0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 18:26:15 +01:00
posthog/migrations/20231129172339_job_queue_table.sql
2023-12-01 14:23:03 +01:00

24 lines
693 B
SQL

CREATE TYPE job_status AS ENUM(
'available',
'completed',
'failed',
'running'
);
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,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
errors jsonb[],
max_attempts INT NOT NULL DEFAULT 1,
finished_at TIMESTAMPTZ DEFAULT NULL,
parameters JSONB,
queue TEXT NOT NULL DEFAULT 'default'::text,
scheduled_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
status job_status NOT NULL DEFAULT 'available'::job_status,
target TEXT NOT NULL
);