[AB-103] adding triggers to update created and updating attributes on tables

fixing error handling in installer
merging change sets to larger operations
adding check constraints
fixing suggestion id handling
applying naming conventions to various columns
adding indices to tables
adding user in server and user locking
This commit is contained in:
Sheldan
2021-02-07 03:06:48 +01:00
parent dac3b0887f
commit 038d5c3832
126 changed files with 1416 additions and 986 deletions

View File

@@ -17,7 +17,7 @@ import java.time.Instant;
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "modmail_message")
@Table(name = "mod_mail_message")
@Getter
@Setter
@EqualsAndHashCode
@@ -29,6 +29,7 @@ public class ModMailMessage implements Serializable {
* The ID of the message which caused this message to be created, either the message containing the command or the message received from the user
*/
@Id
@Column(name = "id")
private Long messageId;
/**
@@ -38,41 +39,39 @@ public class ModMailMessage implements Serializable {
*/
@Column(name = "created_message_in_dm")
private Long createdMessageInDM;
@Column
@Column(name = "created_message_in_channel")
private Long createdMessageInChannel;
/**
* The {@link AUserInAServer} which authored this message
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "modmail_message_author", nullable = false)
@JoinColumn(name = "author_user_in_server_id", nullable = false)
private AUserInAServer author;
/**
* The {@link ModMailThread} in whose context this message was sent and this message is related to
*/
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "threadReference", nullable = false)
@JoinColumn(name = "thread_id", nullable = false)
private ModMailThread threadReference;
/**
* true: message was send via command, false: message was send from the user
* This is used to decide where to get the message from in case of logging, because the user might delete the message and we do not want to re-parse the command message
*/
@Column
@Column(name = "dm_channel")
private Boolean dmChannel;
/**
* Staff only: Whether or not this message meant to be sent anonymous
*/
@Column
@Column(name = "anonymous")
private Boolean anonymous;
@Column(name = "created")
private Instant created;
@PrePersist
private void onInsert() {
this.created = Instant.now();
}
@Column(name = "updated")
private Instant updated;
}

View File

@@ -17,7 +17,7 @@ import java.time.Instant;
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "modmail_role")
@Table(name = "mod_mail_role")
@Getter
@Setter
@EqualsAndHashCode
@@ -29,6 +29,7 @@ public class ModMailRole implements Serializable {
* Unique ID of the mod mail role
*/
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long modMailRoleId;
@@ -36,29 +37,20 @@ public class ModMailRole implements Serializable {
* Which {@link AServer} this role is associated with, for convenience
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "modmail_role_server", nullable = false)
@JoinColumn(name = "server_id", nullable = false)
private AServer server;
/**
* The actual {@link ARole} which this mod mail role references
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "modmail_role", nullable = false)
@JoinColumn(name = "role_id", nullable = false)
private ARole role;
@Column(name = "created")
private Instant created;
@PrePersist
private void onInsert() {
this.created = Instant.now();
}
@Column(name = "updated")
private Instant updated;
@PreUpdate
private void onUpdate() {
this.updated = Instant.now();
}
}

View File

@@ -20,7 +20,7 @@ import java.util.List;
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "modmail_thread")
@Table(name = "mod_mail_thread")
@Getter
@Setter
@EqualsAndHashCode
@@ -30,46 +30,37 @@ public class ModMailThread implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
/**
* The member who opened the thread or who got contacted
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "modmail_user", nullable = false)
@JoinColumn(name = "user_in_server_id", nullable = false)
private AUserInAServer user;
/**
* The text channel in which this thread is dealt with
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "modmail_thread_channel", nullable = false)
@JoinColumn(name = "channel_id", nullable = false)
private AChannel channel;
/**
* The server on which this mod mail thread is, for convenience
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "modmail_thread_server", nullable = false)
@JoinColumn(name = "server_id", nullable = false)
private AServer server;
@Column(name = "created")
private Instant created;
@PrePersist
private void onInsert() {
this.created = Instant.now();
}
@Column(name = "updated")
private Instant updated;
@PreUpdate
private void onUpdate() {
this.updated = Instant.now();
}
@Column
@Column(name = "closed")
private Instant closed;
/**
@@ -101,7 +92,7 @@ public class ModMailThread implements Serializable {
* The current state of the mod mail thread. Whether or not the last post was by staff or user.
*/
@Enumerated(EnumType.STRING)
@Column
@Column(name = "state")
private ModMailThreadState state;
}

View File

@@ -15,7 +15,7 @@ import java.time.Instant;
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "modmail_subscriber")
@Table(name = "mod_mail_subscriber")
@Getter
@Setter
@EqualsAndHashCode
@@ -25,28 +25,27 @@ public class ModMailThreadSubscriber {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long subscriberId;
/**
* The staff member which is subscribed
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "modmail_thread_subscriber", nullable = false)
@JoinColumn(name = "user_in_server_id", nullable = false)
private AUserInAServer subscriber;
/**
* The thread for which the member is subscribed to
*/
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "modMailThread", nullable = false)
@JoinColumn(name = "mod_mail_thread_id", nullable = false)
private ModMailThread threadReference;
@Column(name = "created")
private Instant created;
@PrePersist
private void onInsert() {
this.created = Instant.now();
}
@Column(name = "updated")
private Instant updated;
}