1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/mipilin synced 2025-01-31 02:53:36 +00:00
mipilin/drizzle/0003_closed_alex_power.sql
roxwize a3e6df6ce8
Rae from website
Signed-off-by: roxwize <rae@roxwize.xyz>
2025-01-22 20:34:25 -05:00

19 lines
884 B
SQL

CREATE TABLE IF NOT EXISTS "journal_comments" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "journal_comments_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"user" integer NOT NULL,
"entry" integer NOT NULL,
"content" varchar(512) NOT NULL,
"date" timestamp NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "journal_comments" ADD CONSTRAINT "journal_comments_user_users_id_fk" FOREIGN KEY ("user") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "journal_comments" ADD CONSTRAINT "journal_comments_entry_journal_entries_id_fk" FOREIGN KEY ("entry") REFERENCES "public"."journal_entries"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;