From a95ed473024c7320d40d38d33db7b3f7a4162221 Mon Sep 17 00:00:00 2001 From: M1000fr Date: Fri, 29 Nov 2024 00:26:37 +0100 Subject: [PATCH] refactor: Update Prisma schema to include UserMessage, Class, Room, and RoomMessage models --- prisma/schema.prisma | 61 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 5016a59..6b11836 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,21 +1,64 @@ -// This is your Prisma schema file, -// learn more about it in the docs: https://pris.ly/d/prisma-schema - -// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? -// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init - generator client { provider = "prisma-client-js" } datasource db { - provider = "sqlite" + provider = "mysql" url = env("DATABASE_URL") } model User { id String @id @default(cuid()) username String? - isAdmin Boolean @default(false) - password String? + role Role @default(STUDENT) + + Class Class[] + SentMessages UserMessage[] @relation("SentMessages") + ReceivedMessages UserMessage[] @relation("ReceivedMessages") +} + +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 +} + +model Class { + id String @id @default(cuid()) + name String + + ClassRoom Room[] + students User[] +} + +model Room { + id String @id @default(cuid()) + name String + class Class[] + Messages RoomMessage[] + Documents RoomDocument[] +} + +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 +} + +enum Role { + STUDENT + TEACHER }