diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts
index 63cd6ad3..a4d38315 100644
--- a/util/src/entities/Message.ts
+++ b/util/src/entities/Message.ts
@@ -127,7 +127,7 @@ export class Message extends BaseClass {
mention_channels: Channel[];
@JoinTable({ name: "message_stickers" })
- @ManyToMany(() => Sticker)
+ @ManyToMany(() => Sticker, { cascade: true, onDelete: "CASCADE" })
sticker_items?: Sticker[];
@OneToMany(() => Attachment, (attachment: Attachment) => attachment.message, {
diff --git a/util/src/entities/Migration.ts b/util/src/entities/Migration.ts
new file mode 100644
index 00000000..09df70fb
--- /dev/null
+++ b/util/src/entities/Migration.ts
@@ -0,0 +1,18 @@
+import { Column, Entity, ObjectIdColumn, PrimaryGeneratedColumn } from "typeorm";
+import { BaseClassWithoutId } from ".";
+
+export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith("mongodb")
+ ? ObjectIdColumn
+ : PrimaryGeneratedColumn;
+
+@Entity("migrations")
+export class Migration extends BaseClassWithoutId {
+ @PrimaryIdAutoGenerated()
+ id: number;
+
+ @Column()
+ timestamp: number;
+
+ @Column()
+ name: string;
+}
diff --git a/util/src/entities/ReadState.ts b/util/src/entities/ReadState.ts
index 89480e83..ebef89be 100644
--- a/util/src/entities/ReadState.ts
+++ b/util/src/entities/ReadState.ts
@@ -32,13 +32,8 @@ export class ReadState extends BaseClass {
user: User;
@Column({ nullable: true })
- @RelationId((read_state: ReadState) => read_state.last_message)
last_message_id: string;
- @JoinColumn({ name: "last_message_id" })
- @ManyToOne(() => Message, { nullable: true })
- last_message?: Message;
-
@Column({ nullable: true })
last_pin_timestamp?: Date;
diff --git a/util/src/entities/Sticker.ts b/util/src/entities/Sticker.ts
index 036ff2d0..37bc6fbe 100644
--- a/util/src/entities/Sticker.ts
+++ b/util/src/entities/Sticker.ts
@@ -1,4 +1,5 @@
-import { Column, Entity, JoinColumn, ManyToOne } from "typeorm";
+import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
+import { User } from "./User";
import { BaseClass } from "./BaseClass";
import { Guild } from "./Guild";
@@ -8,6 +9,7 @@ export enum StickerType {
}
export enum StickerFormatType {
+ GIF = 0, // gif is a custom format type and not in discord spec
PNG = 1,
APNG = 2,
LOTTIE = 3,
@@ -21,11 +23,22 @@ export class Sticker extends BaseClass {
@Column({ nullable: true })
description?: string;
- @Column()
- tags: string;
+ @Column({ nullable: true })
+ available?: boolean;
- @Column()
- pack_id: string;
+ @Column({ nullable: true })
+ tags?: string;
+
+ @Column({ nullable: true })
+ @RelationId((sticker: Sticker) => sticker.pack)
+ pack_id?: string;
+
+ @JoinColumn({ name: "pack_id" })
+ @ManyToOne(() => require("./StickerPack").StickerPack, {
+ onDelete: "CASCADE",
+ nullable: true,
+ })
+ pack: import("./StickerPack").StickerPack;
@Column({ nullable: true })
guild_id?: string;
@@ -36,6 +49,15 @@ export class Sticker extends BaseClass {
})
guild?: Guild;
+ @Column({ nullable: true })
+ user_id?: string;
+
+ @JoinColumn({ name: "user_id" })
+ @ManyToOne(() => User, {
+ onDelete: "CASCADE",
+ })
+ user?: User;
+
@Column({ type: "int" })
type: StickerType;
diff --git a/util/src/entities/StickerPack.ts b/util/src/entities/StickerPack.ts
new file mode 100644
index 00000000..ec8c69a2
--- /dev/null
+++ b/util/src/entities/StickerPack.ts
@@ -0,0 +1,31 @@
+import { Column, Entity, JoinColumn, ManyToOne, OneToMany, OneToOne, RelationId } from "typeorm";
+import { Sticker } from ".";
+import { BaseClass } from "./BaseClass";
+
+@Entity("sticker_packs")
+export class StickerPack extends BaseClass {
+ @Column()
+ name: string;
+
+ @Column({ nullable: true })
+ description?: string;
+
+ @Column({ nullable: true })
+ banner_asset_id?: string;
+
+ @OneToMany(() => Sticker, (sticker: Sticker) => sticker.pack, {
+ cascade: true,
+ orphanedRowAction: "delete",
+ })
+ stickers: Sticker[];
+
+ // sku_id: string
+
+ @Column({ nullable: true })
+ @RelationId((pack: StickerPack) => pack.cover_sticker)
+ cover_sticker_id?: string;
+
+ @ManyToOne(() => Sticker, { nullable: true })
+ @JoinColumn()
+ cover_sticker?: Sticker;
+}
diff --git a/util/src/entities/index.ts b/util/src/entities/index.ts
index 7b1c9750..b52841c9 100644
--- a/util/src/entities/index.ts
+++ b/util/src/entities/index.ts
@@ -11,6 +11,7 @@ export * from "./Guild";
export * from "./Invite";
export * from "./Member";
export * from "./Message";
+export * from "./Migration";
export * from "./RateLimit";
export * from "./ReadState";
export * from "./Recipient";
@@ -18,6 +19,7 @@ export * from "./Relationship";
export * from "./Role";
export * from "./Session";
export * from "./Sticker";
+export * from "./StickerPack";
export * from "./Team";
export * from "./TeamMember";
export * from "./Template";
|