Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Add indexes, drop redundant column
Browse files Browse the repository at this point in the history
  • Loading branch information
bretthoerner committed Dec 14, 2023
1 parent 98b9c4a commit eebcbba
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions migrations/20231129172339_job_queue_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ CREATE TABLE job_queue(
id BIGSERIAL PRIMARY KEY,
attempt INT NOT NULL DEFAULT 0,
attempted_at TIMESTAMPTZ DEFAULT NULL,
attempted_by TEXT[] DEFAULT ARRAY[]::TEXT[],
completed_at TIMESTAMPTZ DEFAULT NULL,
attempted_by TEXT [] DEFAULT ARRAY [] :: TEXT [],
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
errors jsonb[],
errors jsonb [],
max_attempts INT NOT NULL DEFAULT 1,
finished_at TIMESTAMPTZ DEFAULT NULL,
parameters JSONB,
queue TEXT NOT NULL DEFAULT 'default'::text,
queue TEXT NOT NULL DEFAULT 'default' :: text,
scheduled_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
status job_status NOT NULL DEFAULT 'available'::job_status,
status job_status NOT NULL DEFAULT 'available' :: job_status,
target TEXT NOT NULL
);

-- Needed for `dequeue` queries
CREATE INDEX idx_queue_scheduled_at ON job_queue(queue, status, scheduled_at);

-- Needed for UPDATE-ing incomplete jobs with a specific target (i.e. slow destinations)
CREATE INDEX idx_queue_target ON job_queue(queue, status, target);

0 comments on commit eebcbba

Please sign in to comment.