server/drizzle/migrations/0012_certain_thor_girl.sql
Jesse Wierzbinski d55668d529
fix(database): 💩 Replace uuid_generate_v7 in migrations to a dummy PostgreSQL function
Prevents a fatal error when running migrations on vanilla PostgreSQL instance without the pg_uuidv7 extension
2025-03-30 22:32:04 +02:00

20 lines
692 B
SQL

CREATE TABLE IF NOT EXISTS "Markers" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"noteId" uuid,
"userId" uuid,
"timeline" text NOT NULL,
"created_at" timestamp(3) DEFAULT now() NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "Markers" ADD CONSTRAINT "Markers_noteId_Notes_id_fk" FOREIGN KEY ("noteId") REFERENCES "Notes"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "Markers" ADD CONSTRAINT "Markers_userId_Users_id_fk" FOREIGN KEY ("userId") REFERENCES "Users"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;