schema.prisma
1.39 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
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("")
email String @unique
password String
name String
phoneNum String @default("") @unique
emailSecret String? @default("")
phoneSecret String? @default("")
bio String? @default("")
rooms Room[] @relation(references: [id])
sendMessage Message[] @relation("Sender")
receiveMessage Message[] @relation("Receiver")
createdAt DateTime? @default(now())
}
model Room {
id Int @default(autoincrement()) @id
participants User[] @relation(references: [id])
categories Category[] @relation(references: [id])
}
model Category {
id Int @default(autoincrement()) @id
name String? @default("")
rooms Room[] @relation(references: [id])
}
model Message {
id Int @default(autoincrement()) @id
text String? @default("")
from User[] @relation("Sender", references: [id])
to User[] @relation("Receiver", references: [id])
room Room @relation(fields: [roomId], references: [id])
roomId Int
createdAt DateTime? @default(now())
}