From d7e18f55257dd0269e684172d8baa0b2017eca39 Mon Sep 17 00:00:00 2001 From: Younes Date: Mon, 16 Dec 2024 20:13:15 +0100 Subject: [PATCH] chore: fix better auth migration --- .../migration.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/prisma/migrations/20241216140937_better_auth_migration/migration.sql b/packages/prisma/migrations/20241216140937_better_auth_migration/migration.sql index 9f5baa80..6e0d6dab 100644 --- a/packages/prisma/migrations/20241216140937_better_auth_migration/migration.sql +++ b/packages/prisma/migrations/20241216140937_better_auth_migration/migration.sql @@ -134,8 +134,22 @@ BEGIN ON DELETE CASCADE ON UPDATE CASCADE; END IF; + + -- First, check if we need to change the column type + IF EXISTS ( + SELECT 1 + FROM information_schema.columns + WHERE table_name = 'User' + AND column_name = 'role' + AND data_type != 'text' + ) THEN + -- Alter the column type to TEXT + ALTER TABLE "User" ALTER COLUMN "role" TYPE TEXT; + END IF; + END $$; + -- Safe role updates UPDATE "User" SET "role" = 'teacher'