Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constraint to prevent jobs in todo state with abort_requested #1256

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));
3 changes: 2 additions & 1 deletion procrastinate/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Loading