Files
codex-bot 5427df8ff3
waterfall-wiki CI and deployment / verify-and-deploy (push) Has been cancelled
Record the Studio schema migration atomically and support safe retries
2026-10-27 15:56:28 +08:00

14 lines
630 B
PL/PgSQL

BEGIN;
CREATE TABLE IF NOT EXISTS studio_designs (
id uuid PRIMARY KEY,
layout_id text NOT NULL CHECK (layout_id ~ '^ref-(0[1-9]|1[0-9]|2[0-7])$'),
name text NOT NULL CHECK (char_length(name) BETWEEN 1 AND 120),
parameters jsonb NOT NULL CHECK (jsonb_typeof(parameters)='object'),
revision integer NOT NULL DEFAULT 1 CHECK (revision > 0),
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS studio_designs_layout_created ON studio_designs(layout_id,created_at DESC,id DESC);
INSERT INTO schema_migrations(version) VALUES('009_studio_designs');
COMMIT;