refactor: Update Prisma schema to include createdAt field in User and RoomMessage models

This commit is contained in:
M1000fr 2024-12-02 14:38:01 +01:00
parent 3301b365f9
commit b07b6082e4

View File

@ -11,10 +11,12 @@ model User {
id String @id @default(cuid()) id String @id @default(cuid())
username String? username String?
role Role @default(STUDENT) role Role @default(STUDENT)
createdAt DateTime @default(now())
Class Class[] Class Class[]
SentMessages UserMessage[] @relation("SentMessages") SentMessages UserMessage[] @relation("SentMessages")
ReceivedMessages UserMessage[] @relation("ReceivedMessages") ReceivedMessages UserMessage[] @relation("ReceivedMessages")
RoomSurveyAnswerUser RoomSurveyAnswerUser[]
} }
model UserMessage { model UserMessage {
@ -26,22 +28,26 @@ model UserMessage {
receiver User @relation(fields: [receiver_user_Id], references: [id], name: "ReceivedMessages") receiver User @relation(fields: [receiver_user_Id], references: [id], name: "ReceivedMessages")
receiver_user_Id String receiver_user_Id String
createdAt DateTime @default(now())
} }
model Class { model Class {
id String @id @default(cuid()) id String @id @default(cuid())
name String name String
createdAt DateTime @default(now())
ClassRoom Room[] ClassRoom Room[]
students User[] Students User[]
} }
model Room { model Room {
id String @id @default(cuid()) id String @id @default(cuid())
name String name String
class Class[] Class Class[]
Messages RoomMessage[] Messages RoomMessage[]
Documents RoomDocument[] Documents RoomDocument[]
Surveys RoomSurvey[]
} }
model RoomMessage { model RoomMessage {
@ -58,6 +64,34 @@ model RoomDocument {
roomId String 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 { enum Role {
STUDENT STUDENT
ADMIN ADMIN