forked from mtusi2026/mtusi2026lab5
Implement durable image queue with outbox worker and recovery checks
This commit is contained in:
@@ -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()
|
||||
);
|
||||
Reference in New Issue
Block a user