-- Roll back the cancelled state; any cancelled row is re-opened as failed -- first so the tighter CHECK applies. UPDATE test_publications SET processing_state = 'failed' WHERE processing_state = 'cancelled'; ALTER TABLE test_publications DROP CONSTRAINT IF EXISTS test_publications_processing_state_check; ALTER TABLE test_publications ADD CONSTRAINT test_publications_processing_state_check CHECK (processing_state IN ('planned', 'pending', 'processing', 'finalizing', 'completed', 'failed', 'stalled')); ALTER TABLE job_retry_operations DROP CONSTRAINT IF EXISTS job_retry_operations_outcome_check; ALTER TABLE job_retry_operations ADD CONSTRAINT job_retry_operations_outcome_check CHECK (outcome IN ('started', 'already_running', 'not_retryable'));