Drizzle schema for projects, defects, push_subscriptions (C8); generated migration; a defects repository (createDefect / listRecentDefects); a programmatic migrator; and a db:verify script. section_id is a plain string referencing in-code board ids, no FK (ADR 0001). Verified against real Postgres: migration applies, a defect round-trips, /api/health reports db up.
27 lines
993 B
SQL
27 lines
993 B
SQL
CREATE TABLE "defects" (
|
|
"id" uuid PRIMARY KEY NOT NULL,
|
|
"section_id" text NOT NULL,
|
|
"project_id" uuid NOT NULL,
|
|
"verbatim" text NOT NULL,
|
|
"reporter_email" text NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "projects" (
|
|
"id" uuid PRIMARY KEY NOT NULL,
|
|
"name" text NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
CONSTRAINT "projects_name_unique" UNIQUE("name")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "push_subscriptions" (
|
|
"id" uuid PRIMARY KEY NOT NULL,
|
|
"endpoint" text NOT NULL,
|
|
"p256dh" text NOT NULL,
|
|
"auth" text NOT NULL,
|
|
"reporter_email" text,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
CONSTRAINT "push_subscriptions_endpoint_unique" UNIQUE("endpoint")
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "defects" ADD CONSTRAINT "defects_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action; |