From 12b5a06fc4a7777c669b00616244744ab9c4122a Mon Sep 17 00:00:00 2001 From: Saurabh Nanda Date: Sun, 19 Nov 2023 13:25:15 +0000 Subject: [PATCH] bugfix in migration --- src/OddJobs/Migrations.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OddJobs/Migrations.hs b/src/OddJobs/Migrations.hs index 1ae7be0..ccab48b 100644 --- a/src/OddJobs/Migrations.hs +++ b/src/OddJobs/Migrations.hs @@ -33,7 +33,8 @@ createJobTableQuery = "CREATE TABLE IF NOT EXISTS ?" <> ", attempts int not null default 0" <> ", locked_at timestamp with time zone null" <> ", locked_by text null" <> - ", result jsonb, parent_job_id int references ?(id)" <> + ", result jsonb" <> + ", parent_job_id int references ?(id)" <> ", constraint incorrect_locking_info CHECK (" <> "(locked_at is null and locked_by is null and status <> 'locked') or " <> "(locked_at is not null and locked_by is not null and (status = 'locked' or status = 'cancelled')))" <> @@ -77,8 +78,8 @@ createJobTable conn tname = void $ do , tname , PGS.Identifier $ "idx_" <> tnameTxt <> "_run_at" , tname - , tname , PGS.Identifier $ "idx_" <> tnameTxt <> "_parent_job_id" + , tname ) _ <- PGS.execute conn createJobTableQuery args PGS.execute conn createNotificationTrigger