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;