sdy

update DB schema

......@@ -18,35 +18,38 @@ model User {
emailSecret String? @default("")
phoneSecret String? @default("")
bio String? @default("")
rooms Room[] @relation(references: [id])
sendMessage Message[] @relation("Sender")
receiveMessage Message[] @relation("Receiver")
room Room @relation(fields: [roomId], references: [id])
roomId Int
messages Message[]
sender User @relation("SenderReceiver", fields: [id], references: [id])
receiver User? @relation("SenderReceiver")
createdAt DateTime? @default(now())
}
model Room {
id Int @default(autoincrement()) @id
name String
participants User[] @relation(references: [id])
participants User[]
categories Category[]
Message Message[]
messages Message[]
}
model Category {
id Int @default(autoincrement()) @id
name String? @default("")
SubRoom Int
room Room @relation(fields: [SubRoom], references: [id])
room Room @relation(fields: [roomId], references: [id])
roomId Int
messages Message[]
}
model Message {
id Int @default(autoincrement()) @id
text String? @default("")
from User @relation("Sender", fields: [fromId], references: [id])
fromId Int
to User? @relation("Receiver", fields: [toId], references: [id])
toId Int?
text String @default("")
sender User @relation(fields: [senderId], references: [id])
senderId Int
room Room @relation(fields: [roomId], references: [id])
roomId Int
createdAt DateTime? @default(now())
category Category? @relation(fields: [categoryId], references: [id])
categoryId Int?
}
\ No newline at end of file
......