From 3fefee674b1b7fa455839e3ef5eb7cdd1af83293 Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Fri, 21 Mar 2025 11:14:24 +0800 Subject: [PATCH] chore(prisma): apply migration to remove TEACHER and STUDENT roles --- .../migration.sql | 16 ++++++++++++++++ prisma/seed.ts | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20250321031353_remove_teacher_student_roles/migration.sql diff --git a/prisma/migrations/20250321031353_remove_teacher_student_roles/migration.sql b/prisma/migrations/20250321031353_remove_teacher_student_roles/migration.sql new file mode 100644 index 0000000..f47ae02 --- /dev/null +++ b/prisma/migrations/20250321031353_remove_teacher_student_roles/migration.sql @@ -0,0 +1,16 @@ +/* + Warnings: + + - The values [TEACHER,STUDENT] on the enum `Role` will be removed. If these variants are still used in the database, this will fail. + +*/ +-- AlterEnum +BEGIN; +CREATE TYPE "Role_new" AS ENUM ('ADMIN', 'GUEST'); +ALTER TABLE "User" ALTER COLUMN "role" DROP DEFAULT; +ALTER TABLE "User" ALTER COLUMN "role" TYPE "Role_new" USING ("role"::text::"Role_new"); +ALTER TYPE "Role" RENAME TO "Role_old"; +ALTER TYPE "Role_new" RENAME TO "Role"; +DROP TYPE "Role_old"; +ALTER TABLE "User" ALTER COLUMN "role" SET DEFAULT 'GUEST'; +COMMIT; diff --git a/prisma/seed.ts b/prisma/seed.ts index ef02526..281e3ce 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -484,7 +484,7 @@ public: name: "fly6516", email: "fly6516@outlook.com", password: "$2b$10$SD1T/dYvKTArGdTmf8ERxuBKIONxY01/wSboRNaNsHnKZzDhps/0u", - role: "TEACHER", + role: "ADMIN", problems: { create: [ {