diff --git a/internal/platform/pg/migrations/00044_runs_endings.sql b/internal/platform/pg/migrations/00044_runs_endings.sql index 8cc596664..5a8059ef9 100644 --- a/internal/platform/pg/migrations/00044_runs_endings.sql +++ b/internal/platform/pg/migrations/00044_runs_endings.sql @@ -4,8 +4,8 @@ -- operator to retry from a step; a workflow.finish step can also leave it -- waiting for approval or declined. detail explains the ending. Parked and -- waiting runs are not terminal. -ALTER TABLE runs.runs DROP CONSTRAINT runs_runs_state_check; -ALTER TABLE runs.runs ADD CONSTRAINT runs_runs_state_check +ALTER TABLE runs.runs DROP CONSTRAINT runs_state_check; +ALTER TABLE runs.runs ADD CONSTRAINT runs_state_check CHECK (state IN ('queued', 'running', 'waiting', 'succeeded', 'failed', 'cancelled', 'parked', 'waiting_approval', 'declined')); ALTER TABLE runs.runs ADD COLUMN detail text; @@ -13,6 +13,6 @@ ALTER TABLE runs.runs ADD COLUMN detail text; -- +goose Down UPDATE runs.runs SET state = 'failed' WHERE state IN ('parked', 'waiting_approval', 'declined'); ALTER TABLE runs.runs DROP COLUMN detail; -ALTER TABLE runs.runs DROP CONSTRAINT runs_runs_state_check; -ALTER TABLE runs.runs ADD CONSTRAINT runs_runs_state_check +ALTER TABLE runs.runs DROP CONSTRAINT runs_state_check; +ALTER TABLE runs.runs ADD CONSTRAINT runs_state_check CHECK (state IN ('queued', 'running', 'waiting', 'succeeded', 'failed', 'cancelled'));