Перенести и адаптировать базу лабораторной 5 для отдельного стенда 6

This commit is contained in:
2026-11-27 16:36:53 +03:00
parent 470d9d6f1e
commit 5c3c4a9d0d
49 changed files with 2366 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
ALTER TABLE attachments
ADD COLUMN target_pipeline_version integer NOT NULL DEFAULT 1 CHECK (target_pipeline_version >= 1),
ADD COLUMN published_pipeline_version integer CHECK (published_pipeline_version >= 1),
ADD CHECK (published_pipeline_version <= target_pipeline_version);
UPDATE attachments SET published_pipeline_version = 1 WHERE state = 'ready';
ALTER TABLE attachment_jobs
DROP CONSTRAINT attachment_jobs_attachment_id_key,
DROP CONSTRAINT attachment_jobs_staging_key_key,
DROP CONSTRAINT attachment_jobs_state_check,
ADD COLUMN pipeline_version integer NOT NULL DEFAULT 1 CHECK (pipeline_version >= 1),
ADD COLUMN settled_at timestamptz,
ADD CHECK (state IN ('queued', 'processing', 'ready', 'failed', 'superseded')),
ADD UNIQUE (attachment_id, pipeline_version);
CREATE INDEX attachment_jobs_staging ON attachment_jobs(staging_key);
ALTER TABLE attachment_variants ADD COLUMN pipeline_version integer NOT NULL DEFAULT 1;
ALTER TABLE attachment_variants DROP CONSTRAINT attachment_variants_pkey;
ALTER TABLE attachment_variants ADD PRIMARY KEY (attachment_id, pipeline_version, name);