Files
buzz/schema/tables/public/workflow_runs.sql
2026-11-19 17:51:45 -05:00

28 lines
1.2 KiB
SQL

-- ── Workflow runs ─────────────────────────────────────────────────────────────
CREATE TABLE workflow_runs (
community_id UUID NOT NULL,
id UUID NOT NULL DEFAULT gen_random_uuid(),
workflow_id UUID NOT NULL,
status run_status NOT NULL DEFAULT 'pending',
trigger_event_id BYTEA,
current_step INT NOT NULL DEFAULT 0,
execution_trace JSONB NOT NULL DEFAULT '[]',
trigger_context JSONB,
cause_source TEXT,
cause_pubkey BYTEA,
started_at TIMESTAMPTZ,
completed_at TIMESTAMPTZ,
error_message TEXT,
error_code TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
PRIMARY KEY (community_id, id),
CONSTRAINT workflow_runs_cause_source_check
CHECK (cause_source IN ('event', 'schedule', 'webhook', 'manual')),
CONSTRAINT workflow_runs_cause_pubkey_check
CHECK (length(cause_pubkey) = 32)
);
CREATE INDEX idx_workflow_runs_workflow ON workflow_runs (community_id, workflow_id);
CREATE INDEX idx_workflow_runs_status ON workflow_runs (community_id, status);