sdy

update DB schema

...@@ -9,44 +9,47 @@ datasource db { ...@@ -9,44 +9,47 @@ datasource db {
9 } 9 }
10 10
11 model User { 11 model User {
12 - id Int @default(autoincrement()) @id 12 + id Int @default(autoincrement()) @id
13 - avatarUrl String? @default("") 13 + avatarUrl String? @default("")
14 - email String @unique 14 + email String @unique
15 - password String 15 + password String
16 - username String 16 + username String
17 - phoneNum String @default("") @unique 17 + phoneNum String @default("") @unique
18 - emailSecret String? @default("") 18 + emailSecret String? @default("")
19 - phoneSecret String? @default("") 19 + phoneSecret String? @default("")
20 - bio String? @default("") 20 + bio String? @default("")
21 - rooms Room[] @relation(references: [id]) 21 + room Room @relation(fields: [roomId], references: [id])
22 - sendMessage Message[] @relation("Sender") 22 + roomId Int
23 - receiveMessage Message[] @relation("Receiver") 23 + messages Message[]
24 - createdAt DateTime? @default(now()) 24 + sender User @relation("SenderReceiver", fields: [id], references: [id])
25 + receiver User? @relation("SenderReceiver")
26 + createdAt DateTime? @default(now())
25 } 27 }
26 28
27 model Room { 29 model Room {
28 id Int @default(autoincrement()) @id 30 id Int @default(autoincrement()) @id
29 name String 31 name String
30 - participants User[] @relation(references: [id]) 32 + participants User[]
31 categories Category[] 33 categories Category[]
32 - Message Message[] 34 + messages Message[]
33 } 35 }
34 36
35 model Category { 37 model Category {
36 - id Int @default(autoincrement()) @id 38 + id Int @default(autoincrement()) @id
37 - name String? @default("") 39 + name String? @default("")
38 - SubRoom Int 40 + room Room @relation(fields: [roomId], references: [id])
39 - room Room @relation(fields: [SubRoom], references: [id]) 41 + roomId Int
42 + messages Message[]
40 } 43 }
41 44
42 model Message { 45 model Message {
43 - id Int @default(autoincrement()) @id 46 + id Int @default(autoincrement()) @id
44 - text String? @default("") 47 + text String @default("")
45 - from User @relation("Sender", fields: [fromId], references: [id]) 48 + sender User @relation(fields: [senderId], references: [id])
46 - fromId Int 49 + senderId Int
47 - to User? @relation("Receiver", fields: [toId], references: [id]) 50 + room Room @relation(fields: [roomId], references: [id])
48 - toId Int? 51 + roomId Int
49 - room Room @relation(fields: [roomId], references: [id]) 52 + createdAt DateTime? @default(now())
50 - roomId Int 53 + category Category? @relation(fields: [categoryId], references: [id])
51 - createdAt DateTime? @default(now()) 54 + categoryId Int?
52 } 55 }
...\ No newline at end of file ...\ No newline at end of file
......