Files
creator-hub/internal/creator/migrations/018_collection_checkpoints.sql
T

23 lines
858 B
SQL

CREATE TABLE IF NOT EXISTS creator_collection_checkpoint (
id text PRIMARY KEY,
source_type text NOT NULL CHECK (source_type IN ('owned', 'competitor')),
source_id text NOT NULL,
collection_kind text NOT NULL CHECK (
collection_kind IN ('works', 'comments')
),
cursor text NOT NULL DEFAULT '',
window_start timestamptz NOT NULL,
window_end timestamptz NOT NULL,
status text NOT NULL DEFAULT 'idle' CHECK (
status IN ('idle', 'running', 'succeeded', 'failed', 'blocked')
),
lease_until timestamptz,
last_started_at timestamptz,
last_completed_at timestamptz,
last_error text NOT NULL DEFAULT '',
UNIQUE (source_type, source_id, collection_kind)
);
CREATE INDEX IF NOT EXISTS creator_collection_due_idx ON creator_collection_checkpoint (
status, lease_until, last_completed_at
);