sdy

update prisma schema

...@@ -20,6 +20,8 @@ model User { ...@@ -20,6 +20,8 @@ model User {
20 bio String? @default("") 20 bio String? @default("")
21 rooms Room[] @relation(references: [id]) 21 rooms Room[] @relation(references: [id])
22 messages Message[] 22 messages Message[]
23 + sender Message @relation("Sender")
24 + receiver Message[] @relation("Receiver")
23 createdAt DateTime? @default(now()) 25 createdAt DateTime? @default(now())
24 } 26 }
25 27
...@@ -38,6 +40,12 @@ model Category { ...@@ -38,6 +40,12 @@ model Category {
38 model Message { 40 model Message {
39 id Int @default(autoincrement()) @id 41 id Int @default(autoincrement()) @id
40 text String? @default("") 42 text String? @default("")
41 - sender User @relation(fields: [senderId], references: [id]) 43 + from User @relation("Sender", fields: [fromId], references: [id])
42 - senderId Int 44 + fromId Int
45 + to User @relation("Receiver", fields: [toId], references: [id])
46 + toId Int
47 + room Room @relation(fields: [roomId], references: [id])
48 + roomId Int
49 + createdAt DateTime?
50 + userId Int?
43 } 51 }
...\ No newline at end of file ...\ No newline at end of file
......