diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 7aa0ed2b..78363316 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,5 +1,4 @@ -// This is your Prisma schema file, -// learn more about it in the docs: https://pris.ly/d/prisma-schema +// Updated Prisma schema with additional features generator client { provider = "prisma-client-js" @@ -11,61 +10,69 @@ datasource db { shadowDatabaseUrl = env("SHADOW_DATABASE_URL") } +// Added enum for role to ensure predefined roles +enum UserRole { + ADMIN + TEACHER + STUDENT + NONE +} + model Classroom { - classroomId String @id @default(cuid()) - classroomName String - fccUserIds String[] - description String? - fccCertifications Int[] - classroomTeacherId String - User User @relation(fields: [classroomTeacherId], references: [id]) - createdAt DateTime @default(now()) -} + classroomId String @id @default(auto()) @map("_id") @test.Auto(1) + classroomName String + fccUserIds String[] + description String? + fccCertifications Int[] + classroomTeacherId String + User User @relation(fields: [classroomTeacherId], references: [id]) + createdAt DateTime @default(now()) +} model Account { - id String @id @default(cuid()) - userId String - type String - provider String - providerAccountId String - refresh_token String? @db.Text - access_token String? @db.Text - expires_at Int? - token_type String? - scope String? - id_token String? @db.Text - session_state String? + id String @id @default(auto()) @map("_id") @test.Auto(2) + userId String + type String + provider String + providerAccountId String + refresh_token String? @db.Text + access_token String? @db.Text + expires_at Int? + token_type String? + scope String? + id_token String? @db.Text + session_state String? refresh_token_expires_in Int? - user User @relation(fields: [userId], references: [id], onDelete: Cascade) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([provider, providerAccountId]) } model Session { - id String @id @default(cuid()) - sessionToken String @unique - userId String - expires DateTime - user User @relation(fields: [userId], references: [id], onDelete: Cascade) + id String @id @default(auto()) @map("_id") @test.Auto(3) + sessionToken String @unique + userId String + expires DateTime + user User @relation(fields: [userId], references: [id], onDelete: Cascade) } model User { - id String @id @default(cuid()) - name String? - email String? @unique - emailVerified DateTime? - image String? - role String @default("NONE") - Classroom Classroom[] - accounts Account[] - sessions Session[] + id String @id @default(auto()) @map("_id") @test.Auto(4) + name String? + email String? @unique + emailVerified DateTime? + image String? + role UserRole @default(NONE) + Classrooms Classroom[] + accounts Account[] + sessions Session[] } model VerificationToken { - identifier String - token String @unique - expires DateTime + identifier String + token String @unique + expires DateTime @@unique([identifier, token]) -} \ No newline at end of file +}