[AB-263] adding stricter not null checks to database, disabling updates/inserts for created and updated columns to only rely on triggers

This commit is contained in:
Sheldan
2021-05-23 14:17:03 +02:00
parent 04a7cfafd7
commit 13a6e1fdca
145 changed files with 1204 additions and 350 deletions

View File

@@ -51,13 +51,13 @@ public class Mute implements Serializable {
/**
* The reason of the mute which is stored
*/
@Column(name = "reason")
@Column(name = "reason", nullable = false)
private String reason;
/**
* The date when the mute was cast, and the start date
*/
@Column(name = "mute_date")
@Column(name = "mute_date", nullable = false)
private Instant muteDate;
/**
@@ -69,8 +69,9 @@ public class Mute implements Serializable {
/**
* Whether or not the mute already ended, be it manually or when the time passed
*/
@Column(name = "mute_ended")
private Boolean muteEnded;
@Builder.Default
@Column(name = "mute_ended", nullable = false)
private Boolean muteEnded = false;
/**
* The message which contained the command which caused this mute
@@ -82,7 +83,7 @@ public class Mute implements Serializable {
* The channel in which this mute was cast
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "mutingChannel", nullable = false)
@JoinColumn(name = "mutingChannel")
private AChannel mutingChannel;
/**
@@ -91,7 +92,7 @@ public class Mute implements Serializable {
@Column(name = "trigger_key")
private String triggerKey;
@Column(name = "created")
@Column(name = "created", nullable = false, insertable = false, updatable = false)
private Instant created;
@PrePersist
@@ -99,7 +100,7 @@ public class Mute implements Serializable {
this.muteDate = Instant.now();
}
@Column(name = "updated")
@Column(name = "updated", insertable = false, updatable = false)
private Instant updated;
}

View File

@@ -26,7 +26,7 @@ public class MuteRole implements Serializable {
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
@Column(name = "id", nullable = false)
private Long id;
/**
@@ -45,10 +45,10 @@ public class MuteRole implements Serializable {
@JoinColumn(name = "role_id", nullable = false)
private ARole role;
@Column(name = "created")
@Column(name = "created", nullable = false, insertable = false, updatable = false)
private Instant created;
@Column(name = "updated")
@Column(name = "updated", insertable = false, updatable = false)
private Instant updated;
}

View File

@@ -31,13 +31,13 @@ public class UserNote implements Serializable {
@JoinColumn(name = "user_in_server_id", nullable = false)
private AUserInAServer user;
@Column(length = 2000, name = "note")
@Column(length = 2000, name = "note", nullable = false)
private String note;
@Column(name = "created")
@Column(name = "created", nullable = false, insertable = false, updatable = false)
private Instant created;
@Column(name = "updated")
@Column(name = "updated", insertable = false, updatable = false)
private Instant updated;
}

View File

@@ -64,7 +64,7 @@ public class Warning implements Serializable {
*/
@Getter
@Setter
@Column(name = "warn_date")
@Column(name = "warn_date", nullable = false)
private Instant warnDate;
/**
@@ -72,8 +72,9 @@ public class Warning implements Serializable {
*/
@Getter
@Setter
@Column(name = "decayed")
private Boolean decayed;
@Builder.Default
@Column(name = "decayed", nullable = false)
private Boolean decayed = false;
/**
* The date at which the warning was decayed
@@ -83,10 +84,10 @@ public class Warning implements Serializable {
@Column(name = "decay_date")
private Instant decayDate;
@Column(name = "created")
@Column(name = "created", nullable = false, insertable = false, updatable = false)
private Instant created;
@Column(name = "updated")
@Column(name = "updated", insertable = false, updatable = false)
private Instant updated;
}