-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathschema.prisma
More file actions
890 lines (814 loc) · 40.3 KB
/
schema.prisma
File metadata and controls
890 lines (814 loc) · 40.3 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
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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
// 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("")
email String @unique @default("")
password String
role Role? @relation("User_role", fields: [roleId], references: [id])
roleId String? @map("role")
apiKeys ApiKey[] @relation("ApiKey_user")
phone String @default("")
restaurantOrders RestaurantOrder[] @relation("RestaurantOrder_customer")
addresses Address[] @relation("Address_user")
carts Cart[] @relation("Cart_user")
employeeId String?
staffRole String?
hireDate DateTime?
hourlyRate Decimal? @postgresql.Decimal(10, 2)
pin String @default("")
staffPermissions Json?
isActive Boolean @default(true)
onboardingStatus String? @default("not_started")
photo_id String?
photo_filesize Int?
photo_width Int?
photo_height Int?
photo_extension String?
emergencyContactName String @default("")
emergencyContactPhone String @default("")
certifications Json?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
passwordResetToken String?
passwordResetIssuedAt DateTime?
passwordResetRedeemedAt DateTime?
from_RestaurantOrder_server RestaurantOrder[] @relation("RestaurantOrder_server")
from_RestaurantOrder_createdBy RestaurantOrder[] @relation("RestaurantOrder_createdBy")
from_KitchenMessage_sender KitchenMessage[] @relation("KitchenMessage_sender")
from_Payment_processedBy Payment[] @relation("Payment_processedBy")
from_KitchenStation_assignedStaff KitchenStation[] @relation("KitchenStation_assignedStaff")
from_KitchenTicket_preparedBy KitchenTicket[] @relation("KitchenTicket_preparedBy")
from_StockMovement_createdBy StockMovement[] @relation("StockMovement_createdBy")
from_WaitlistEntry_addedBy WaitlistEntry[] @relation("WaitlistEntry_addedBy")
from_Shift_staff Shift[] @relation("Shift_staff")
from_TipPool_createdBy TipPool[] @relation("TipPool_createdBy")
from_TimeEntry_staff TimeEntry[] @relation("TimeEntry_staff")
from_WasteLog_loggedBy WasteLog[] @relation("WasteLog_loggedBy")
from_PurchaseOrder_createdBy PurchaseOrder[] @relation("PurchaseOrder_createdBy")
@@index([roleId])
}
model Role {
id String @id @default(cuid())
name String @default("")
canAccessDashboard Boolean @default(false)
canReadOrders Boolean @default(false)
canManageOrders Boolean @default(false)
canReadPayments Boolean @default(false)
canManagePayments Boolean @default(false)
canReadProducts Boolean @default(false)
canManageProducts Boolean @default(false)
canReadCart Boolean @default(false)
canManageCart Boolean @default(false)
canReadInventory Boolean @default(false)
canManageInventory Boolean @default(false)
canReadUsers Boolean @default(false)
canManageUsers Boolean @default(false)
canSeeOtherPeople Boolean @default(false)
canEditOtherPeople Boolean @default(false)
canManagePeople Boolean @default(false)
canReadRoles Boolean @default(false)
canManageRoles Boolean @default(false)
canReadKitchen Boolean @default(false)
canManageKitchen Boolean @default(false)
canReadTables Boolean @default(false)
canManageTables Boolean @default(false)
canReadStaff Boolean @default(false)
canManageStaff Boolean @default(false)
canManageSettings Boolean @default(false)
canManageOnboarding Boolean @default(true)
canReadVendors Boolean @default(false)
canManageVendors Boolean @default(false)
canReadGiftCards Boolean @default(false)
canManageGiftCards Boolean @default(false)
canReadDiscounts Boolean @default(false)
canManageDiscounts Boolean @default(false)
assignedTo User[] @relation("User_role")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model Section {
id String @id @default(cuid())
name String @unique @default("")
tables Table[] @relation("Table_section")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model Floor {
id String @id @default(cuid())
name String @default("")
level Int @default(1)
isActive Boolean @default(true)
tables Table[] @relation("Table_floor")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model Table {
id String @id @default(cuid())
tableNumber String @default("")
capacity Int @default(4)
status String? @default("available")
shape String? @default("rectangle")
positionX Float? @default(0)
positionY Float? @default(0)
metadata Json?
floor Floor? @relation("Table_floor", fields: [floorId], references: [id])
floorId String? @map("floor")
section Section? @relation("Table_section", fields: [sectionId], references: [id])
sectionId String? @map("section")
orders RestaurantOrder[] @relation("RestaurantOrder_tables")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
from_Reservation_assignedTable Reservation[] @relation("Reservation_assignedTable")
from_WaitlistEntry_table WaitlistEntry[] @relation("WaitlistEntry_table")
@@index([tableNumber])
@@index([floorId])
@@index([sectionId])
}
model MenuCategory {
id String @id @default(cuid())
name String @default("")
icon String @default("")
description String @default("")
mealPeriods Json @default("[\"all_day\"]")
sortOrder Int? @default(0)
menuItems MenuItem[] @relation("MenuItem_category")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model MenuItem {
id String @id @default(cuid())
name String @default("")
menuItemImages MenuItemImage[] @relation("MenuItem_menuItemImages")
description Json @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
price Int
available Boolean @default(true)
featured Boolean @default(false)
popular Boolean @default(false)
prepTime Int? @default(15)
calories Int?
kitchenStation String? @default("grill")
allergens Json @default("[]")
dietaryFlags Json @default("[]")
mealPeriods Json @default("[\"all_day\"]")
category MenuCategory? @relation("MenuItem_category", fields: [categoryId], references: [id])
categoryId String? @map("category")
modifiers MenuItemModifier[] @relation("MenuItemModifier_menuItem")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
from_OrderItem_menuItem OrderItem[] @relation("OrderItem_menuItem")
from_Recipe_menuItem Recipe[] @relation("Recipe_menuItem")
from_CartItem_menuItem CartItem[] @relation("CartItem_menuItem")
from_PrepStation_menuItem PrepStation[] @relation("PrepStation_menuItem")
@@index([categoryId])
}
model MenuItemImage {
id String @id @default(cuid())
image_id String?
image_filesize Int?
image_width Int?
image_height Int?
image_extension String?
imagePath String @default("")
altText String @default("")
order Int? @default(0)
menuItems MenuItem[] @relation("MenuItem_menuItemImages")
metadata Json?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model MenuItemModifier {
id String @id @default(cuid())
name String @default("")
modifierGroup String? @default("addons")
modifierGroupLabel String @default("")
required Boolean @default(false)
minSelections Int? @default(0)
maxSelections Int? @default(1)
priceAdjustment Int? @default(0)
calories Int?
defaultSelected Boolean @default(false)
menuItem MenuItem? @relation("MenuItemModifier_menuItem", fields: [menuItemId], references: [id])
menuItemId String? @map("menuItem")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
from_OrderItem_appliedModifiers OrderItem[] @relation("OrderItem_appliedModifiers")
from_CartItem_modifiers CartItem[] @relation("CartItem_modifiers")
@@index([menuItemId])
}
model RestaurantOrder {
id String @id @default(cuid())
orderNumber String @unique @default("")
orderType String? @default("dine_in")
orderSource String? @default("pos")
status String? @default("open")
guestCount Int? @default(1)
specialInstructions String @default("")
onHold Boolean @default(false)
holdReason String @default("")
isUrgent Boolean @default(false)
subtotal Int? @default(0)
tax Int? @default(0)
tip Int? @default(0)
discount Int? @default(0)
total Int? @default(0)
currencyCode String @default("USD")
customerName String @default("")
customerEmail String @default("")
customerPhone String @default("")
deliveryAddress String @default("")
deliveryAddress2 String @default("")
deliveryCity String @default("")
deliveryState String @default("")
deliveryZip String @default("")
deliveryCountryCode String @default("")
secretKey String @default("")
tableSeatedAt DateTime? @default(now())
tableFreedAt DateTime?
tables Table[] @relation("RestaurantOrder_tables")
customer User? @relation("RestaurantOrder_customer", fields: [customerId], references: [id])
customerId String? @map("customer")
server User? @relation("RestaurantOrder_server", fields: [serverId], references: [id])
serverId String? @map("server")
createdBy User? @relation("RestaurantOrder_createdBy", fields: [createdById], references: [id])
createdById String? @map("createdBy")
courses OrderCourse[] @relation("OrderCourse_order")
orderItems OrderItem[] @relation("OrderItem_order")
payments Payment[] @relation("Payment_order")
discounts Discount[] @relation("Discount_orders")
giftCards GiftCard[] @relation("GiftCard_order")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
from_KitchenMessage_order KitchenMessage[] @relation("KitchenMessage_order")
from_Cart_order Cart[] @relation("Cart_order")
from_GiftCardTransaction_order GiftCardTransaction[] @relation("GiftCardTransaction_order")
from_KitchenTicket_order KitchenTicket[] @relation("KitchenTicket_order")
from_StockMovement_order StockMovement[] @relation("StockMovement_order")
@@index([customerId])
@@index([serverId])
@@index([createdById])
}
model Address {
id String @id @default(cuid())
name String @default("")
address1 String @default("")
address2 String @default("")
city String @default("")
state String @default("")
postalCode String @default("")
countryCode String @default("US")
country String @default("")
phone String @default("")
isDefault Boolean @default(false)
isBilling Boolean @default(false)
metadata Json?
user User? @relation("Address_user", fields: [userId], references: [id])
userId String? @map("user")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([userId])
}
model OrderItem {
id String @id @default(cuid())
quantity Int @default(1)
price Int
specialInstructions String @default("")
courseNumber Int? @default(1)
seatNumber Int?
sentToKitchen DateTime?
kitchenStatus String? @default("new")
firedAt DateTime?
kitchenStartedAt DateTime?
kitchenReadyAt DateTime?
fulfilledAt DateTime?
recalledAt DateTime?
order RestaurantOrder? @relation("OrderItem_order", fields: [orderId], references: [id])
orderId String? @map("order")
course OrderCourse? @relation("OrderItem_course", fields: [courseId], references: [id])
courseId String? @map("course")
menuItem MenuItem? @relation("OrderItem_menuItem", fields: [menuItemId], references: [id])
menuItemId String? @map("menuItem")
appliedModifiers MenuItemModifier[] @relation("OrderItem_appliedModifiers")
kitchenTickets KitchenTicket[] @relation("KitchenTicket_orderItems")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([orderId])
@@index([courseId])
@@index([menuItemId])
}
model OrderCourse {
id String @id @default(cuid())
courseType String @default("mains")
status String? @default("pending")
fireTime DateTime?
autoFireAt DateTime?
onHold Boolean @default(false)
allItemsReady Boolean @default(false)
courseNumber Int? @default(1)
order RestaurantOrder? @relation("OrderCourse_order", fields: [orderId], references: [id])
orderId String? @map("order")
orderItems OrderItem[] @relation("OrderItem_course")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([orderId])
}
model KitchenMessage {
id String @id @default(cuid())
content String @default("")
type String? @default("general")
fromStation String? @default("foh")
order RestaurantOrder? @relation("KitchenMessage_order", fields: [orderId], references: [id])
orderId String? @map("order")
sender User? @relation("KitchenMessage_sender", fields: [senderId], references: [id])
senderId String? @map("sender")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([orderId])
@@index([senderId])
}
model Recipe {
id String @id @default(cuid())
name String @default("")
menuItem MenuItem? @relation("Recipe_menuItem", fields: [menuItemId], references: [id])
menuItemId String? @map("menuItem")
recipeIngredients Json?
yield Int? @default(1)
prepTime Int?
instructions String @default("")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([menuItemId])
}
model Reservation {
id String @id @default(cuid())
customerName String @default("")
customerPhone String @default("")
customerEmail String @default("")
reservationDate DateTime
partySize Int @default(2)
duration Int? @default(90)
status String? @default("pending")
specialRequests String @default("")
assignedTable Table? @relation("Reservation_assignedTable", fields: [assignedTableId], references: [id])
assignedTableId String? @map("assignedTable")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([assignedTableId])
}
model Payment {
id String @id @default(cuid())
amount Int
data Json?
currencyCode String @default("USD")
status String @default("pending")
paymentMethod String? @default("credit_card")
paymentProvider PaymentProvider? @relation("Payment_paymentProvider", fields: [paymentProviderId], references: [id])
paymentProviderId String? @map("paymentProvider")
providerPaymentId String @default("")
cardLast4 String @default("")
cardBrand String @default("")
tipAmount Int? @default(0)
isSplitPayment Boolean @default(false)
splitPaymentIndex Int?
splitTotal Int?
processedAt DateTime?
errorMessage String @default("")
notes String @default("")
order RestaurantOrder? @relation("Payment_order", fields: [orderId], references: [id])
orderId String? @map("order")
paymentCollection PaymentCollection? @relation("Payment_paymentCollection", fields: [paymentCollectionId], references: [id])
paymentCollectionId String? @map("paymentCollection")
processedBy User? @relation("Payment_processedBy", fields: [processedById], references: [id])
processedById String? @map("processedBy")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([paymentProviderId])
@@index([orderId])
@@index([paymentCollectionId])
@@index([processedById])
}
model PaymentCollection {
id String @id @default(cuid())
description PaymentCollectionDescriptionType? @default(default)
amount Int
authorizedAmount Int? @default(0)
refundedAmount Int? @default(0)
metadata Json?
paymentSessions PaymentSession[] @relation("PaymentSession_paymentCollection")
payments Payment[] @relation("Payment_paymentCollection")
cart Cart? @relation("Cart_paymentCollection")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model PaymentSession {
id String @id @default(cuid())
isSelected Boolean @default(false)
isInitiated Boolean @default(false)
amount Int
data Json? @default("{}")
idempotencyKey String @default("")
paymentCollection PaymentCollection? @relation("PaymentSession_paymentCollection", fields: [paymentCollectionId], references: [id])
paymentCollectionId String? @map("paymentCollection")
paymentProvider PaymentProvider? @relation("PaymentSession_paymentProvider", fields: [paymentProviderId], references: [id])
paymentProviderId String? @map("paymentProvider")
paymentAuthorizedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([idempotencyKey])
@@index([paymentCollectionId])
@@index([paymentProviderId])
}
model Cart {
id String @id @default(cuid())
user User? @relation("Cart_user", fields: [userId], references: [id])
userId String? @map("user")
items CartItem[] @relation("CartItem_cart")
orderType String? @default("pickup")
email String @default("")
customerName String @default("")
customerPhone String @default("")
deliveryAddress String @default("")
deliveryAddress2 String @default("")
deliveryCity String @default("")
deliveryState String @default("")
deliveryZip String @default("")
deliveryCountryCode String @default("")
paymentCollection PaymentCollection? @relation("Cart_paymentCollection", fields: [paymentCollectionId], references: [id])
paymentCollectionId String? @unique @map("paymentCollection")
tipPercent String? @default("0")
order RestaurantOrder? @relation("Cart_order", fields: [orderId], references: [id])
orderId String? @map("order")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([userId])
@@index([orderId])
}
model CartItem {
id String @id @default(cuid())
cart Cart? @relation("CartItem_cart", fields: [cartId], references: [id])
cartId String? @map("cart")
menuItem MenuItem? @relation("CartItem_menuItem", fields: [menuItemId], references: [id])
menuItemId String? @map("menuItem")
quantity Int? @default(1)
modifiers MenuItemModifier[] @relation("CartItem_modifiers")
specialInstructions String @default("")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([cartId])
@@index([menuItemId])
}
model PaymentProvider {
id String @id @default(cuid())
name String @default("")
code String @unique @default("")
isInstalled Boolean @default(true)
credentials Json? @default("{}")
metadata Json? @default("{}")
createPaymentFunction String @default("")
capturePaymentFunction String @default("")
refundPaymentFunction String @default("")
getPaymentStatusFunction String @default("")
generatePaymentLinkFunction String @default("")
handleWebhookFunction String @default("")
sessions PaymentSession[] @relation("PaymentSession_paymentProvider")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
from_Payment_paymentProvider Payment[] @relation("Payment_paymentProvider")
}
model ApiKey {
id String @id @default(cuid())
name String @default("")
tokenSecret String
tokenPreview String @default("")
scopes Json? @default("[]")
status ApiKeyStatusType? @default(active)
expiresAt DateTime?
lastUsedAt DateTime?
usageCount Json? @default("{\"total\":0,\"daily\":{}}")
restrictedToIPs Json? @default("[]")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
user User? @relation("ApiKey_user", fields: [userId], references: [id])
userId String? @map("user")
@@index([userId])
}
model Discount {
id String @id @default(cuid())
code String @unique @default("")
isDynamic Boolean @default(false)
isDisabled Boolean @default(false)
stackable Boolean @default(false)
startsAt DateTime @default(now())
endsAt DateTime?
metadata Json?
usageLimit Int?
usageCount Int @default(0)
validDuration String @default("")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
discountRule DiscountRule? @relation("Discount_discountRule", fields: [discountRuleId], references: [id])
discountRuleId String? @map("discountRule")
orders RestaurantOrder[] @relation("Discount_orders")
@@index([discountRuleId])
}
model DiscountRule {
id String @id @default(cuid())
description String @default("")
type DiscountRuleTypeType
value Int
allocation DiscountRuleAllocationType?
metadata Json?
discounts Discount[] @relation("Discount_discountRule")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model GiftCard {
id String @id @default(cuid())
code String @unique @default("")
value Int
balance Int
isDisabled Boolean @default(false)
endsAt DateTime?
metadata Json?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
order RestaurantOrder? @relation("GiftCard_order", fields: [orderId], references: [id])
orderId String? @map("order")
giftCardTransactions GiftCardTransaction[] @relation("GiftCardTransaction_giftCard")
@@index([orderId])
}
model GiftCardTransaction {
id String @id @default(cuid())
amount Int
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
giftCard GiftCard? @relation("GiftCardTransaction_giftCard", fields: [giftCardId], references: [id])
giftCardId String? @map("giftCard")
order RestaurantOrder? @relation("GiftCardTransaction_order", fields: [orderId], references: [id])
orderId String? @map("order")
@@index([giftCardId])
@@index([orderId])
}
model KitchenStation {
id String @id @default(cuid())
name String @default("")
displayOrder Int? @default(0)
isActive Boolean @default(true)
assignedStaff User[] @relation("KitchenStation_assignedStaff")
tickets KitchenTicket[] @relation("KitchenTicket_station")
prepStations PrepStation[] @relation("PrepStation_station")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model PrepStation {
id String @id @default(cuid())
menuItem MenuItem? @relation("PrepStation_menuItem", fields: [menuItemId], references: [id])
menuItemId String? @map("menuItem")
station KitchenStation? @relation("PrepStation_station", fields: [stationId], references: [id])
stationId String? @map("station")
preparationTime Int? @default(15)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([menuItemId])
@@index([stationId])
}
model KitchenTicket {
id String @id @default(cuid())
status String @default("new")
priority Int? @default(0)
ticketType String? @default("prep")
items Json?
firedAt DateTime? @default(now())
startedAt DateTime?
completedAt DateTime?
servedAt DateTime?
recalledAt DateTime?
order RestaurantOrder? @relation("KitchenTicket_order", fields: [orderId], references: [id])
orderId String? @map("order")
station KitchenStation? @relation("KitchenTicket_station", fields: [stationId], references: [id])
stationId String? @map("station")
orderItems OrderItem[] @relation("KitchenTicket_orderItems")
preparedBy User? @relation("KitchenTicket_preparedBy", fields: [preparedById], references: [id])
preparedById String? @map("preparedBy")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([orderId])
@@index([stationId])
@@index([preparedById])
}
model Vendor {
id String @id @default(cuid())
name String @default("")
contact String @default("")
email String @default("")
phone String @default("")
paymentTerms String @default("")
leadTime Int?
ingredients Ingredient[] @relation("Ingredient_vendor")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
from_PurchaseOrder_vendor PurchaseOrder[] @relation("PurchaseOrder_vendor")
}
model InventoryLocation {
id String @id @default(cuid())
name String @default("")
description String @default("")
isActive Boolean @default(true)
ingredients Ingredient[] @relation("Ingredient_location")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model Ingredient {
id String @id @default(cuid())
name String @default("")
unit String @default("lb")
category String?
currentStock Decimal @default("0.00") @postgresql.Decimal(10, 2)
parLevel Decimal? @postgresql.Decimal(10, 2)
reorderPoint Decimal? @postgresql.Decimal(10, 2)
reorderQuantity Decimal? @postgresql.Decimal(10, 2)
costPerUnit Decimal? @postgresql.Decimal(10, 2)
expirationDate DateTime?
sku String @default("")
vendor Vendor? @relation("Ingredient_vendor", fields: [vendorId], references: [id])
vendorId String? @map("vendor")
location InventoryLocation? @relation("Ingredient_location", fields: [locationId], references: [id])
locationId String? @map("location")
stockMovements StockMovement[] @relation("StockMovement_ingredient")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
from_WasteLog_ingredient WasteLog[] @relation("WasteLog_ingredient")
@@index([vendorId])
@@index([locationId])
}
model StockMovement {
id String @id @default(cuid())
type String
quantity Decimal @postgresql.Decimal(10, 2)
reason String @default("")
ingredient Ingredient? @relation("StockMovement_ingredient", fields: [ingredientId], references: [id])
ingredientId String? @map("ingredient")
createdBy User? @relation("StockMovement_createdBy", fields: [createdById], references: [id])
createdById String? @map("createdBy")
order RestaurantOrder? @relation("StockMovement_order", fields: [orderId], references: [id])
orderId String? @map("order")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([ingredientId])
@@index([createdById])
@@index([orderId])
}
model StoreSettings {
id Int @id
name String @default("")
tagline String @default("")
address String @default("")
phone String @default("")
email String @default("")
currencyCode String @default("USD")
locale String @default("en-US")
timezone String @default("America/New_York")
countryCode String @default("US")
hours Json? @default("{\"monday\":\"11:00 AM - 10:00 PM\",\"tuesday\":\"11:00 AM - 10:00 PM\",\"wednesday\":\"11:00 AM - 10:00 PM\",\"thursday\":\"11:00 AM - 10:00 PM\",\"friday\":\"11:00 AM - 11:00 PM\",\"saturday\":\"10:00 AM - 11:00 PM\",\"sunday\":\"10:00 AM - 9:00 PM\"}")
taxRate Decimal? @default("8.75") @postgresql.Decimal(5, 2)
deliveryEnabled Boolean @default(true)
deliveryPostalCodes Json? @default("[\"11201\"]")
deliveryFee Decimal? @default("4.99") @postgresql.Decimal(10, 2)
deliveryMinimum Decimal? @default("15.00") @postgresql.Decimal(10, 2)
pickupDiscount Int? @default(10)
estimatedDelivery String @default("30-45 min")
estimatedPickup String @default("15-20 min")
heroHeadline String @default("Fresh meals for pickup and delivery.")
heroSubheadline String @default("A modern ordering storefront with house favorites, quick pickup, and a menu built to customize.")
heroTagline String @default("Made fresh daily · Ready when you are")
promoBanner String @default("Free pickup discount · 10% off all pickup orders")
rating Decimal? @default("4.8") @postgresql.Decimal(2, 1)
reviewCount Int? @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model WaitlistEntry {
id String @id @default(cuid())
customerName String @default("")
phoneNumber String @default("")
partySize Int @default(2)
quotedWaitTime Int? @default(15)
status String? @default("waiting")
addedAt DateTime @default(now())
notifiedAt DateTime?
seatedAt DateTime?
notes String @default("")
table Table? @relation("WaitlistEntry_table", fields: [tableId], references: [id])
tableId String? @map("table")
addedBy User? @relation("WaitlistEntry_addedBy", fields: [addedById], references: [id])
addedById String? @map("addedBy")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([tableId])
@@index([addedById])
}
model Shift {
id String @id @default(cuid())
startTime DateTime
endTime DateTime
role String @default("server")
status String? @default("scheduled")
hourlyRate Decimal? @postgresql.Decimal(10, 2)
clockIn DateTime?
clockOut DateTime?
notes String @default("")
staff User? @relation("Shift_staff", fields: [staffId], references: [id])
staffId String? @map("staff")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([staffId])
}
model TipPool {
id String @id @default(cuid())
date DateTime
tipPoolType String? @default("individual")
totalTips Int @default(0)
cashTips Int? @default(0)
creditTips Int? @default(0)
distributions Json?
status String? @default("open")
notes String @default("")
createdBy User? @relation("TipPool_createdBy", fields: [createdById], references: [id])
createdById String? @map("createdBy")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([createdById])
}
model TimeEntry {
id String @id @default(cuid())
clockIn DateTime
clockOut DateTime?
role String? @default("server")
hourlyRate Decimal? @postgresql.Decimal(10, 2)
tips Decimal? @default("0.00") @postgresql.Decimal(10, 2)
breakMinutes Decimal? @default("0") @postgresql.Decimal(5, 0)
notes String @default("")
staff User? @relation("TimeEntry_staff", fields: [staffId], references: [id])
staffId String? @map("staff")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([staffId])
}
model WasteLog {
id String @id @default(cuid())
quantity Decimal @postgresql.Decimal(10, 2)
reason String @default("spoilage")
notes String @default("")
ingredient Ingredient? @relation("WasteLog_ingredient", fields: [ingredientId], references: [id])
ingredientId String? @map("ingredient")
loggedBy User? @relation("WasteLog_loggedBy", fields: [loggedById], references: [id])
loggedById String? @map("loggedBy")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([ingredientId])
@@index([loggedById])
}
model PurchaseOrder {
id String @id @default(cuid())
poNumber String @unique @default("")
orderDate DateTime @default(now())
expectedDelivery DateTime?
receivedDate DateTime?
status String? @default("draft")
lineItems Json?
notes String @default("")
vendor Vendor? @relation("PurchaseOrder_vendor", fields: [vendorId], references: [id])
vendorId String? @map("vendor")
createdBy User? @relation("PurchaseOrder_createdBy", fields: [createdById], references: [id])
createdById String? @map("createdBy")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([vendorId])
@@index([createdById])
}
enum PaymentCollectionDescriptionType {
default
refund
}
enum ApiKeyStatusType {
active
inactive
revoked
}
enum DiscountRuleTypeType {
fixed
percentage
free_item
}
enum DiscountRuleAllocationType {
total
item
}