[2.12] ingest.job #29

Closed
opened 2026-06-13 23:54:32 +02:00 by dernbu · 0 comments
Owner

Parent

#2

Schema

CREATE TABLE ingest.job (
  id             bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  source         text   NOT NULL CHECK (source IN (lawnet, elitigation)),
  job_type       text   NOT NULL CHECK (job_type IN (discover, fetch_document, fetch_pdf, build_derived_content)),
  source_key     text   NOT NULL,
  status         text   NOT NULL DEFAULT queued CHECK (status IN (queued, leased, succeeded, dead)),
  priority       integer NOT NULL DEFAULT 0,
  available_at   timestamptz NOT NULL DEFAULT now(),
  leased_until   timestamptz NULL,
  leased_by      text   NULL,
  attempt_count  integer NOT NULL DEFAULT 0,
  max_attempts   integer NOT NULL DEFAULT 5,
  last_error     text   NULL,
  created_at     timestamptz NOT NULL DEFAULT now(),
  updated_at     timestamptz NOT NULL DEFAULT now(),
  completed_at   timestamptz NULL,
  UNIQUE (source, job_type, source_key)
);

Done when

  • All CHECK constraints reject invalid values
  • Composite UNIQUE enforced
  • available_at index for worker SKIP LOCKED queries
## Parent #2 ## Schema ```sql CREATE TABLE ingest.job ( id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, source text NOT NULL CHECK (source IN (lawnet, elitigation)), job_type text NOT NULL CHECK (job_type IN (discover, fetch_document, fetch_pdf, build_derived_content)), source_key text NOT NULL, status text NOT NULL DEFAULT queued CHECK (status IN (queued, leased, succeeded, dead)), priority integer NOT NULL DEFAULT 0, available_at timestamptz NOT NULL DEFAULT now(), leased_until timestamptz NULL, leased_by text NULL, attempt_count integer NOT NULL DEFAULT 0, max_attempts integer NOT NULL DEFAULT 5, last_error text NULL, created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now(), completed_at timestamptz NULL, UNIQUE (source, job_type, source_key) ); ``` ## Done when - All CHECK constraints reject invalid values - Composite UNIQUE enforced - `available_at` index for worker SKIP LOCKED queries
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dernbu/lawnet-scraper#29
No description provided.