Skip to content

Commit

Permalink
Add supervisor role
Browse files Browse the repository at this point in the history
  • Loading branch information
MangoSwirl committed Jan 9, 2024
1 parent 1657469 commit fb7633a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
12 changes: 12 additions & 0 deletions prisma/migrations/20240109020355_add_supervisor_role/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Warnings:
- Made the column `role` on table `Person` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterEnum
ALTER TYPE "Role" ADD VALUE 'SUPERVISOR';

-- AlterTable
ALTER TABLE "Person" ALTER COLUMN "role" SET NOT NULL,
ALTER COLUMN "role" SET DEFAULT 'STUDENT';
9 changes: 5 additions & 4 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ model Person {
id String @id @default(cuid())
name String
email String
role Role
role Role @default(STUDENT)
permissions Permission[]
teamAffiliated Boolean @default(false)
labCertification LabCertification?
Expand All @@ -62,13 +62,14 @@ model Person {
enum Role {
STUDENT
MENTOR
SUPERVISOR
OTHER
}

model LabCertification {
personId String @id
person Person @relation(fields: [personId], references: [id], onDelete: Cascade)
safetyQuiz Boolean @default(false)
personId String @id
person Person @relation(fields: [personId], references: [id], onDelete: Cascade)
safetyQuiz Boolean @default(false)
labLayoutEmergencyPreparedness Boolean @default(false) @map("emergencyPreparedness")
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/util/person/role/localized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export const localizedRole = (role: RoleString) =>
({
STUDENT: 'Student',
MENTOR: 'Mentor',
SUPERVISOR: 'Supervisor',
OTHER: 'Other',
}[role] ?? role);
1 change: 1 addition & 0 deletions src/lib/util/person/role/prismaRoles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import { Role } from "@prisma/client";
export const prismaRoles: Record<string, Role> = {
"STUDENT": Role.STUDENT,
"MENTOR": Role.MENTOR,
"SUPERVISOR": Role.SUPERVISOR,
"OTHER": Role.OTHER,
};
1 change: 1 addition & 0 deletions src/lib/util/person/role/roles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const roles = [
"STUDENT",
"MENTOR",
"SUPERVISOR",
"OTHER",
]

Expand Down

0 comments on commit fb7633a

Please sign in to comment.