Выполнение лабораторной работы номер 7

This commit is contained in:
2026-12-04 18:15:18 +03:00
parent 20afc2c790
commit 2fae615742
77 changed files with 5212 additions and 64 deletions
+20
View File
@@ -0,0 +1,20 @@
ALTER TABLE attachments DROP CONSTRAINT attachments_status_check;
ALTER TABLE attachments ADD CONSTRAINT attachments_status_check CHECK (status IN ('pending','queued','processing','ready','failed'));
ALTER TABLE attachments ADD COLUMN variants JSONB NOT NULL DEFAULT '[]';
ALTER TABLE attachments ADD COLUMN error_code TEXT;
ALTER TABLE attachments ADD COLUMN staging_cleaned BOOLEAN NOT NULL DEFAULT FALSE;
CREATE TABLE attachment_jobs (
id UUID PRIMARY KEY REFERENCES attachments(id),
attempt INTEGER NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
available_at TIMESTAMPTZ NOT NULL DEFAULT now(),
published_at TIMESTAMPTZ,
lease_until TIMESTAMPTZ,
trace_context JSONB NOT NULL DEFAULT '{}',
replay_count INTEGER NOT NULL DEFAULT 0
);
CREATE INDEX attachment_jobs_available_idx ON attachment_jobs(available_at);
CREATE TABLE attachment_replays (
job_id UUID NOT NULL REFERENCES attachment_jobs(id),
replayed_at TIMESTAMPTZ NOT NULL DEFAULT now()
);