forked from mtusi2026/mtusi2026lab5
17 lines
673 B
SQL
17 lines
673 B
SQL
ALTER TABLE attachment_outbox
|
|
DROP CONSTRAINT attachment_outbox_job_id_fkey;
|
|
|
|
CREATE TABLE attachment_pipeline_events (
|
|
id bigserial PRIMARY KEY,
|
|
attachment_id uuid NOT NULL REFERENCES attachments(id) ON DELETE CASCADE,
|
|
prior_job_id uuid NOT NULL,
|
|
job_id uuid NOT NULL,
|
|
prior_version integer NOT NULL CHECK (prior_version >= 1),
|
|
pipeline_version integer NOT NULL CHECK (pipeline_version >= 1),
|
|
action varchar(16) NOT NULL CHECK (action = 'replay'),
|
|
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
|
|
);
|
|
|
|
CREATE INDEX attachment_pipeline_events_attachment_created_idx
|
|
ON attachment_pipeline_events (attachment_id, created_at);
|