-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.prisma
478 lines (439 loc) · 20.8 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
// This file is automatically generated by Keystone, do not modify it manually.
// Modify your Keystone config when you want to change this.
datasource postgresql {
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
provider = "postgresql"
}
generator client {
provider = "prisma-client-js"
}
model User {
id String @id @default(cuid())
name String @default("")
nameLast String @default("")
authId String @unique @default("")
image String @default("")
phone String @default("")
email String @unique @default("")
password String @default("")
url String @default("")
isAdmin Boolean @default(false)
isActive Boolean @default(true)
stripeCustomerId String @default("")
buisnessHourOpen String? @default("09:00:00")
buisnessHourClosed String? @default("18:00:00")
createdAt DateTime? @default(now())
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
isVerified Boolean @default(false)
role Role? @relation("User_role", fields: [roleId], references: [id])
roleId String? @map("role")
posts Post[] @relation("Post_author")
pages Page[] @relation("Page_author")
servicesProvided Service[] @relation("Service_employees")
bookings Booking[] @relation("Booking_customer")
gigs Booking[] @relation("Booking_employees")
gig_requests Booking[] @relation("Booking_employee_requests")
eventsHost Event[] @relation("Event_hosts")
eventsCohost Event[] @relation("Event_cohosts")
availability Availability[] @relation("Availability_employee")
cart CartItem[] @relation("CartItem_user")
products Product[] @relation("Product_author")
addons Addon[] @relation("Addon_author")
rentals Rental[] @relation("Rental_customer")
subscriptionPlans SubscriptionPlan[] @relation("SubscriptionPlan_author")
subscriptions SubscriptionItem[] @relation("SubscriptionItem_user")
orders Order[] @relation("Order_user")
tickets Ticket[] @relation("Ticket_holder")
@@index([roleId])
}
model Role {
id String @id @default(cuid())
name String @unique @default("")
label String @unique @default("")
canManageProducts Boolean @default(false)
canReadProducts Boolean @default(false)
canManageAddons Boolean @default(false)
canManageBookings Boolean @default(false)
canManageAvailability Boolean @default(false)
canManageEvents Boolean @default(false)
canManageAnnouncements Boolean @default(false)
canManageTickets Boolean @default(false)
canSeeOtherUsers Boolean @default(false)
canManageUsers Boolean @default(false)
canManageRoles Boolean @default(false)
canManageCart Boolean @default(false)
canManageOrders Boolean @default(false)
canManageCategories Boolean @default(false)
canManageTags Boolean @default(false)
canManageLocations Boolean @default(false)
canManagePages Boolean @default(false)
canManagePosts Boolean @default(false)
canManageServices Boolean @default(false)
canManageSubscriptionPlans Boolean @default(false)
canManageSubscriptionItems Boolean @default(false)
canManageCoupons Boolean @default(false)
assignedTo User[] @relation("User_role")
}
model Announcement {
id String @id @default(cuid())
link String @default("")
start DateTime?
end DateTime?
color String @default("#00000094")
type String? @default("NORMAL")
content Json @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
}
model Booking {
id String @id @default(cuid())
start DateTime
end DateTime
service Service? @relation("Booking_service", fields: [serviceId], references: [id])
serviceId String? @map("service")
location Location? @relation("Booking_location", fields: [locationId], references: [id])
locationId String? @map("location")
addons Addon[] @relation("Addon_bookings")
price Int @default(0)
employees User[] @relation("Booking_employees")
employee_requests User[] @relation("Booking_employee_requests")
customer User? @relation("Booking_customer", fields: [customerId], references: [id])
customerId String? @map("customer")
email String @default("")
phone String @default("")
name String @default("")
status String? @default("LEAD")
details Json @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
notes String @default("")
secretNotes String @default("")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
google Json? @default("{\"id\":\"\",\"status\":\"\",\"kind\":\"\",\"htmlLink\":\"\"}")
@@index([serviceId])
@@index([locationId])
@@index([customerId])
}
model Service {
id String @id @default(cuid())
name String @unique @default("")
image String @default("")
excerpt String @default("")
description Json @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
price Int? @default(0)
durationInHours Decimal @default("6") @postgresql.Decimal(5, 2)
buisnessHourOpen String? @default("09:00:00")
buisnessHourClosed String? @default("18:00:00")
buisnessDays Json @default("[0,1,2,3,4,5,6]")
status String? @default("DRAFT")
addons Addon[] @relation("Addon_services")
employees User[] @relation("Service_employees")
locations Location[] @relation("Location_services")
bookings Booking[] @relation("Booking_service")
categories Category[] @relation("Category_services")
tags Tag[] @relation("Service_tags")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
}
model Location {
id String @id @default(cuid())
name String @unique @default("")
address String @unique @default("")
rooms Int? @default(1)
services Service[] @relation("Location_services")
bookings Booking[] @relation("Booking_location")
events Event[] @relation("Event_location")
categories Category[] @relation("Category_locations")
tags Tag[] @relation("Location_tags")
}
model Addon {
id String @id @default(cuid())
name String @unique @default("")
slug String @unique @default("")
image String @default("")
test String @default("")
excerpt String @default("")
price Int? @default(0)
stripeProductId String @default("")
status String? @default("AVAILABLE")
author User? @relation("Addon_author", fields: [authorId], references: [id])
authorId String? @map("author")
services Service[] @relation("Addon_services")
products Product[] @relation("Addon_products")
rentals Rental[] @relation("Addon_rentals")
subscriptionPlans SubscriptionPlan[] @relation("Addon_subscriptionPlans")
bookings Booking[] @relation("Addon_bookings")
subscriptionItems SubscriptionItem[] @relation("Addon_subscriptionItems")
categories Category[] @relation("Addon_categories")
tags Tag[] @relation("Addon_tags")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
@@index([authorId])
}
model Availability {
id String @id @default(cuid())
start DateTime
end DateTime
employee User? @relation("Availability_employee", fields: [employeeId], references: [id])
employeeId String? @map("employee")
type String? @default("VACATION")
status String? @default("APPROVED")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
@@index([employeeId])
}
model SubscriptionPlan {
id String @id @default(cuid())
image String @default("")
author User? @relation("SubscriptionPlan_author", fields: [authorId], references: [id])
authorId String? @map("author")
name String @default("")
slug String @unique @default("")
excerpt String @default("")
description Json @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
status String? @default("DRAFT")
price Int
stripeProductId String @default("")
stripePriceId String @default("")
billing_interval String? @default("month")
stockMax Int @default(0)
addons Addon[] @relation("Addon_subscriptionPlans")
coupons Coupon[] @relation("Coupon_subscriptionPlans")
items SubscriptionItem[] @relation("SubscriptionItem_subscriptionPlan")
tags Tag[] @relation("SubscriptionPlan_tags")
categories Category[] @relation("Category_subscriptions")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
@@index([authorId])
}
model SubscriptionItem {
id String @id @default(cuid())
custom_price Int?
subscriptionPlan SubscriptionPlan? @relation("SubscriptionItem_subscriptionPlan", fields: [subscriptionPlanId], references: [id])
subscriptionPlanId String? @map("subscriptionPlan")
isActive Boolean @default(true)
isDelinquent Boolean @default(false)
status String? @default("ACTIVE")
billing_interval String @default("month")
notes String @default("")
addons Addon[] @relation("Addon_subscriptionItems")
user User? @relation("SubscriptionItem_user", fields: [userId], references: [id])
userId String? @map("user")
stripeChargeId String @default("")
stripeSubscriptionId String @default("")
coupons Coupon[] @relation("Coupon_subscriptionItems")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
@@index([subscriptionPlanId])
@@index([userId])
}
model Product {
id String @id @default(cuid())
image String @default("")
name String @default("")
stripeProductId String @default("NO_PROD_ID")
stripePriceId String @default("NO_PRICE_ID")
slug String @unique @default("")
excerpt String @default("")
description Json @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
isForSale Boolean @default(true)
isForRent Boolean @default(false)
status String? @default("DRAFT")
price Int?
rental_price Int?
stockCount Int @default(0)
author User? @relation("Product_author", fields: [authorId], references: [id])
authorId String? @map("author")
orderItems OrderItem[] @relation("OrderItem_product")
addons Addon[] @relation("Addon_products")
tags Tag[] @relation("Product_tags")
categories Category[] @relation("Category_products")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
from_CartItem_product CartItem[] @relation("CartItem_product")
@@index([authorId])
}
model Rental {
id String @id @default(cuid())
start DateTime
end DateTime
location String @default("")
delivery Boolean @default(false)
price Int @default(0)
email String @default("")
phone String @default("")
name String @default("")
notes String @default("")
order Order? @relation("Order_rental")
addons Addon[] @relation("Addon_rentals")
customer User? @relation("Rental_customer", fields: [customerId], references: [id])
customerId String? @map("customer")
status String? @default("LEAD")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
google Json? @default("{\"id\":\"\",\"status\":\"\",\"kind\":\"\",\"htmlLink\":\"\"}")
@@index([customerId])
}
model CartItem {
id String @id @default(cuid())
quantity Int @default(1)
type String
product Product? @relation("CartItem_product", fields: [productId], references: [id])
productId String? @map("product")
user User? @relation("CartItem_user", fields: [userId], references: [id])
userId String? @map("user")
@@index([productId])
@@index([userId])
}
model OrderItem {
id String @id @default(cuid())
name String @default("")
description String @default("")
image String @default("")
type String
price Int?
quantity Int?
order Order? @relation("OrderItem_order", fields: [orderId], references: [id])
orderId String? @map("order")
product Product? @relation("OrderItem_product", fields: [productId], references: [id])
productId String? @map("product")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
@@index([orderId])
@@index([productId])
}
model Order {
id String @id @default(cuid())
email String @default("")
notes String @default("")
total Int?
items OrderItem[] @relation("OrderItem_order")
rental Rental? @relation("Order_rental", fields: [rentalId], references: [id])
rentalId String? @unique @map("rental")
ticketItems Ticket[] @relation("Ticket_order")
user User? @relation("Order_user", fields: [userId], references: [id])
userId String? @map("user")
charge String @default("")
stripeSessionId String @default("")
status String? @default("STARTED")
shipping_address String @default("")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
@@index([userId])
}
model Coupon {
id String @id @default(cuid())
name String @unique @default("")
stripeId String @default("")
amount_off Int?
percent_off Int?
duration_in_months Int?
duration String
subscriptionItems SubscriptionItem[] @relation("Coupon_subscriptionItems")
subscriptionPlans SubscriptionPlan[] @relation("Coupon_subscriptionPlans")
}
model Page {
id String @id @default(cuid())
title String @default("")
slug String @unique @default("")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
status String? @default("DRAFT")
template String? @default("FULLWIDTH")
pinned Int? @default(0)
excerpt String @default("")
featured_image String @default("")
featured_video String @default("")
content Json @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
author User? @relation("Page_author", fields: [authorId], references: [id])
authorId String? @map("author")
categories Category[] @relation("Category_pages")
tags Tag[] @relation("Page_tags")
@@index([authorId])
}
model Post {
id String @id @default(cuid())
title String @default("")
slug String @unique @default("")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
status String? @default("DRAFT")
template String? @default("FULLWIDTH")
pinned Int? @default(0)
excerpt String @default("")
featured_image String @default("")
featured_video String @default("")
content Json @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
allow_comments Boolean @default(false)
author User? @relation("Post_author", fields: [authorId], references: [id])
authorId String? @map("author")
categories Category[] @relation("Category_posts")
tags Tag[] @relation("Post_tags")
@@index([authorId])
}
model Event {
id String @id @default(cuid())
summary String @default("[NEW]")
location Location? @relation("Event_location", fields: [locationId], references: [id])
locationId String? @map("location")
start DateTime
end DateTime?
price Int @default(0)
hosts User[] @relation("Event_hosts")
cohosts User[] @relation("Event_cohosts")
tickets Ticket[] @relation("Ticket_event")
seats Int
image String @default("")
excerpt String @default("")
description Json @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
status String? @default("ACTIVE")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
categories Category[] @relation("Category_events")
tags Tag[] @relation("Event_tags")
@@index([locationId])
}
model Ticket {
id String @id @default(cuid())
qrcode String @default("")
event Event? @relation("Ticket_event", fields: [eventId], references: [id])
eventId String? @map("event")
email String @default("")
holder User? @relation("Ticket_holder", fields: [holderId], references: [id])
holderId String? @map("holder")
orderCount String @default("")
cost Int @default(0)
chargeId String @default("")
order Order? @relation("Ticket_order", fields: [orderId], references: [id])
orderId String? @map("order")
status String? @default("PAID")
dateCreated DateTime? @default(now())
dateModified DateTime? @default(now())
@@index([eventId])
@@index([holderId])
@@index([orderId])
}
model Category {
id String @id @default(cuid())
name String @unique @default("")
excerpt String @default("")
posts Post[] @relation("Category_posts")
pages Page[] @relation("Category_pages")
products Product[] @relation("Category_products")
subscriptions SubscriptionPlan[] @relation("Category_subscriptions")
events Event[] @relation("Category_events")
services Service[] @relation("Category_services")
locations Location[] @relation("Category_locations")
addons Addon[] @relation("Addon_categories")
}
model Tag {
id String @id @default(cuid())
name String @unique @default("")
posts Post[] @relation("Post_tags")
pages Page[] @relation("Page_tags")
products Product[] @relation("Product_tags")
subscriptions SubscriptionPlan[] @relation("SubscriptionPlan_tags")
events Event[] @relation("Event_tags")
services Service[] @relation("Service_tags")
locations Location[] @relation("Location_tags")
addons Addon[] @relation("Addon_tags")
}