1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/mipilin synced 2025-01-31 02:53:36 +00:00
mipilin/drizzle/0006_lame_grey_gargoyle.sql

15 lines
660 B
MySQL
Raw Normal View History

CREATE TABLE IF NOT EXISTS "journal_entries" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "journal_entries_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"user" integer NOT NULL,
"mood-change" integer DEFAULT 0 NOT NULL,
"entry" varchar(4096) DEFAULT '' NOT NULL,
"visibility" integer DEFAULT 1 NOT NULL,
"date" timestamp NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "journal_entries" ADD CONSTRAINT "journal_entries_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 $$;