fix(migration): drop default on User.roles before altering type
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m3s

The 20260507151706_drop_award_master_role migration failed on prod with
'default for column "roles" cannot be cast automatically to type
"UserRole_new"[]'. Postgres won't auto-cast the @default([]) binding
through an enum-type swap. Same DROP DEFAULT / SET DEFAULT dance the
singular `role` column already had.

The original migration ran in a transaction that fully rolled back, so
the DB is unchanged — the fixed migration can be applied as-is once the
failed record is resolved (DELETE FROM _prisma_migrations WHERE
migration_name='20260507151706_drop_award_master_role').

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt
2026-05-07 16:31:08 +02:00
parent 7bc2b84d1d
commit cad5b3fc28

View File

@@ -22,8 +22,10 @@ ALTER TABLE "User"
ALTER COLUMN role TYPE "UserRole_new" USING role::text::"UserRole_new";
ALTER TABLE "User" ALTER COLUMN role SET DEFAULT 'APPLICANT';
ALTER TABLE "User" ALTER COLUMN roles DROP DEFAULT;
ALTER TABLE "User"
ALTER COLUMN roles TYPE "UserRole_new"[] USING roles::text[]::"UserRole_new"[];
ALTER TABLE "User" ALTER COLUMN roles SET DEFAULT '{}'::"UserRole_new"[];
DROP TYPE "UserRole";
ALTER TYPE "UserRole_new" RENAME TO "UserRole";