Files
archie/internal/platform/pg/migrations/00058_events_dispatch_outcome.sql
T
sam 8c267b6edd feat: record skipped dispatches and approver ids
- store trigger dispatches as started or skipped, with a JSON reason surfaced in the API and UI
- persist the answering account's identity id beside its display name for approvals and judgements
- save connector acceptances and their declarations in one transaction so a refused change stores nothing
2026-11-22 23:24:30 +11:00

18 lines
755 B
SQL

-- +goose Up
-- A dispatch records the outcome of a trigger for an event: a started run or a
-- skip. A skip's reason is a JSON document with a code and display details,
-- such as the mapping fields that failed.
ALTER TABLE events.dispatches
ALTER COLUMN run_id DROP NOT NULL,
ADD COLUMN outcome text NOT NULL DEFAULT 'started' CHECK (outcome IN ('started', 'skipped')),
ADD COLUMN reason jsonb,
ADD CONSTRAINT dispatches_run_matches_outcome CHECK ((outcome = 'started') = (run_id IS NOT NULL));
-- +goose Down
DELETE FROM events.dispatches WHERE outcome = 'skipped';
ALTER TABLE events.dispatches
DROP CONSTRAINT dispatches_run_matches_outcome,
DROP COLUMN reason,
DROP COLUMN outcome,
ALTER COLUMN run_id SET NOT NULL;