refactor: Update Prisma schema to include UserMessage, Class, Room, and RoomMessage models

This commit is contained in:
M1000fr 2024-11-29 00:26:37 +01:00
parent 61bd5cd862
commit a95ed47302

View File

@ -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 { generator client {
provider = "prisma-client-js" provider = "prisma-client-js"
} }
datasource db { datasource db {
provider = "sqlite" provider = "mysql"
url = env("DATABASE_URL") url = env("DATABASE_URL")
} }
model User { model User {
id String @id @default(cuid()) id String @id @default(cuid())
username String? username String?
isAdmin Boolean @default(false) role Role @default(STUDENT)
password String?
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
} }