From 88b6e2f294b01ffd2880207bb88d066f70c3451b Mon Sep 17 00:00:00 2001 From: giovanni Date: Thu, 2 Apr 2026 11:40:38 +0700 Subject: [PATCH] adjust sql migration --- ...034456_adjust_daily_checklist_unique_for_rejected.down.sql | 4 ++++ ...02034456_adjust_daily_checklist_unique_for_rejected.up.sql | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/internal/database/migrations/20260402034456_adjust_daily_checklist_unique_for_rejected.down.sql b/internal/database/migrations/20260402034456_adjust_daily_checklist_unique_for_rejected.down.sql index 1994f220..2ef9aecd 100644 --- a/internal/database/migrations/20260402034456_adjust_daily_checklist_unique_for_rejected.down.sql +++ b/internal/database/migrations/20260402034456_adjust_daily_checklist_unique_for_rejected.down.sql @@ -1,5 +1,9 @@ +BEGIN; + DROP INDEX IF EXISTS idx_daily_checklists_unique_non_rejected; ALTER TABLE daily_checklists ADD CONSTRAINT daily_checklists_date_kandang_category_key UNIQUE (date, kandang_id, category); + +COMMIT; diff --git a/internal/database/migrations/20260402034456_adjust_daily_checklist_unique_for_rejected.up.sql b/internal/database/migrations/20260402034456_adjust_daily_checklist_unique_for_rejected.up.sql index 83ea4f41..753deaef 100644 --- a/internal/database/migrations/20260402034456_adjust_daily_checklist_unique_for_rejected.up.sql +++ b/internal/database/migrations/20260402034456_adjust_daily_checklist_unique_for_rejected.up.sql @@ -1,6 +1,10 @@ +BEGIN; + ALTER TABLE daily_checklists DROP CONSTRAINT IF EXISTS daily_checklists_date_kandang_category_key; CREATE UNIQUE INDEX IF NOT EXISTS idx_daily_checklists_unique_non_rejected ON daily_checklists (date, kandang_id, category) WHERE (status IS NULL OR status <> 'REJECTED'); + +COMMIT;