diff --git a/procrastinate/sql/migrations/03.00.00_50_post_cancel_notification.sql b/procrastinate/sql/migrations/03.00.00_50_post_cancel_notification.sql index 38e40da86..16e930051 100644 --- a/procrastinate/sql/migrations/03.00.00_50_post_cancel_notification.sql +++ b/procrastinate/sql/migrations/03.00.00_50_post_cancel_notification.sql @@ -200,3 +200,6 @@ CREATE TRIGGER procrastinate_trigger_abort_requested_events_v1 -- Rename remaining functions to use version suffix ALTER FUNCTION procrastinate_unlink_periodic_defers RENAME TO procrastinate_unlink_periodic_defers_v1; ALTER TRIGGER procrastinate_trigger_delete_jobs ON procrastinate_jobs RENAME TO procrastinate_trigger_delete_jobs_v1; + +-- New constraints +ALTER TABLE procrastinate_jobs ADD CONSTRAINT check_not_todo_abort_requested CHECK (NOT (status = 'todo' AND abort_requested = true)); diff --git a/procrastinate/sql/schema.sql b/procrastinate/sql/schema.sql index 67306e5ef..687f01404 100644 --- a/procrastinate/sql/schema.sql +++ b/procrastinate/sql/schema.sql @@ -39,7 +39,8 @@ CREATE TABLE procrastinate_jobs ( status procrastinate_job_status DEFAULT 'todo'::procrastinate_job_status NOT NULL, scheduled_at timestamp with time zone NULL, attempts integer DEFAULT 0 NOT NULL, - abort_requested boolean DEFAULT false NOT NULL + abort_requested boolean DEFAULT false NOT NULL, + CONSTRAINT check_not_todo_abort_requested CHECK (NOT (status = 'todo' AND abort_requested = true)) ); CREATE TABLE procrastinate_periodic_defers (