Server/prisma/schema.prisma

99 lines
2.5 KiB
Plaintext
Raw Normal View History

2024-11-25 12:17:49 +00:00
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
2024-11-25 12:17:49 +00:00
url = env("DATABASE_URL")
}
model User {
2024-12-06 00:00:32 +00:00
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
2024-12-06 00:00:32 +00:00
}