summary refs log tree commit diff
path: root/util/src/entities/Message.ts
diff options
context:
space:
mode:
Diffstat (limited to 'util/src/entities/Message.ts')
-rw-r--r--util/src/entities/Message.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts
index 506db71a..0712f545 100644
--- a/util/src/entities/Message.ts
+++ b/util/src/entities/Message.ts
@@ -8,12 +8,14 @@ import {
 	Column,
 	CreateDateColumn,
 	Entity,
+	FindConditions,
 	JoinColumn,
 	JoinTable,
 	ManyToMany,
 	ManyToOne,
 	OneToMany,
 	RelationId,
+	RemoveOptions,
 	UpdateDateColumn,
 } from "typeorm";
 import { BaseClass } from "./BaseClass";
@@ -112,7 +114,7 @@ export class Message extends BaseClass {
 	mention_everyone?: boolean;
 
 	@JoinTable({ name: "message_user_mentions" })
-	@ManyToMany(() => User)
+	@ManyToMany(() => User, { orphanedRowAction: "delete", onDelete: "CASCADE", cascade: true })
 	mentions: User[];
 
 	@JoinTable({ name: "message_role_mentions" })
@@ -127,8 +129,11 @@ export class Message extends BaseClass {
 	@ManyToMany(() => Sticker)
 	sticker_items?: Sticker[];
 
-	@JoinColumn({ name: "attachment_ids" })
-	@OneToMany(() => Attachment, (attachment: Attachment) => attachment.message, { cascade: true })
+	@OneToMany(() => Attachment, (attachment: Attachment) => attachment.message, {
+		cascade: true,
+		orphanedRowAction: "delete",
+		onDelete: "CASCADE",
+	})
 	attachments?: Attachment[];
 
 	@Column({ type: "simple-json" })