From b07b6082e4ec0d3d8df4fc32bc62867b93485006 Mon Sep 17 00:00:00 2001 From: M1000fr Date: Mon, 2 Dec 2024 14:38:01 +0100 Subject: [PATCH] refactor: Update Prisma schema to include createdAt field in User and RoomMessage models --- prisma/schema.prisma | 54 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 0065263..805a884 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -8,13 +8,15 @@ datasource db { } model User { - id String @id @default(cuid()) - username String? - role Role @default(STUDENT) + id String @id @default(cuid()) + username String? + role Role @default(STUDENT) + createdAt DateTime @default(now()) - Class Class[] - SentMessages UserMessage[] @relation("SentMessages") - ReceivedMessages UserMessage[] @relation("ReceivedMessages") + Class Class[] + SentMessages UserMessage[] @relation("SentMessages") + ReceivedMessages UserMessage[] @relation("ReceivedMessages") + RoomSurveyAnswerUser RoomSurveyAnswerUser[] } model UserMessage { @@ -26,22 +28,26 @@ model UserMessage { 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 + id String @id @default(cuid()) + name String + createdAt DateTime @default(now()) ClassRoom Room[] - students User[] + Students User[] } model Room { id String @id @default(cuid()) name String - class Class[] + Class Class[] Messages RoomMessage[] Documents RoomDocument[] + Surveys RoomSurvey[] } model RoomMessage { @@ -58,6 +64,34 @@ model RoomDocument { 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