mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-20 05:24:09 +00:00
[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:
@@ -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>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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="starboard_post-notnull">
|
||||
<addNotNullConstraint columnName="ignored"
|
||||
tableName="starboard_post"
|
||||
validate="true"/>
|
||||
<addNotNullConstraint columnName="post_message_id"
|
||||
tableName="starboard_post"
|
||||
validate="true"/>
|
||||
<addNotNullConstraint columnName="starboard_message_id"
|
||||
tableName="starboard_post"
|
||||
validate="true"/>
|
||||
<addNotNullConstraint columnName="starred_date"
|
||||
tableName="starboard_post"
|
||||
validate="true"/>
|
||||
<addNotNullConstraint columnName="created"
|
||||
tableName="starboard_post"
|
||||
validate="true"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?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="starboard_post_reaction-notnull">
|
||||
<addNotNullConstraint columnName="created"
|
||||
tableName="starboard_post_reaction"
|
||||
validate="true"/>
|
||||
<addNotNullConstraint columnName="post_id"
|
||||
tableName="starboard_post_reaction"
|
||||
validate="true"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?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="starboard_post.xml" relativeToChangelogFile="true"/>
|
||||
<include file="starboard_post_reaction.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -8,4 +8,5 @@
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="1.0-starboard/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.2.3-starboard/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.2.12/collection.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -22,17 +22,17 @@ public class StarboardPost implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
@Column(name = "id", nullable = false)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "author_user_in_server_id", nullable = false)
|
||||
private AUserInAServer author;
|
||||
|
||||
@Column(name = "starboard_message_id")
|
||||
@Column(name = "starboard_message_id", nullable = false)
|
||||
private Long starboardMessageId;
|
||||
|
||||
@Column(name = "post_message_id")
|
||||
@Column(name = "post_message_id", nullable = false)
|
||||
private Long postMessageId;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@@ -51,10 +51,10 @@ public class StarboardPost implements Serializable {
|
||||
@Transient
|
||||
private Integer reactionCount;
|
||||
|
||||
@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;
|
||||
|
||||
@PostLoad
|
||||
@@ -69,11 +69,12 @@ public class StarboardPost implements Serializable {
|
||||
mappedBy = "starboardPost")
|
||||
private List<StarboardPostReaction> reactions;
|
||||
|
||||
@Column(name = "starred_date")
|
||||
@Column(name = "starred_date", nullable = false)
|
||||
private Instant starredDate;
|
||||
|
||||
@Column(name = "ignored")
|
||||
private boolean ignored;
|
||||
@Builder.Default
|
||||
@Column(name = "ignored", nullable = false)
|
||||
private boolean ignored = false;
|
||||
|
||||
public int getReactionCount() {
|
||||
if(this.reactions == null) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class StarboardPostReaction implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
@Column(name = "id", nullable = false)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@@ -35,10 +35,10 @@ public class StarboardPostReaction implements Serializable {
|
||||
@JoinColumn(name = "server_id", nullable = false)
|
||||
private AServer server;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user