summary refs log tree commit diff
path: root/util/src/entities
diff options
context:
space:
mode:
authoruurgothat <cckhmck@gmail.com>2021-10-24 18:13:51 +0300
committeruurgothat <cckhmck@gmail.com>2021-10-24 18:13:51 +0300
commitb603b81629a7775914dcb4eae53f418c3620dbdd (patch)
treeb13cc06dcf49ebe49ffff452758e3849baa0ca2f /util/src/entities
parentFormat the file (diff)
parentMerge pull request #492 from fosscord/translation (diff)
downloadserver-b603b81629a7775914dcb4eae53f418c3620dbdd.tar.xz
Merge branch 'master' of https://github.com/fosscord/fosscord-server
Diffstat (limited to 'util/src/entities')
-rw-r--r--util/src/entities/Invite.ts2
-rw-r--r--util/src/entities/Message.ts8
-rw-r--r--util/src/entities/Migration.ts2
3 files changed, 9 insertions, 3 deletions
diff --git a/util/src/entities/Invite.ts b/util/src/entities/Invite.ts
index b3e00957..6ac64ddc 100644
--- a/util/src/entities/Invite.ts
+++ b/util/src/entities/Invite.ts
@@ -71,7 +71,7 @@ export class Invite extends BaseClassWithoutId {
 	@Column({ nullable: true })
 	target_user_type?: number;
 
-	@Column({ nullable: true})
+	@Column({ nullable: true })
 	vanity_url?: boolean;
 
 	static async joinGuild(user_id: string, code: string) {
diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts
index a4d38315..20a44ca3 100644
--- a/util/src/entities/Message.ts
+++ b/util/src/entities/Message.ts
@@ -9,6 +9,7 @@ import {
 	CreateDateColumn,
 	Entity,
 	FindConditions,
+	Index,
 	JoinColumn,
 	JoinTable,
 	ManyToMany,
@@ -45,9 +46,11 @@ export enum MessageType {
 }
 
 @Entity("messages")
+@Index(["channel_id", "id"], { unique: true })
 export class Message extends BaseClass {
 	@Column({ nullable: true })
 	@RelationId((message: Message) => message.channel)
+	@Index()
 	channel_id: string;
 
 	@JoinColumn({ name: "channel_id" })
@@ -68,10 +71,13 @@ export class Message extends BaseClass {
 
 	@Column({ nullable: true })
 	@RelationId((message: Message) => message.author)
+	@Index()
 	author_id: string;
 
 	@JoinColumn({ name: "author_id", referencedColumnName: "id" })
-	@ManyToOne(() => User)
+	@ManyToOne(() => User, {
+		onDelete: "CASCADE",
+	})
 	author?: User;
 
 	@Column({ nullable: true })
diff --git a/util/src/entities/Migration.ts b/util/src/entities/Migration.ts
index 7393496f..3f39ae72 100644
--- a/util/src/entities/Migration.ts
+++ b/util/src/entities/Migration.ts
@@ -10,7 +10,7 @@ export class Migration extends BaseClassWithoutId {
 	@PrimaryIdAutoGenerated()
 	id: number;
 
-	@Column({ type: 'bigint' })
+	@Column({ type: "bigint" })
 	timestamp: number;
 
 	@Column()