[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

@@ -0,0 +1,10 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,29 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
<changeSet author="Sheldan" id="suggestion-notnull">
<addNotNullConstraint columnName="id"
tableName="suggestion"
validate="true"/>
<addNotNullConstraint columnName="message_id"
tableName="suggestion"
validate="true"/>
<addNotNullConstraint columnName="state"
tableName="suggestion"
validate="true"/>
<addNotNullConstraint columnName="created"
tableName="suggestion"
validate="true"/>
<addNotNullConstraint columnName="channel_id"
tableName="suggestion"
validate="true"/>
<addNotNullConstraint columnName="server_id"
tableName="suggestion"
validate="true"/>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,10 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
<include file="suggestion.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -7,4 +7,5 @@
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
<include file="1.0-suggestion/collection.xml" relativeToChangelogFile="true"/>
<include file="1.2.12/collection.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -27,16 +27,16 @@ public class Suggestion implements Serializable {
@Getter
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "suggester_user_in_server_id")
@JoinColumn(name = "suggester_user_in_server_id", nullable = false)
private AUserInAServer suggester;
@Getter
@Column(name = "message_id")
@Column(name = "message_id", nullable = false)
private Long messageId;
@Getter
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "channel_id")
@JoinColumn(name = "channel_id", nullable = false)
private AChannel channel;
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@@ -46,16 +46,16 @@ public class Suggestion implements Serializable {
@Getter
@Enumerated(EnumType.STRING)
@Column(name = "state")
@Column(name = "state", nullable = false)
private SuggestionState state;
@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;
@Column(name = "suggestion_text")
@Column(name = "suggestion_text", nullable = false)
private String suggestionText;
@Getter