You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: server/migrations/0000_closed_scalphunter.sql
+9-3Lines changed: 9 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -4,16 +4,16 @@ CREATE TABLE IF NOT EXISTS "media" (
4
4
"created_at"timestamp DEFAULT now() NOT NULL,
5
5
"url"textNOT NULL,
6
6
"type"textNOT NULL,
7
-
"thumbnail"text
7
+
"thumbnail"text,
8
+
"message_id" uuid
8
9
);
9
10
--> statement-breakpoint
10
11
CREATETABLEIF NOT EXISTS "messages" (
11
12
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
12
13
"text"textNOT NULL,
13
14
"created_at"timestamp DEFAULT now(),
14
15
"from_id" uuid NOT NULL,
15
-
"to_id" uuid NOT NULL,
16
-
"media_id" uuid[] DEFAULT '{}'::uuid[]
16
+
"to_id" uuid NOT NULL
17
17
);
18
18
--> statement-breakpoint
19
19
CREATETABLEIF NOT EXISTS "sessions" (
@@ -45,6 +45,12 @@ EXCEPTION
45
45
WHEN duplicate_object THEN null;
46
46
END $$;
47
47
--> statement-breakpoint
48
+
DO $$ BEGIN
49
+
ALTERTABLE"media" ADD CONSTRAINT"media_message_id_messages_id_fk"FOREIGN KEY ("message_id") REFERENCES"public"."messages"("id") ON DELETE cascadeONUPDATE no action;
50
+
EXCEPTION
51
+
WHEN duplicate_object THEN null;
52
+
END $$;
53
+
--> statement-breakpoint
48
54
DO $$ BEGIN
49
55
ALTERTABLE"messages" ADD CONSTRAINT"messages_from_id_users_id_fk"FOREIGN KEY ("from_id") REFERENCES"public"."users"("id") ON DELETE no action ONUPDATE no action;
0 commit comments