24 lines
1.0 KiB
SQL
24 lines
1.0 KiB
SQL
-- Apply independently to each project's business database.
|
|
CREATE SCHEMA IF NOT EXISTS workbench;
|
|
CREATE TABLE IF NOT EXISTS workbench.calculation_jobs (
|
|
job_id uuid PRIMARY KEY,
|
|
project_id uuid NOT NULL,
|
|
owner_user_id uuid NOT NULL,
|
|
request_key text NOT NULL,
|
|
tool text NOT NULL,
|
|
parameters jsonb NOT NULL,
|
|
binding jsonb NOT NULL,
|
|
timeout_seconds integer NOT NULL CHECK (timeout_seconds BETWEEN 1 AND 86400),
|
|
status text NOT NULL DEFAULT 'queued' CHECK (status IN
|
|
('queued','running','cancel_requested','succeeded','failed','cancelled','timed_out','interrupted')),
|
|
result jsonb,
|
|
error jsonb,
|
|
lease_generation bigint NOT NULL DEFAULT 0,
|
|
lease_owner text,
|
|
lease_expires_at timestamptz,
|
|
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
|
updated_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
|
UNIQUE(project_id,owner_user_id,request_key)
|
|
);
|
|
CREATE INDEX IF NOT EXISTS calculation_jobs_queue ON workbench.calculation_jobs(project_id,status,created_at);
|