fix: make EvaluationForm constraint drop idempotent (IF EXISTS)
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled

The migration failed on deploy because the constraint
EvaluationForm_roundId_version_key did not exist in the target DB.
Using DROP CONSTRAINT IF EXISTS makes this safe for databases where
the constraint was already removed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt
2026-04-07 13:34:01 -04:00
parent 2864579e92
commit ef2186e89a

View File

@@ -1,8 +1,9 @@
-- AlterTable: add nullable category column to EvaluationForm
ALTER TABLE "EvaluationForm" ADD COLUMN "category" "CompetitionCategory";
-- Drop old unique constraint
ALTER TABLE "EvaluationForm" DROP CONSTRAINT "EvaluationForm_roundId_version_key";
-- Drop old unique constraint (IF EXISTS — may not exist on fresh databases where
-- the constraint was never created or was already removed by an earlier migration)
ALTER TABLE "EvaluationForm" DROP CONSTRAINT IF EXISTS "EvaluationForm_roundId_version_key";
-- Add new unique constraint including category
ALTER TABLE "EvaluationForm" ADD CONSTRAINT "EvaluationForm_roundId_version_category_key" UNIQUE ("roundId", "version", "category");