Skip to content

Commit

Permalink
chore: fix better auth migration
Browse files Browse the repository at this point in the history
  • Loading branch information
younes200 committed Dec 16, 2024
1 parent c757bf2 commit d7e18f5
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit d7e18f5

Please sign in to comment.