-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathschema.prisma
314 lines (275 loc) · 8.36 KB
/
schema.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
generator client {
provider = "prisma-client-js"
}
generator dbml {
provider = "prisma-dbml-generator"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model Cart {
id String @id
userId String
transactionState TransactionState @default(pending)
transactionId String? @unique
paidAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
user User @relation(fields: [userId], references: [id])
processingAt DateTime?
succeededAt DateTime?
cartItems CartItem[]
@@index([userId], map: "carts_userId_fkey")
@@map("carts")
}
model CartItem {
id String @id
itemId String
quantity Int
price Int
reducedPrice Int?
forcePaid Boolean @default(false)
forUserId String
cartId String
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
cart Cart @relation(fields: [cartId], references: [id], onDelete: Cascade)
forUser User @relation(fields: [forUserId], references: [id])
item Item @relation(fields: [itemId], references: [id])
@@index([cartId], map: "cartitems_cartId_fkey")
@@index([forUserId], map: "cartitems_forUserId_fkey")
@@index([itemId], map: "cartitems_itemId_fkey")
@@map("cartitems")
}
model Item {
id String @id
name String
category ItemCategory
attribute String?
price Int
reducedPrice Int?
infos String? @db.VarChar(300)
image Boolean @default(false)
stock Int?
availableFrom DateTime?
availableUntil DateTime?
display Boolean @default(true)
position Int @default(0)
cartItems CartItem[]
@@map("items")
}
model Setting {
id String @id
value Boolean
@@map("settings")
}
model Team {
id String @id
name String
tournamentId String
captainId String @unique
lockedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
discordRoleId String?
discordTextChannelId String?
discordVoiceChannelId String?
pokemonPlayerId String?
captain User @relation(fields: [captainId], references: [id])
tournament Tournament @relation(fields: [tournamentId], references: [id])
askingUsers User[] @relation("teamAskingUsers")
users User[] @relation("teamUsers")
enteredQueueAt DateTime?
@@unique([name, tournamentId])
@@index([id])
@@index([tournamentId], map: "teams_tournamentId_fkey")
@@map("teams")
}
model Tournament {
id String @id
name String @unique
maxPlayers Int
playersPerTeam Int @default(1)
coachesPerTeam Int @default(0)
cashprize Int @default(0)
cashprizeDetails String?
displayCashprize Boolean @default(false)
format String?
infos String?
casters Caster[]
displayCasters Boolean @default(false)
display Boolean @default(false)
discordRoleId String?
discordRespoRoleId String?
discordTextCategoryId String?
discordVocalCategoryId String?
position Int @default(0)
teams Team[]
@@map("tournaments")
}
model Caster {
id String @id
name String
tournamentId String
tournament Tournament @relation(fields: [tournamentId], references: [id], onDelete: Cascade)
@@index([tournamentId], map: "casters_tournamentId_fkey")
@@map("casters")
}
model Partner {
id String @id
name String @unique
link String
description String @db.Text
display Boolean
position Int @default(0)
@@map("partners")
}
model Log {
id String @id
userId String
method String
path String
body Json?
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
@@map("logs")
}
model User {
id String @id
username String? @unique
firstname String
lastname String
email String? @unique
password String?
type UserType?
age UserAge
discordId String? @unique
permissions String?
registerToken String? @unique
resetToken String? @unique
place String? @unique
customMessage String?
scannedAt DateTime?
attendantId String? @unique
teamId String?
askingTeamId String?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
ticketMailSent Boolean @default(false)
askingTeam Team? @relation("teamAskingUsers", fields: [askingTeamId], references: [id])
attendant User? @relation("attendantUser", fields: [attendantId], references: [id])
team Team? @relation("teamUsers", fields: [teamId], references: [id])
cartItems CartItem[]
carts Cart[]
logs Log[]
captainTeam Team?
repoItems RepoItem[] @relation("repoItemUser")
repoLogs RepoLog[] @relation("repoLogUser")
attended User? @relation("attendantUser")
orga Orga? @relation("userOrga")
@@index([id])
@@index([askingTeamId], map: "users_askingTeamId_fkey")
@@index([teamId], map: "users_teamId_fkey")
@@map("users")
}
model Orga {
userId String @id
photoFilename String?
displayName Boolean @default(false)
displayUsername Boolean @default(true)
displayPhoto Boolean @default(false)
mainCommissionId String?
roles OrgaRole[] @relation("orgaRoleOrga")
user User @relation("userOrga", fields: [userId], references: [id])
mainCommission Commission? @relation("orgaCommission", fields: [mainCommissionId], references: [id])
// TODO : uncomment that for next year, for 2023 it's too late
// @@map("orgas")
@@index([mainCommissionId])
}
model RepoItem {
id String @id
type RepoItemType
forUserId String
zone String
pickedUp Boolean @default(false)
user User @relation("repoItemUser", fields: [forUserId], references: [id])
repoLogs RepoLog[] @relation("repoLogItem")
@@index([id])
@@index([forUserId])
@@map("repoItem")
}
model RepoLog {
id String @id
itemId String
action RepoLogAction
timestamp DateTime @default(now())
forUserId String
item RepoItem @relation("repoLogItem", fields: [itemId], references: [id])
user User @relation("repoLogUser", fields: [forUserId], references: [id])
@@index([id])
@@index([forUserId])
@@map("repoLog")
}
model OrgaRole {
userId String
commissionId String
commissionRole RoleInCommission
user Orga @relation("orgaRoleOrga", fields: [userId], references: [userId])
commission Commission @relation("orgaRoleCommission", fields: [commissionId], references: [id])
@@id([userId, commissionId])
@@index([userId])
@@index([commissionId])
@@map("orgaRole")
}
model Commission {
id String @id
name String
nameOnBadge String @default("")
position Int
color String
masterCommissionId String?
masterCommission Commission? @relation("masterCommission", fields: [masterCommissionId], references: [id])
subCommissions Commission[] @relation("masterCommission")
orgas OrgaRole[] @relation("orgaRoleCommission")
orgaWhereMain Orga[] @relation("orgaCommission")
@@index([masterCommissionId])
@@map("commission")
}
enum TransactionState {
pending
processing
paid
canceled
expired
refunded
}
enum ItemCategory {
ticket
supplement
rent
}
enum UserType {
player
coach
spectator
attendant
}
enum UserAge {
adult
child
}
enum RoleInCommission {
respo
member
}
enum RepoItemType {
computer
monitor
peripheral
}
enum RepoLogAction {
added
removed
}