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>
32 lines
1.1 KiB
SQL
32 lines
1.1 KiB
SQL
-- Drops AWARD_MASTER from the UserRole enum.
|
|
--
|
|
-- Any row still holding AWARD_MASTER is demoted to JURY_MEMBER (singular role)
|
|
-- or filtered out of the roles[] array (multi-role) before the enum swap, so
|
|
-- the type alteration is safe even if the prod migration was missed.
|
|
|
|
UPDATE "User" SET role = 'JURY_MEMBER' WHERE role = 'AWARD_MASTER';
|
|
UPDATE "User" SET roles = array_remove(roles, 'AWARD_MASTER') WHERE 'AWARD_MASTER' = ANY(roles);
|
|
|
|
CREATE TYPE "UserRole_new" AS ENUM (
|
|
'SUPER_ADMIN',
|
|
'PROGRAM_ADMIN',
|
|
'JURY_MEMBER',
|
|
'MENTOR',
|
|
'OBSERVER',
|
|
'APPLICANT',
|
|
'AUDIENCE'
|
|
);
|
|
|
|
ALTER TABLE "User" ALTER COLUMN role DROP DEFAULT;
|
|
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";
|