add level 4

This commit is contained in:
Матвей
2026-10-26 10:29:54 +03:00
parent df15ab0967
commit ff33b8a7c2
9 changed files with 265 additions and 40 deletions
+17
View File
@@ -0,0 +1,17 @@
ALTER TABLE attachment_jobs
ADD COLUMN next_attempt_at timestamptz NOT NULL DEFAULT now(),
ADD COLUMN lease_until timestamptz,
ADD COLUMN replayed_at timestamptz;
CREATE INDEX attachment_jobs_due_idx ON attachment_jobs(status, next_attempt_at);
CREATE INDEX attachment_jobs_lease_idx ON attachment_jobs(status, lease_until);
CREATE TABLE attachment_outbox (
id uuid PRIMARY KEY,
job_id uuid NOT NULL REFERENCES attachment_jobs(job_id) ON DELETE CASCADE,
payload jsonb NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
published_at timestamptz,
attempts integer NOT NULL DEFAULT 0,
UNIQUE (job_id, published_at)
);
CREATE INDEX attachment_outbox_pending_idx ON attachment_outbox(created_at) WHERE published_at IS NULL;