generator client { provider = "prisma-client-js" } datasource db { provider = "mysql" url = env("DATABASE_URL") } model User { id String @id @default(cuid()) username String? @unique role Role @default(STUDENT) createdAt DateTime @default(now()) providerId String @unique Class Class[] SentMessages UserMessage[] @relation("SentMessages") ReceivedMessages UserMessage[] @relation("ReceivedMessages") RoomSurveyAnswerUser RoomSurveyAnswerUser[] } model UserMessage { id Int @id @default(autoincrement()) content String sender User @relation(fields: [sender_user_Id], references: [id], name: "SentMessages") sender_user_Id String receiver User @relation(fields: [receiver_user_Id], references: [id], name: "ReceivedMessages") receiver_user_Id String createdAt DateTime @default(now()) } model Class { id String @id @default(cuid()) name String createdAt DateTime @default(now()) ClassRoom Room[] Students User[] } model Room { id String @id @default(cuid()) name String Class Class[] Messages RoomMessage[] Documents RoomDocument[] Surveys RoomSurvey[] } model RoomMessage { id Int @id @default(autoincrement()) content String Room Room @relation(fields: [roomId], references: [id]) roomId String } model RoomDocument { id Int @id @default(autoincrement()) content String Room Room @relation(fields: [roomId], references: [id]) roomId String } model RoomSurvey { id Int @id @default(autoincrement()) content String Room Room @relation(fields: [roomId], references: [id]) roomId String createdAt DateTime @default(now()) endAt DateTime? Answers RoomSurveyAnswer[] } model RoomSurveyAnswer { id Int @id @default(autoincrement()) content String Survey RoomSurvey @relation(fields: [surveyId], references: [id]) surveyId Int isRight Boolean Users RoomSurveyAnswerUser[] } model RoomSurveyAnswerUser { id Int @id @default(autoincrement()) User User @relation(fields: [userId], references: [id]) userId String Answer RoomSurveyAnswer @relation(fields: [answerId], references: [id]) answerId Int } enum Role { STUDENT ADMIN }