-- Ported from the SQLite migration of the same number. -- Jobs (BACKLOG G1): a request that takes minutes — a 3D model from a -- picture — answered with an id and asked after, rather than held open. -- The request is kept as it was sent, so whichever gateway holds the lease -- replays it through the same path a client's request takes; the result is -- a file in the files table, kept for the batch files' retention. CREATE TABLE jobs ( id TEXT PRIMARY KEY, owner TEXT NOT NULL, key_id TEXT NOT NULL, endpoint TEXT NOT NULL, model TEXT NOT NULL, input BYTEA NOT NULL, -- status is queued, running, completed, failed, cancelling, cancelled or -- expired. status TEXT NOT NULL, -- progress is what the engine said of the work so far, as JSON: queue -- position, percent, step. Empty until it says anything. progress TEXT NOT NULL DEFAULT '', -- prompt_id is the engine's own id for the work (ComfyUI's prompt_id), -- so a gateway that takes over a running job asks after the same work. prompt_id TEXT NOT NULL DEFAULT '', output_file_id TEXT NOT NULL DEFAULT '', content_type TEXT NOT NULL DEFAULT '', error TEXT NOT NULL DEFAULT '', created_at BIGINT NOT NULL, started_at BIGINT NOT NULL DEFAULT 0, finished_at BIGINT NOT NULL DEFAULT 0, expires_at BIGINT NOT NULL, lease_owner TEXT NOT NULL DEFAULT '', lease_until BIGINT NOT NULL DEFAULT 0 ); CREATE INDEX jobs_owner ON jobs (owner, created_at); CREATE INDEX jobs_status ON jobs (status, lease_until);