summary refs log tree commit diff
path: root/util/src
diff options
context:
space:
mode:
authorunknownPerson115 <69736850+unknownPerson115@users.noreply.github.com>2021-12-23 20:40:13 -0600
committerGitHub <noreply@github.com>2021-12-23 20:40:13 -0600
commit49426b11472c8679168f84de0d5e4aca68e095af (patch)
tree204946dc4714786060072bf3a30864c275bb44c1 /util/src
parentFix people not being able to create issues (diff)
downloadserver-49426b11472c8679168f84de0d5e4aca68e095af.tar.xz
Fixed potential guild message SQL constraints
i have tied member dependencies to the author id rather than the member id to avoid a dependency cycle and you can now kick/ban someone from a guild/server and the messages will remain in the guild (just like discord) as stated in issue #441

I have also tested this code seems clean so far
(new pull request opened because of branch commit issues)
Diffstat (limited to 'util/src')
-rw-r--r--util/src/entities/Message.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts
index 20a44ca3..e577d5df 100644
--- a/util/src/entities/Message.ts
+++ b/util/src/entities/Message.ts
@@ -84,8 +84,10 @@ export class Message extends BaseClass {
 	@RelationId((message: Message) => message.member)
 	member_id: string;
 
-	@JoinColumn({ name: "member_id" })
-	@ManyToOne(() => Member)
+	@JoinColumn({ name: "author_id", referencedColumnName: "id" })
+	@ManyToOne(() => User, {
+		onDelete: "CASCADE",
+	})
 	member?: Member;
 
 	@Column({ nullable: true })