schema.prisma
1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-1.1.x", "darwin"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model User {
id Int @default(autoincrement()) @id
avatarUrl String? @default("")
username String
email String @unique
password String
phoneNum String? @default("") @unique
emailSecret String? @default("")
phoneSecret String? @default("")
bio String? @default("")
participatedGroup Group[] @relation("group-participants", references: [id])
createdGroup Group[] @relation("group-creator")
messages Message[]
directMessages DirectMessage[]
createdAt DateTime? @default(now())
}
model Group {
id Int @default(autoincrement()) @id
name String @unique
participants User[] @relation("group-participants")
messages Message[]
creator User @relation("group-creator", fields: [creatorId])
creatorId Int
files String? @default("")
createdAt DateTime? @default(now())
}
model DirectMessage {
id Int @default(autoincrement()) @id
text String @default("")
sender User @relation(fields: [senderId], references: [id])
senderId Int
createdAt DateTime? @default(now())
}
model Message {
id Int @default(autoincrement()) @id
text String @default("")
sender User @relation(fields: [senderId], references: [id])
senderId Int
group Group @relation(fields: [groupId], references: [id])
groupId Int
createdAt DateTime? @default(now())
}