-
Notifications
You must be signed in to change notification settings - Fork 0
/
Social-Media-MySQL.prisma
192 lines (172 loc) · 4.36 KB
/
Social-Media-MySQL.prisma
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model Posts {
id Int @id @default(autoincrement())
image String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String? @db.VarChar(255)
isAdult Boolean @default(false)
content String?
published Boolean @default(false)
author Users @relation(fields: [authorId], references: [id])
authorId Int
tags Tags[]
time String?
likes Likes[]
comments Comments[]
}
model Likes {
id Int @id @default(autoincrement())
userId Int
postId Int?
likedAt DateTime @default(now())
user Users @relation(fields: [userId], references: [id])
post Posts? @relation(fields: [postId], references: [id])
time String?
comments Comments? @relation(fields: [commentsId], references: [id])
commentsId Int?
replies Replies? @relation(fields: [repliesId], references: [id])
repliesId Int?
tags Tags? @relation(fields: [tagsId], references: [id])
tagsId Int?
}
model Comments {
id Int @id @default(autoincrement())
userId Int
postId Int
content String
timestamp DateTime @default(now())
Likes Likes[]
user Users @relation(fields: [userId], references: [id])
post Posts @relation(fields: [postId], references: [id])
time String?
replies Replies[]
}
model Replies {
id Int @id @default(autoincrement())
userId Int
commentId Int
content String
timestamp DateTime @default(now())
likes Likes[]
user Users @relation(fields: [userId], references: [id])
comment Comments @relation(fields: [commentId], references: [id])
time String?
}
model Profile {
id Int @id @default(autoincrement())
bio String?
age Int?
education String?
address String?
contact String?
gender Gender?
country String?
isAdult Boolean @default(false)
user Users @relation(fields: [userId], references: [id])
userId Int @unique
}
model Users {
id Int @id @default(autoincrement())
avatar String?
name String
username String @unique
email String? @unique
password String?
server Server @default(ASIA)
verified Boolean @default(false)
banned Boolean @default(false)
role Role @default(USER)
plan Plan @default(BASIC)
followers Follows[] @relation("following")
following Follows[] @relation("follower")
blocked Blocked[] @relation("blocked")
posts Posts[]
likes Likes[]
comments Comments[]
profile Profile?
time String?
replies Replies[]
mails Mails[]
rooms Rooms? @relation(fields: [roomsId], references: [id])
roomsId Int?
messages Messages[]
}
model Follows {
follower Users @relation("follower", fields: [followerId], references: [id])
followerId Int
following Users @relation("following", fields: [followingId], references: [id])
followingId Int
@@id([followerId, followingId])
}
model Rooms {
id Int @id @default(autoincrement())
members Users[]
messages Messages[]
createdAt DateTime @default(now())
time String?
}
model Messages {
id Int @id @default(autoincrement())
image String?
text String
author Users @relation(fields: [authorId], references: [id])
authorId Int
room Rooms? @relation(fields: [roomId], references: [id])
roomId Int?
sentAt DateTime @default(now())
time String?
}
model Blocked {
blocked Users @relation("blocked", fields: [blockedUserId], references: [id])
blockedUserId Int
@@id([blockedUserId])
}
model Tags {
id Int @id @default(autoincrement())
name String @unique
posts Posts[]
likes Likes[]
}
enum Plan {
BASIC
PRO
PREMIUM
}
enum Role {
USER
ADMIN
}
enum Gender {
MALE
FEMALE
}
enum Server {
ASIA
NAMERICA
SAMERICA
AUSTRALIA
EUROPE
AFRICA
}
model Mails {
id Int @id @default(autoincrement())
image String?
subject String
content String
type MailType?
time String?
author Users @relation(fields: [authorId], references: [id])
authorId Int
}
enum MailType {
REPORT
CONTACT
FEEDBACK
}