sdy

update DB schema

......@@ -9,44 +9,47 @@ datasource db {
}
model User {
id Int @default(autoincrement()) @id
avatarUrl String? @default("")
email String @unique
password String
username String
phoneNum String @default("") @unique
emailSecret String? @default("")
phoneSecret String? @default("")
bio String? @default("")
rooms Room[] @relation(references: [id])
sendMessage Message[] @relation("Sender")
receiveMessage Message[] @relation("Receiver")
createdAt DateTime? @default(now())
id Int @default(autoincrement()) @id
avatarUrl String? @default("")
email String @unique
password String
username String
phoneNum String @default("") @unique
emailSecret String? @default("")
phoneSecret String? @default("")
bio String? @default("")
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])
id Int @default(autoincrement()) @id
name String? @default("")
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?
room Room @relation(fields: [roomId], references: [id])
roomId Int
createdAt DateTime? @default(now())
id Int @default(autoincrement()) @id
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
......