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

This commit is contained in:
2026-12-04 06:42:43 +03:00
parent 20afc2c790
commit cb7824c14c
37 changed files with 2292 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);