mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-08 18:07:39 +00:00
[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:
@@ -1,5 +1,5 @@
|
||||
package dev.sheldan.abstracto.core.command.models;
|
||||
|
||||
public enum TableLocks {
|
||||
CHANNELS
|
||||
CHANNELS, USER_IN_SERVER, USER
|
||||
}
|
||||
|
||||
@@ -40,17 +40,7 @@ public class ACommand implements Serializable {
|
||||
@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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
@Entity(name = "command_in_server")
|
||||
@@ -22,14 +23,15 @@ public class ACommandInAServer implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "command_in_server_id")
|
||||
private Long commandInServerId;
|
||||
|
||||
@OneToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
@JoinColumn(name = "commandReference", nullable = false)
|
||||
@JoinColumn(name = "command_id", nullable = false)
|
||||
private ACommand commandReference;
|
||||
|
||||
@OneToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
@JoinColumn(name = "serverReference", nullable = false)
|
||||
@JoinColumn(name = "server_id", nullable = false)
|
||||
private AServer serverReference;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@@ -46,9 +48,16 @@ public class ACommandInAServer implements Serializable {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Column
|
||||
@Column(name = "restricted")
|
||||
private Boolean restricted;
|
||||
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@Column(name = "updated")
|
||||
private Instant updated;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,17 +38,7 @@ public class AModule implements Serializable {
|
||||
@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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,10 +42,8 @@ public class AChannel implements SnowFlake, Serializable {
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@PrePersist
|
||||
private void onInsert() {
|
||||
this.created = Instant.now();
|
||||
}
|
||||
@Column(name = "updated")
|
||||
private Instant updated;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
@@ -23,7 +23,7 @@ public class AChannelGroup implements Serializable {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column
|
||||
@Column(name = "group_name")
|
||||
@Setter
|
||||
private String groupName;
|
||||
|
||||
@@ -40,10 +40,8 @@ public class AChannelGroup implements Serializable {
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@PrePersist
|
||||
private void onInsert() {
|
||||
this.created = Instant.now();
|
||||
}
|
||||
@Column(name = "updated")
|
||||
private Instant updated;
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
|
||||
@Entity
|
||||
@Table(name = "channel_group_command")
|
||||
@@ -20,6 +21,7 @@ public class AChannelGroupCommand implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "command_in_group_id")
|
||||
private Long commandInGroupId;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@@ -33,6 +35,13 @@ public class AChannelGroupCommand implements Serializable {
|
||||
private AChannelGroup group;
|
||||
|
||||
@Setter
|
||||
@Column(name = "enabled")
|
||||
private Boolean enabled;
|
||||
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@Column(name = "updated")
|
||||
private Instant updated;
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package dev.sheldan.abstracto.core.models.database;
|
||||
import net.dv8tion.jda.api.entities.ChannelType;
|
||||
|
||||
public enum AChannelType {
|
||||
TEXT, DM, VOICE, NEWS, CATEGORY, UNKOWN;
|
||||
TEXT, DM, VOICE, NEWS, CATEGORY, UNKNOWN;
|
||||
|
||||
public static AChannelType getAChannelType(ChannelType type) {
|
||||
switch (type) {
|
||||
@@ -11,7 +11,7 @@ public enum AChannelType {
|
||||
case PRIVATE: return AChannelType.DM;
|
||||
case VOICE: return AChannelType.VOICE;
|
||||
case CATEGORY: return AChannelType.CATEGORY;
|
||||
default: return AChannelType.UNKOWN;
|
||||
default: return AChannelType.UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
|
||||
@Entity
|
||||
@Table(name="systemConfig")
|
||||
@Table(name="system_config")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@@ -46,19 +46,9 @@ public class AConfig implements Serializable {
|
||||
@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();
|
||||
}
|
||||
|
||||
public String getValueAsString() {
|
||||
if(getLongValue() != null) {
|
||||
return getLongValue().toString();
|
||||
|
||||
@@ -24,34 +24,24 @@ public class ADefaultConfig implements Serializable {
|
||||
@Column
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Column(name = "string_value")
|
||||
@Setter
|
||||
private String stringValue;
|
||||
|
||||
@Column
|
||||
@Column(name = "double_value")
|
||||
@Setter
|
||||
private Double doubleValue;
|
||||
|
||||
@Column
|
||||
@Column(name = "long_value")
|
||||
@Setter
|
||||
private Long longValue;
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
public String getValueAsString() {
|
||||
if(getLongValue() != null) {
|
||||
return getLongValue().toString();
|
||||
|
||||
@@ -21,48 +21,39 @@ public class AEmote implements Serializable, Fakeable {
|
||||
|
||||
@javax.persistence.Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Integer id;
|
||||
|
||||
@Column
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
// the way discord calls them and the unicode char for default Tweemoji emotes
|
||||
@Column
|
||||
@Column(name = "emote_key")
|
||||
@Setter
|
||||
private String emoteKey;
|
||||
|
||||
@Column
|
||||
@Column(name = "emote_id")
|
||||
@Setter
|
||||
private Long emoteId;
|
||||
|
||||
@Column
|
||||
@Column(name = "animated")
|
||||
@Setter
|
||||
private Boolean animated;
|
||||
|
||||
@Column
|
||||
@Column(name = "custom")
|
||||
@Setter
|
||||
private Boolean custom;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "emote_server_id", nullable = false)
|
||||
@JoinColumn(name = "server_id", nullable = false)
|
||||
private AServer serverRef;
|
||||
|
||||
@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(name = "changeable")
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
@@ -28,6 +28,7 @@ public class AFeature implements SnowFlake, Serializable {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Column(name = "key")
|
||||
private String key;
|
||||
|
||||
@Getter
|
||||
@@ -39,18 +40,7 @@ public class AFeature implements SnowFlake, Serializable {
|
||||
@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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -44,23 +44,13 @@ public class AFeatureFlag implements Serializable {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Column(name = "enabled")
|
||||
private boolean enabled;
|
||||
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@PrePersist
|
||||
private void onInsert() {
|
||||
this.created = Instant.now();
|
||||
}
|
||||
|
||||
@Column(name = "updated")
|
||||
private Instant updateTimestamp;
|
||||
|
||||
@PreUpdate
|
||||
private void onUpdate() {
|
||||
this.updateTimestamp = Instant.now();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class AFeatureMode implements Serializable {
|
||||
@JoinColumn(name = "server_id", nullable = false)
|
||||
private AServer server;
|
||||
|
||||
@Column
|
||||
@Column(name = "enabled")
|
||||
@Getter
|
||||
@Setter
|
||||
private Boolean enabled;
|
||||
@@ -48,17 +48,7 @@ public class AFeatureMode implements Serializable {
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@PrePersist
|
||||
private void onInsert() {
|
||||
this.created = Instant.now();
|
||||
}
|
||||
|
||||
@Column(name = "updated")
|
||||
private Instant updateTimestamp;
|
||||
|
||||
@PreUpdate
|
||||
private void onUpdate() {
|
||||
this.updateTimestamp = Instant.now();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,32 +26,23 @@ public class ARole implements SnowFlake, Serializable {
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@Getter
|
||||
@Setter
|
||||
@JoinColumn(name = "role_server_id", nullable = false)
|
||||
@JoinColumn(name = "server_id", nullable = false)
|
||||
private AServer server;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Column(name = "deleted")
|
||||
private Boolean deleted;
|
||||
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@PrePersist
|
||||
private void onInsert() {
|
||||
this.created = Instant.now();
|
||||
}
|
||||
|
||||
@Column(name = "updated")
|
||||
private Instant updated;
|
||||
|
||||
@Transient
|
||||
private boolean fake;
|
||||
|
||||
@PreUpdate
|
||||
private void onUpdate() {
|
||||
this.updated = Instant.now();
|
||||
}
|
||||
|
||||
public String getAsMention() {
|
||||
return "<@&" + getId() + '>';
|
||||
}
|
||||
|
||||
@@ -28,22 +28,12 @@ public class AServer implements SnowFlake, Serializable {
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@PrePersist
|
||||
private void onInsert() {
|
||||
this.created = Instant.now();
|
||||
}
|
||||
|
||||
@Column(name = "updated")
|
||||
private Instant updated;
|
||||
|
||||
@Transient
|
||||
private boolean fake;
|
||||
|
||||
@PreUpdate
|
||||
private void onUpdate() {
|
||||
this.updated = Instant.now();
|
||||
}
|
||||
|
||||
@OneToOne(mappedBy = "server", cascade = CascadeType.ALL)
|
||||
@PrimaryKeyJoinColumn
|
||||
private AllowedMention allowedMention;
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
public class AUser implements Serializable {
|
||||
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@OneToMany(
|
||||
@@ -32,17 +33,7 @@ public class AUser implements Serializable {
|
||||
@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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,27 +25,17 @@ public class AUserInAServer implements Serializable {
|
||||
private Long userInServerId;
|
||||
|
||||
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
@JoinColumn(name = "userReference", nullable = false)
|
||||
@JoinColumn(name = "user_id", nullable = false)
|
||||
private AUser userReference;
|
||||
|
||||
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
@JoinColumn(name = "serverReference", nullable = false)
|
||||
@JoinColumn(name = "server_id", nullable = false)
|
||||
private AServer serverReference;
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,18 +44,8 @@ public class AllowedMention implements Serializable {
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@PrePersist
|
||||
private void onInsert() {
|
||||
this.created = Instant.now();
|
||||
}
|
||||
|
||||
@Column(name = "updated")
|
||||
private Instant updateTimestamp;
|
||||
|
||||
@PreUpdate
|
||||
private void onUpdate() {
|
||||
this.updateTimestamp = Instant.now();
|
||||
}
|
||||
private Instant updated;
|
||||
|
||||
public boolean allAllowed() {
|
||||
return everyone && user && role;
|
||||
|
||||
@@ -4,6 +4,7 @@ import lombok.*;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.Instant;
|
||||
|
||||
@Entity
|
||||
@Table(name = "channel_group_type")
|
||||
@@ -24,4 +25,10 @@ public class ChannelGroupType {
|
||||
|
||||
@Column(name = "group_type_key")
|
||||
private String groupTypeKey;
|
||||
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@Column(name = "updated")
|
||||
private Instant updated;
|
||||
}
|
||||
|
||||
@@ -19,31 +19,21 @@ import java.time.Instant;
|
||||
public class DefaultEmote implements Serializable {
|
||||
|
||||
@javax.persistence.Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Column(name = "emote_key")
|
||||
@Setter
|
||||
private String emoteKey;
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -31,23 +31,14 @@ public class DefaultFeatureFlag implements Serializable {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Column(name = "enabled")
|
||||
private boolean enabled;
|
||||
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@PrePersist
|
||||
private void onInsert() {
|
||||
this.created = Instant.now();
|
||||
}
|
||||
|
||||
@Column(name = "updated")
|
||||
private Instant updateTimestamp;
|
||||
|
||||
@PreUpdate
|
||||
private void onUpdate() {
|
||||
this.updateTimestamp = Instant.now();
|
||||
}
|
||||
private Instant updated;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -38,25 +38,18 @@ public class DefaultFeatureMode implements Serializable {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Column(name = "enabled")
|
||||
private boolean enabled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Column(name = "mode")
|
||||
private String mode;
|
||||
|
||||
@Column(name = "created")
|
||||
private Instant created;
|
||||
|
||||
@PrePersist
|
||||
private void onInsert() {
|
||||
this.created = Instant.now();
|
||||
}
|
||||
|
||||
@Column(name = "updated")
|
||||
private Instant updateTimestamp;
|
||||
private Instant updated;
|
||||
|
||||
@PreUpdate
|
||||
private void onUpdate() {
|
||||
this.updateTimestamp = Instant.now();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,26 +20,17 @@ public class DefaultPostTarget implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Getter
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Getter
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -20,9 +20,11 @@ public class PostTarget implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Getter
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Getter
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@@ -38,18 +40,7 @@ public class PostTarget implements Serializable {
|
||||
@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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user