forked from mtusi2026/mtusi2026lab5
feat(worker): prepare replay queries and audit schema
This commit is contained in:
@@ -6,6 +6,7 @@ ALTER TABLE attachments
|
||||
ADD COLUMN job_id uuid UNIQUE,
|
||||
ADD COLUMN pipeline_version int NOT NULL DEFAULT 1 CHECK (pipeline_version > 0),
|
||||
ADD COLUMN attempts int NOT NULL DEFAULT 0 CHECK (attempts >= 0),
|
||||
ADD COLUMN retry_base int NOT NULL DEFAULT 0 CHECK (retry_base >= 0 AND retry_base <= attempts),
|
||||
ADD COLUMN width int CHECK (width > 0),
|
||||
ADD COLUMN height int CHECK (height > 0),
|
||||
ADD COLUMN lease_until timestamptz;
|
||||
@@ -39,7 +40,18 @@ CREATE TABLE outbox (
|
||||
|
||||
CREATE INDEX idx_outbox_pending ON outbox (available_at, id) WHERE published_at IS NULL;
|
||||
|
||||
CREATE TABLE attachment_replays (
|
||||
attachment_id uuid NOT NULL REFERENCES attachments (id) ON DELETE CASCADE,
|
||||
attempt int NOT NULL CHECK (attempt > 0),
|
||||
previous_error_code text,
|
||||
operator text NOT NULL,
|
||||
reason text NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (attachment_id, attempt)
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE attachment_replays;
|
||||
DROP TABLE outbox;
|
||||
DROP TABLE attachment_variants;
|
||||
DROP TYPE attachment_variant_name;
|
||||
@@ -48,6 +60,7 @@ ALTER TABLE attachments
|
||||
DROP COLUMN height,
|
||||
DROP COLUMN width,
|
||||
DROP COLUMN lease_until,
|
||||
DROP COLUMN retry_base,
|
||||
DROP COLUMN attempts,
|
||||
DROP COLUMN pipeline_version,
|
||||
DROP COLUMN job_id,
|
||||
|
||||
Reference in New Issue
Block a user