ЛР 6: реализация мессенджера и сценарии проверки

This commit is contained in:
Russiankryt
2026-12-03 17:20:52 +03:00
parent 470d9d6f1e
commit 503126f29c
38 changed files with 2622 additions and 37 deletions
+19
View File
@@ -0,0 +1,19 @@
ALTER TABLE attachments DROP CONSTRAINT attachments_status_check;
ALTER TABLE attachments ADD CHECK (status IN ('queued', 'processing', 'ready', 'failed'));
ALTER TABLE attachments ADD COLUMN pipeline_version integer NOT NULL DEFAULT 0;
CREATE TABLE image_jobs (
id uuid PRIMARY KEY,
attachment_id uuid NOT NULL REFERENCES attachments(id),
pipeline_version integer NOT NULL CHECK (pipeline_version > 0),
attempt integer NOT NULL DEFAULT 0,
state text NOT NULL DEFAULT 'waiting' CHECK (state IN ('waiting', 'leased', 'done', 'failed')),
next_run timestamptz NOT NULL DEFAULT clock_timestamp(),
leased_until timestamptz,
published_at timestamptz,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
trace_context jsonb NOT NULL DEFAULT '{}'::jsonb,
UNIQUE (attachment_id, pipeline_version)
);
CREATE INDEX image_jobs_pending ON image_jobs(next_run, id) WHERE state IN ('waiting', 'leased');