Implement durable image queue with outbox worker and recovery checks

This commit is contained in:
2026-11-21 11:56:57 +03:00
parent 276dbdad8a
commit 7909110924
52 changed files with 2658 additions and 48 deletions
+17
View File
@@ -0,0 +1,17 @@
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 updated_at timestamptz NOT NULL DEFAULT clock_timestamp();
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 jobs (
id uuid PRIMARY KEY, attachment_id uuid UNIQUE NOT NULL REFERENCES attachments(id),
pipeline_version int NOT NULL DEFAULT 1 CHECK(pipeline_version=1),
attempts int NOT NULL DEFAULT 0, state text NOT NULL DEFAULT 'queued',
available_at timestamptz NOT NULL DEFAULT clock_timestamp(), lease_until timestamptz,
last_published timestamptz, created_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
CREATE TABLE replay_audit (
id bigserial PRIMARY KEY, job_id uuid NOT NULL REFERENCES jobs(id),
reason text NOT NULL, created_at timestamptz NOT NULL DEFAULT clock_timestamp()
);