sdy

update schema.prisma

...@@ -9,46 +9,44 @@ datasource db { ...@@ -9,46 +9,44 @@ 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 - username String 14 + username String
15 - email String @unique 15 + email String @unique
16 - password String 16 + password 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 + groups Group[] @relation(references: [id])
22 - messages Message[] 22 + messages Message[]
23 - sender User[] @relation("SenderReceiver", references: [id]) 23 + directMessages DirectMessage[]
24 - receiver User[] @relation("SenderReceiver", references: [id]) 24 + createdAt DateTime? @default(now())
25 - createdAt DateTime? @default(now())
26 } 25 }
27 26
28 -model Room { 27 +model Group {
29 - id Int @default(autoincrement()) @id 28 + id Int @default(autoincrement()) @id
30 - name String @unique 29 + name String @unique
31 - participants User[] @relation(references: [id]) 30 + participants User[]
32 - categories Category[]
33 messages Message[] 31 messages Message[]
32 + files String? @default("")
33 + createdAt DateTime? @default(now())
34 } 34 }
35 35
36 -model Category { 36 +model DirectMessage {
37 - id Int @default(autoincrement()) @id 37 + id Int @default(autoincrement()) @id
38 - name String @default("") @unique 38 + text String @default("")
39 - room Room @relation(fields: [roomId], references: [id]) 39 + sender User @relation(fields: [senderId], references: [id])
40 - roomId Int 40 + senderId Int
41 - messages Message[] 41 + createdAt DateTime? @default(now())
42 } 42 }
43 43
44 model Message { 44 model Message {
45 - id Int @default(autoincrement()) @id 45 + id Int @default(autoincrement()) @id
46 - text String @default("") 46 + text String @default("")
47 - sender User @relation(fields: [senderId], references: [id]) 47 + sender User @relation(fields: [senderId], references: [id])
48 - senderId Int 48 + senderId Int
49 - room Room @relation(fields: [roomId], references: [id]) 49 + group Group @relation(fields: [groupId], references: [id])
50 - roomId Int 50 + groupId Int
51 - createdAt DateTime? @default(now()) 51 + createdAt DateTime? @default(now())
52 - category Category? @relation(fields: [categoryId], references: [id])
53 - categoryId Int?
54 } 52 }
......