sdy

add creator column

...@@ -9,26 +9,29 @@ datasource db { ...@@ -9,26 +9,29 @@ 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 - groups Group[] @relation(references: [id]) 21 + participatedGroup Group[] @relation("group-participants", references: [id])
22 - messages Message[] 22 + createdGroup Group[] @relation("group-creator")
23 - directMessages DirectMessage[] 23 + messages Message[]
24 - createdAt DateTime? @default(now()) 24 + directMessages DirectMessage[]
25 + createdAt DateTime? @default(now())
25 } 26 }
26 27
27 model Group { 28 model Group {
28 id Int @default(autoincrement()) @id 29 id Int @default(autoincrement()) @id
29 name String @unique 30 name String @unique
30 - participants User[] 31 + participants User[] @relation("group-participants")
31 messages Message[] 32 messages Message[]
33 + creator User @relation("group-creator", fields: [creatorId])
34 + creatorId Int
32 files String? @default("") 35 files String? @default("")
33 createdAt DateTime? @default(now()) 36 createdAt DateTime? @default(now())
34 } 37 }
......