[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

@@ -29,6 +29,7 @@ public class AssignableRole implements Serializable {
* The unique ID of this {@link AssignableRole assignableRole}
*/
@Id
@Column(name = "id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@@ -36,7 +37,7 @@ public class AssignableRole implements Serializable {
* The {@link AEmote emote} this role is associated with
*/
@OneToOne(fetch = FetchType.LAZY, orphanRemoval = true)
@JoinColumn(name = "emote_id")
@JoinColumn(name = "emote_id", nullable = false)
private AEmote emote;
/**
@@ -80,7 +81,7 @@ public class AssignableRole implements Serializable {
/**
* The description which is shown in the embeds of the posts of the {@link AssignableRolePlace}
*/
@Column(name = "description")
@Column(name = "description", nullable = false)
private String description;
/**
@@ -93,18 +94,18 @@ public class AssignableRole implements Serializable {
* The position of this assignable role within the {@link AssignableRole}. This is required in order to show them
* the same order as the descriptions in the fields and also to move them around and switch positions
*/
@Column(name = "position")
@Column(name = "position", nullable = false)
private Integer position;
/**
* The {@link Instant} this entity was created
*/
@Column(name = "created")
@Column(name = "created", nullable = false, insertable = false, updatable = false)
private Instant created;
/**
* The {@link Instant} this entity was updated
*/
@Column(name = "updated")
@Column(name = "updated", insertable = false, updatable = false)
private Instant updated;
}

View File

@@ -33,14 +33,14 @@ public class AssignableRolePlace implements Serializable {
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
@Column(name = "id", nullable = false)
private Long id;
/**
* The channel in which the {@link AssignableRolePlacePost posts} for this place should be created
*/
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name="channel_id")
@JoinColumn(name="channel_id", nullable = false)
private AChannel channel;
/**
@@ -53,7 +53,7 @@ public class AssignableRolePlace implements Serializable {
/**
* The key this place is associated with via commands. Unique per server.
*/
@Column(name = "key")
@Column(name = "key", nullable = false)
private String key;
/**
@@ -84,47 +84,47 @@ public class AssignableRolePlace implements Serializable {
/**
* The text which is displayed in the first description area of the created {@link AssignableRolePlacePost}
*/
@Column(name = "text")
@Column(name = "text", nullable = false)
private String text;
/**
* Whether or not the reactions placed onto the posts should be acted upon
*/
@Builder.Default
@Column(name = "active")
@Column(name = "active", nullable = false)
private Boolean active = true;
/**
* Whether or not the fields containing the descriptions should be inline
*/
@Builder.Default
@Column(name = "inline")
@Column(name = "inline", nullable = false)
private Boolean inline = false;
/**
* Whether or not it should be restricted, that a {@link AssignedRoleUser} should only have one role of this place
*/
@Builder.Default
@Column(name = "unique_roles")
@Column(name = "unique_roles", nullable = false)
private Boolean uniqueRoles = false;
/**
* Whether or not the added reactions should be removed automatically
*/
@Builder.Default
@Column(name = "auto_remove")
@Column(name = "auto_remove", nullable = false)
private Boolean autoRemove = false;
/**
* The {@link Instant} this entity was created
*/
@Column(name = "created")
@Column(name = "created", nullable = false, insertable = false, updatable = false)
private Instant created;
/**
* The {@link Instant} this entity was updated
*/
@Column(name = "updated")
@Column(name = "updated", insertable = false, updatable = false)
private Instant updated;
}

View File

@@ -28,14 +28,14 @@ public class AssignableRolePlacePost implements Serializable {
* The ID of the {@link net.dv8tion.jda.api.entities.Message message} which represents this post with the reactions.
*/
@Id
@Column(name = "id")
@Column(name = "id", nullable = false)
private Long id;
/**
* The actual {@link AChannel channel} in which the post ended up in
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "channel_id")
@JoinColumn(name = "channel_id", nullable = false)
private AChannel usedChannel;
/**
@@ -66,13 +66,13 @@ public class AssignableRolePlacePost implements Serializable {
/**
* The {@link Instant} this entity was created
*/
@Column(name = "created")
@Column(name = "created", nullable = false, insertable = false, updatable = false)
private Instant created;
/**
* The {@link Instant} this entity was updated
*/
@Column(name = "updated")
@Column(name = "updated", insertable = false, updatable = false)
private Instant updated;
}

View File

@@ -27,7 +27,7 @@ public class AssignedRoleUser implements Serializable {
* The ID of the associated {@link AUserInAServer userInAServer}
*/
@Id
@Column(name = "id")
@Column(name = "id", nullable = false)
private Long id;
@OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@@ -48,13 +48,13 @@ public class AssignedRoleUser implements Serializable {
/**
* The {@link Instant} this entity was created
*/
@Column(name = "created")
@Column(name = "created", nullable = false, insertable = false, updatable = false)
private Instant created;
/**
* The {@link Instant} this entity was updated
*/
@Column(name = "updated")
@Column(name = "updated", insertable = false, updatable = false)
private Instant updated;
}