Очередь и обработка изображений

This commit is contained in:
Югай Артур Рустамович
2026-11-24 19:34:09 +03:00
parent 276dbdad8a
commit 616b5d4e4e
51 changed files with 5337 additions and 45 deletions
+27
View File
@@ -0,0 +1,27 @@
ALTER TABLE attachments ADD COLUMN status text NOT NULL DEFAULT 'ready'
CHECK (status IN ('queued','processing','ready','failed'));
ALTER TABLE attachments ADD COLUMN error_code text;
ALTER TABLE attachments ADD COLUMN staging_deleted boolean NOT NULL DEFAULT false;
CREATE TABLE attachment_jobs (
id uuid PRIMARY KEY,
attachment_id uuid NOT NULL UNIQUE REFERENCES attachments(id),
pipeline_version integer NOT NULL DEFAULT 1 CHECK (pipeline_version = 1),
staging_key text NOT NULL UNIQUE,
attempt integer NOT NULL DEFAULT 0,
next_attempt_at timestamptz NOT NULL DEFAULT clock_timestamp(),
published_at timestamptz,
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
CREATE TABLE attachment_variants (
attachment_id uuid NOT NULL REFERENCES attachments(id),
pipeline_version integer NOT NULL DEFAULT 1,
name text NOT NULL CHECK (name = 'thumbnail'),
content_type text NOT NULL,
width integer NOT NULL,
height integer NOT NULL,
size_bytes integer NOT NULL,
sha256 char(64) NOT NULL,
object_key text NOT NULL UNIQUE,
PRIMARY KEY (attachment_id,pipeline_version,name)
);