Files
cms-website/apps/api/drizzle/0000_pale_sumo.sql
T
浅念 63830f249e feat(db): 0000 站点域——sites/site_config_revisions + 唯一约束
drizzle-kit 首个迁移从 0000 起编号(计划文案写 0001,以实际产出为准)。
迁移文件 + meta/_journal.json + snapshot 一并入库。

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-20 19:17:16 +08:00

22 lines
1009 B
SQL

CREATE TABLE "site_config_revisions" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"site_id" uuid NOT NULL,
"version" integer NOT NULL,
"data" jsonb NOT NULL,
"checksum" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "sites" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"key" text NOT NULL,
"name" text NOT NULL,
"default_locale" text NOT NULL,
"production_origin" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "sites_key_unique" UNIQUE("key")
);
--> statement-breakpoint
ALTER TABLE "site_config_revisions" ADD CONSTRAINT "site_config_revisions_site_id_sites_id_fk" FOREIGN KEY ("site_id") REFERENCES "public"."sites"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "site_config_rev_uq" ON "site_config_revisions" USING btree ("site_id","version");