-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
2665 lines (2383 loc) · 84.9 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
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
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(dbgenerated("nanoid(24)"))
name String
firstName String?
email String @unique
phone String?
password String
invoicedContactId String?
isPending Boolean @default(true)
isVerify Boolean @default(true)
defaultRoleId String?
refreshToken String?
createdAt DateTime @default(now())
updatedAt DateTime
bio String?
isActivated Boolean @default(true)
shortId String? @unique @default(dbgenerated("short_id('u'::text, 'model_user_seq'::text, 10000)"))
jobTitle String?
workingHours Json?
AccountTracking AccountTracking[]
Action_Action_assigneeIdToUser Action[] @relation("Action_assigneeIdToUser")
Action_Action_userCreatedIdToUser Action[] @relation("Action_userCreatedIdToUser")
CalendarEvent CalendarEvent[]
CatalogItem CatalogItem[]
CompleteVisit CompleteVisit[]
Feedback_Feedback_userCreatedIdToUser Feedback[] @relation("Feedback_userCreatedIdToUser")
Feedback_Feedback_userSubmitIdToUser Feedback[] @relation("Feedback_userSubmitIdToUser")
Goal Goal[]
GoogleCalendarEvent GoogleCalendarEvent[]
GoogleNotiChannel GoogleNotiChannel?
GoogleTokens GoogleTokens?
InternalComment InternalComment[]
Inventory Inventory[]
InventoryInformation InventoryInformation[]
Item Item[]
LastServiceMessage LastServiceMessage[]
LineItem LineItem[]
ListItem ListItem[]
MeetLink MeetLink[]
Note Note[]
Participant Participant[]
PinnedComment PinnedComment[]
ReadMessageTracking ReadMessageTracking[]
ReviewUpdate ReviewUpdate[]
ReviewUpdateNotification ReviewUpdateNotification[]
ScheduleEvent ScheduleEvent[]
Service_Service_assigneeIdToUser Service[] @relation("Service_assigneeIdToUser")
Service_Service_managerIdToUser Service[] @relation("Service_managerIdToUser")
Service_Service_requesterIdToUser Service[] @relation("Service_requesterIdToUser")
Service_Service_userCreatedToUser Service[] @relation("Service_userCreatedToUser")
ServiceMessage ServiceMessage[]
ServiceTracking ServiceTracking[]
ServiceUpdates ServiceUpdates[]
Space Space[]
SpaceDefaultList SpaceDefaultList[]
SpaceDraftList SpaceDraftList[]
SubscribeNotificationService SubscribeNotificationService[]
SubscriptionTracking SubscriptionTracking[]
Task_Task_assigneeIdToUser Task[] @relation("Task_assigneeIdToUser")
Task_Task_userCompletedIdToUser Task[] @relation("Task_userCompletedIdToUser")
Task_Task_userCreatedIdToUser Task[] @relation("Task_userCreatedIdToUser")
Technician Technician?
TimePreference TimePreference[]
TimeProposal TimeProposal[]
Role Role? @relation(fields: [defaultRoleId], references: [id], onDelete: Cascade)
UserAccount UserAccount[]
UserDeviceToken UserDeviceToken[]
UserPlace UserPlace[]
UserProfile UserProfile[]
UserReadServiceMessage UserReadServiceMessage[]
UserResetPassword UserResetPassword[]
UsersBelongRoles UsersBelongRoles[]
ViewDefault ViewDefault[]
Visit Visit[]
VisitExpense VisitExpense[]
VisitReport VisitReport[]
VisitTechnician VisitTechnician[]
@@index([createdAt(sort: Desc)])
@@index([name])
}
model Account {
id String @id @default(dbgenerated("nanoid(24)"))
name String
invoicedCustomerId String?
type AccountType @default(INDIVIDUAL)
email String?
phone String?
createdAt DateTime @default(now())
updatedAt DateTime
relationship RelationshipType? @default(CUSTOMER)
address1 String?
address2 String?
shortId String? @unique @default(dbgenerated("short_id('a'::text, 'model_account_seq'::text, 10000)"))
isArchived Boolean @default(false)
AccountMarket AccountMarket[]
AccountTracking AccountTracking[]
Service Service[]
ServiceVendor ServiceVendor[]
Subscription Subscription[]
UserAccount UserAccount[]
Vendor Vendor?
}
model AccountMarket {
id String @id @default(dbgenerated("nanoid(24)"))
accountId String
marketId String
createdAt DateTime @default(now())
updatedAt DateTime
Account Account @relation(fields: [accountId], references: [id], onDelete: Cascade)
Market Market @relation(fields: [marketId], references: [id], onDelete: Cascade)
@@index([accountId, marketId])
}
model AccountTracking {
id String @id @default(dbgenerated("nanoid(24)"))
userId String
accountId String
key AccountTrackingKey @default(ACQUISITION_CHANNEL)
value Json
createdAt DateTime @default(now())
updatedAt DateTime
Account Account @relation(fields: [accountId], references: [id])
User User @relation(fields: [userId], references: [id])
@@index([accountId])
@@index([key])
@@index([userId])
}
model Action {
id String @id @default(dbgenerated("nanoid(24)"))
membershipId String
homePlanId String?
title String?
description String?
userCreatedId String?
assigneeId String?
isRoutineActive Boolean? @default(false)
routineActiveDate DateTime?
routineInactiveDate DateTime?
cycle CYCLE?
timesPerCycle Int? @default(1)
basePrice Float?
ceilingPrice Float?
actionPrompt ActionPrompt?
actionType ActionType? @default(SERVICE_EVENT)
status ActionStatus? @default(OPEN)
createdAt DateTime @default(now())
updatedAt DateTime
User_Action_assigneeIdToUser User? @relation("Action_assigneeIdToUser", fields: [assigneeId], references: [id])
HomePlan HomePlan? @relation(fields: [homePlanId], references: [id], onDelete: Cascade)
Membership Membership @relation(fields: [membershipId], references: [id], onDelete: Cascade)
User_Action_userCreatedIdToUser User? @relation("Action_userCreatedIdToUser", fields: [userCreatedId], references: [id])
ActionItems ActionItems[]
ServiceAction ServiceAction[]
@@index([assigneeId])
@@index([createdAt(sort: Desc)])
@@index([isRoutineActive])
@@index([membershipId])
@@index([userCreatedId])
}
model ActionEvents {
id String @id @default(dbgenerated("nanoid(24)"))
oldData Json?
newData Json?
userId String?
type ActionEventType? @default(CREATE)
createdAt DateTime @default(now())
updatedAt DateTime
@@index([type])
@@index([userId])
}
model ActionItems {
id String @id @default(dbgenerated("nanoid(24)"))
itemId String
actionId String
createdAt DateTime @default(now())
updatedAt DateTime
Action Action @relation(fields: [actionId], references: [id], onDelete: Cascade)
Item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
@@index([actionId])
@@index([itemId])
}
model Activity {
id String @id @default(dbgenerated("nanoid(24)"))
userId String
serviceId String
type ActivityType? @default(CREATE)
oldService Json?
newService Json?
createdAt DateTime @default(now())
updatedAt DateTime
@@index([serviceId])
@@index([type])
@@index([userId])
}
model AiChatHistory {
id String @id @default(dbgenerated("nanoid(24)"))
message Json
createdAt DateTime @default(now())
contextId String
contextType String
userCreatedId String?
@@index([contextId], type: Hash)
}
model Attachable {
id String @id @default(dbgenerated("nanoid(24)"))
attachmentId String
attachableType String
attachableId String
createdAt DateTime @default(now())
updatedAt DateTime
Attachment Attachment @relation(fields: [attachmentId], references: [id], onDelete: Cascade)
@@index([attachableId], type: Hash)
@@index([attachableType], type: Hash)
}
model Attachment {
id String @id @default(dbgenerated("nanoid(24)"))
contentUri String
thumbnailUri String?
fileName String
fileSize Int @default(0)
type AttachmentType? @default(FILE)
createdAt DateTime @default(now())
updatedAt DateTime
uploaded Boolean? @default(true)
Attachable Attachable[]
@@index([contentUri])
@@index([createdAt(sort: Desc)])
@@index([type])
@@index([updatedAt(sort: Desc)])
}
model CalendarEvent {
id String @id @default(dbgenerated("nanoid(24)"))
userCreatedId String
calendarEventItemId String
calendarEventItemType CalendarEventItemType? @default(VISIT)
isAllDay Boolean? @default(false)
createdAt DateTime @default(now())
updatedAt DateTime
User User @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
@@index([calendarEventItemType], type: Hash)
@@index([userCreatedId], type: Hash)
}
model CatalogItem {
id String @id @default(dbgenerated("nanoid(24)"))
SKU String?
name String
description String?
type CatalogType? @default(SERVICE)
categoryId String?
cost Float?
price Float?
userCreatedId String
isFlatPrice Boolean? @default(false)
createdAt DateTime @default(now())
updatedAt DateTime
isPublic Boolean? @default(true)
unitType UnitType? @default(HOUR)
markup Float?
Category Category? @relation(fields: [categoryId], references: [id], onDelete: Cascade)
User User @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
CatalogItemAssembly_CatalogItemAssembly_assemblyIdToCatalogItem CatalogItemAssembly[] @relation("CatalogItemAssembly_assemblyIdToCatalogItem")
CatalogItemAssembly_CatalogItemAssembly_itemIdToCatalogItem CatalogItemAssembly[] @relation("CatalogItemAssembly_itemIdToCatalogItem")
CatalogItemLabor CatalogItemLabor[]
Checklist Checklist[]
@@index([categoryId])
}
model CatalogItemAssembly {
id String @id @default(dbgenerated("nanoid(24)"))
assemblyId String
itemId String
quantity Float @default(1)
createdAt DateTime @default(now())
updatedAt DateTime
CatalogItem_CatalogItemAssembly_assemblyIdToCatalogItem CatalogItem @relation("CatalogItemAssembly_assemblyIdToCatalogItem", fields: [assemblyId], references: [id], onDelete: Cascade)
CatalogItem_CatalogItemAssembly_itemIdToCatalogItem CatalogItem @relation("CatalogItemAssembly_itemIdToCatalogItem", fields: [itemId], references: [id], onDelete: Cascade)
@@index([assemblyId])
@@index([itemId])
}
model CatalogItemLabor {
id String @id @default(dbgenerated("nanoid(24)"))
laborId String
itemId String
quantity Float @default(1)
createdAt DateTime @default(now())
updatedAt DateTime
CatalogItem CatalogItem @relation(fields: [itemId], references: [id], onDelete: Cascade)
Labor Labor @relation(fields: [laborId], references: [id], onDelete: Cascade)
@@index([itemId])
@@index([laborId])
}
model Categorizable {
id String @id @default(dbgenerated("nanoid(24)"))
categoryId String
createdAt DateTime @default(now())
updatedAt DateTime
categorizableId String
categorizableType String
Category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade)
@@index([categorizableId])
@@index([categoryId])
}
model Category {
id String @id @default(dbgenerated("nanoid(24)"))
createdAt DateTime @default(now())
updatedAt DateTime
title String
order Int @default(0)
parentCategoryId String?
CatalogItem CatalogItem[]
Categorizable Categorizable[]
Labor Labor[]
@@index([order])
}
model Checklist {
id String @id @default(dbgenerated("nanoid(24)"))
name String
itemId String
createdAt DateTime @default(now())
updatedAt DateTime
CatalogItem CatalogItem @relation(fields: [itemId], references: [id], onDelete: Cascade)
@@index([itemId])
}
model CompleteVisit {
id String @id @default(dbgenerated("nanoid(24)"))
visitId String @unique
userCreatedId String
status CompleteVisitStatus @default(JOB_COMPLETE)
fromDateTime DateTime
toDateTime DateTime
totalExpenses Float?
workDescription String?
nextSteps String?
comment String?
createdAt DateTime @default(now())
updatedAt DateTime
User User @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
Visit Visit @relation(fields: [visitId], references: [id], onDelete: Cascade)
@@index([status], type: Hash)
@@index([userCreatedId], type: Hash)
@@index([visitId], type: Hash)
}
model CustomRules {
id String @id @default(dbgenerated("nanoid(24)"))
key CustomRulesKey
value Json
description String?
createdAt DateTime @default(now())
updatedAt DateTime
}
model EventLog {
id String @id @default(dbgenerated("nanoid(24)"))
type GraphQLOperationType @default(MUTATION)
operationName String
inputData Json?
resultData Json?
createdBy String?
createdAt DateTime @default(now())
updatedAt DateTime
@@index([operationName])
}
model Feedback {
id String @id @default(dbgenerated("nanoid(24)"))
serviceId String @unique
userSubmitId String?
userCreatedId String
submittedAt DateTime?
rating Int?
status FeedbackStatus @default(OPEN)
tags Json?
comment String?
channel FeedbackChannel? @default(WEB)
createdAt DateTime @default(now())
updatedAt DateTime
dismissAt DateTime?
isActuallySubmitted Boolean? @default(false)
Service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
User_Feedback_userCreatedIdToUser User @relation("Feedback_userCreatedIdToUser", fields: [userCreatedId], references: [id])
User_Feedback_userSubmitIdToUser User? @relation("Feedback_userSubmitIdToUser", fields: [userSubmitId], references: [id])
@@index([serviceId])
@@index([userCreatedId])
@@index([userSubmitId])
}
model Flow {
id String @id @default(dbgenerated("nanoid(24)"))
name String
type FlowType
version Int? @default(1)
createdAt DateTime @default(now())
updatedAt DateTime
FlowStep FlowStep[]
Onboarding Onboarding[]
}
model FlowStep {
id String @id @default(dbgenerated("nanoid(24)"))
name String
flowId String?
model String?
order Int? @default(1)
payload Json?
rule Json?
createdAt DateTime @default(now())
updatedAt DateTime
Flow Flow? @relation(fields: [flowId], references: [id], onDelete: Cascade)
}
model Goal {
id String @id @default(dbgenerated("nanoid(24)"))
title String
membershipId String
userCreatedId String
onboardingId String?
order Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime
Membership Membership @relation(fields: [membershipId], references: [id], onDelete: Cascade)
Onboarding Onboarding? @relation(fields: [onboardingId], references: [id], onDelete: Cascade)
User User @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
@@index([membershipId])
@@index([onboardingId])
@@index([userCreatedId])
}
model GoogleCalendarEvent {
id String @id @default(dbgenerated("nanoid(24)"))
eventId String
status String?
fromDateTime DateTime
toDateTime DateTime
htmlLink String?
hangoutLink String?
title String?
description String?
creator String?
organizer String?
attendees Json?
recurrence Json?
fromUserId String
createdAt DateTime @default(now())
updatedAt DateTime
eventType String?
originalStartTime DateTime?
recurringEventId String?
validUntil DateTime?
isAllDay Boolean? @default(false)
timeZone String?
User User @relation(fields: [fromUserId], references: [id], onDelete: Cascade)
@@index([eventId])
@@index([fromUserId])
}
model GoogleNotiChannel {
id String @id @default(dbgenerated("nanoid(24)"))
userId String @unique
channelId String
kind String
resourceId String
resourceUri String
token String?
expiryDate DateTime?
createdAt DateTime @default(now())
updatedAt DateTime
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
}
model GoogleTokens {
id String @id @default(dbgenerated("nanoid(24)"))
userId String @unique
state String
accessToken String?
refreshToken String?
scope String?
tokenType String?
expiryDate DateTime?
createdAt DateTime @default(now())
updatedAt DateTime
consentEmail String?
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
}
model HomePlan {
id String @id @default(dbgenerated("nanoid(24)"))
membershipId String
showPlanWelcome Boolean @default(true)
isHomePlanReviewed Boolean @default(false)
isHomeReportReviewed Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime
Action Action[]
Membership Membership @relation(fields: [membershipId], references: [id], onDelete: Cascade)
Onboarding Onboarding?
@@index([membershipId])
}
model InternalComment {
id String @id @default(dbgenerated("nanoid(24)"))
serviceId String
authorId String
plainBody String
replyToId String?
createdAt DateTime @default(now())
updatedAt DateTime
body String?
User User @relation(fields: [authorId], references: [id], onDelete: Cascade)
InternalComment InternalComment? @relation("InternalCommentToInternalComment", fields: [replyToId], references: [id], onDelete: NoAction, onUpdate: NoAction)
other_InternalComment InternalComment[] @relation("InternalCommentToInternalComment")
Service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
LinkPreview LinkPreview[]
PinnedComment PinnedComment[]
ReviewUpdate ReviewUpdate[]
@@index([authorId])
@@index([serviceId])
}
model Inventory {
id String @id @default(dbgenerated("nanoid(24)"))
name String
spaceId String
userCreatedId String
createdAt DateTime @default(now())
updatedAt DateTime
Space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade)
User User @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
InventoryInformation InventoryInformation?
}
model InventoryInformation {
id String @id @default(dbgenerated("nanoid(24)"))
inventoryId String @unique
userCreatedId String
utility String?
manufacturer String?
model String?
modelNumber String?
serialNumber String?
materialOrSpecs String?
dateManufactured DateTime?
approximateAge String?
typicalWarrantyPeriod String?
expectedLifeTimeDuration String?
category String?
createdAt DateTime @default(now())
updatedAt DateTime
Inventory Inventory @relation(fields: [inventoryId], references: [id], onDelete: Cascade)
User User @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
}
model Invoice {
id String @id @default(dbgenerated("nanoid(24)"))
invoiceId String
invoiceNumber String?
source InvoiceSource?
status String?
total Float?
date DateTime?
serviceId String
createdAt DateTime @default(now())
updatedAt DateTime
Service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
}
model Item {
id String @id @default(dbgenerated("nanoid(24)"))
title String
description String
price Float?
itemTypeId String
itemCategoryId String?
SKU String?
isAllowRoutine Boolean? @default(true)
userCreatedId String?
createdAt DateTime @default(now())
updatedAt DateTime
ActionItems ActionItems[]
ItemCategory ItemCategory? @relation(fields: [itemCategoryId], references: [id], onDelete: Cascade)
ItemType ItemType @relation(fields: [itemTypeId], references: [id], onDelete: Cascade)
User User? @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
@@index([createdAt(sort: Desc)])
@@index([isAllowRoutine])
@@index([itemCategoryId])
@@index([itemTypeId])
@@index([userCreatedId])
}
model ItemCategory {
id String @id @default(dbgenerated("nanoid(24)"))
title String
order Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime
Item Item[]
}
model ItemEvents {
id String @id @default(dbgenerated("nanoid(24)"))
oldData Json?
newData Json?
userId String?
type ItemEventType? @default(CREATE)
createdAt DateTime @default(now())
updatedAt DateTime
@@index([type])
@@index([userId])
}
model ItemType {
id String @id @default(dbgenerated("nanoid(24)"))
itemName String
itemKey String @unique
order Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime
Item Item[]
}
model Labor {
id String @id @default(dbgenerated("nanoid(24)"))
name String
skillId String?
cost Float?
price Float?
unitType UnitType? @default(HOUR)
createdAt DateTime @default(now())
updatedAt DateTime
categoryId String?
markup Float?
CatalogItemLabor CatalogItemLabor[]
Category Category? @relation(fields: [categoryId], references: [id], onDelete: Cascade)
Skill Skill? @relation(fields: [skillId], references: [id], onDelete: Cascade)
@@index([skillId])
}
model LastServiceMessage {
id String @id @default(dbgenerated("nanoid(24)"))
serviceId String @unique
plainBody String?
userCreatedId String?
viaEmail Boolean? @default(false)
createdAt DateTime @default(now())
updatedAt DateTime
viaChannel MessageViaType? @default(WEB)
body String?
Service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
User User? @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
@@index([userCreatedId])
@@index([viaChannel])
@@index([viaEmail])
}
model LineItem {
id String @id @default(dbgenerated("nanoid(24)"))
title String
description String?
userCreatedId String
price Float?
order Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime
serviceId String
Service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
User User @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
@@index([userCreatedId])
}
model LinkPreview {
id String @id @default(dbgenerated("nanoid(24)"))
url String
domain String
title String?
description String?
ogTitle String?
ogImage String?
createdAt DateTime @default(now())
updatedAt DateTime
internalCommentId String?
serviceMessageId String?
InternalComment InternalComment? @relation(fields: [internalCommentId], references: [id], onDelete: Cascade)
ServiceMessage ServiceMessage? @relation(fields: [serviceMessageId], references: [id], onDelete: Cascade)
@@index([createdAt(sort: Desc)])
@@index([serviceMessageId])
@@index([updatedAt(sort: Desc)])
}
model ListItem {
id String @id @default(dbgenerated("nanoid(24)"))
title String
description String?
userCreatedId String
placeId String?
status ListItemStatus? @default(TODO)
order Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime
isImportant Boolean @default(false)
membershipId String?
onboardingId String?
source ListItemSource? @default(LIST)
frequency ListItemFrequency? @default(ONCE)
maxPrice Float?
minPrice Float?
priority ListItemPriority? @default(THIS_MONTH)
Membership Membership? @relation(fields: [membershipId], references: [id], onDelete: Cascade)
Onboarding Onboarding? @relation(fields: [onboardingId], references: [id], onDelete: Cascade)
Place Place? @relation(fields: [placeId], references: [id], onDelete: Cascade)
User User @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
ListItemLinker ListItemLinker[]
@@index([membershipId])
@@index([onboardingId])
@@index([placeId])
@@index([userCreatedId])
}
model ListItemLinker {
id String @id @default(dbgenerated("nanoid(24)"))
listItemId String
type String
linkId String
createdAt DateTime @default(now())
updatedAt DateTime
ListItem ListItem @relation(fields: [listItemId], references: [id], onDelete: Cascade)
@@index([listItemId])
}
model MailTemplate {
id String @id @default(dbgenerated("nanoid(24)"))
name EmailTemplateName
fileName String
fromEmail String
fromEmailName String
description String?
createdAt DateTime @default(now())
updatedAt DateTime
}
model Market {
id String @id @default(dbgenerated("nanoid(24)"))
name String
key String
order Int @default(1)
createdAt DateTime @default(now())
updatedAt DateTime
AccountMarket AccountMarket[]
Place Place[]
}
model MeetLink {
id String @id @default(dbgenerated("nanoid(24)"))
userCreatedId String
meetType MeetLinkType? @default(SCHEDULE)
url String @unique
expiryDate DateTime
createdAt DateTime @default(now())
updatedAt DateTime
User User @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
ScheduleEvent ScheduleEvent[]
@@index([meetType], type: Hash)
@@index([url], type: Hash)
@@index([userCreatedId], type: Hash)
}
model Membership {
id String @id @default(dbgenerated("nanoid(24)"))
subscriptionId String
placeId String
invoicedSubscriptionId String?
isActive Boolean @default(true)
activeDate DateTime? @default(now())
inactiveDate DateTime?
createdAt DateTime @default(now())
updatedAt DateTime
paused Boolean? @default(false)
shortId String? @unique @default(dbgenerated("short_id('m'::text, 'model_membership_seq'::text, 10000)"))
residenceType ResidenceType? @default(PRIMARY)
Action Action[]
Goal Goal[]
HomePlan HomePlan[]
ListItem ListItem[]
Place Place @relation(fields: [placeId], references: [id], onDelete: Cascade)
Subscription Subscription @relation(fields: [subscriptionId], references: [id], onDelete: Cascade)
Onboarding Onboarding[]
Service Service[]
@@index([createdAt(sort: Desc)])
@@index([isActive])
@@index([placeId])
@@index([subscriptionId])
}
model MembershipEvents {
id String @id @default(dbgenerated("nanoid(24)"))
oldData Json?
newData Json?
userId String?
source MembershipSource? @default(SYSTEM)
type MembershipType? @default(CREATE)
refSubscriptionEventsId String?
createdAt DateTime @default(now())
updatedAt DateTime
@@index([userId])
}
model MultipleUploadProgess {
id String @id @default(dbgenerated("nanoid(24)"))
partKey String @unique
contentUri String
fileKey String
fileId String
partNumber String
signedUrl String?
status MultipleUploadStatus @default(IN_PROGRESS)
createdAt DateTime @default(now())
updatedAt DateTime
@@index([contentUri], type: Hash)
}
model Note {
id String @id @default(dbgenerated("nanoid(24)"))
itemKey String
itemValue String
plainBody String?
body String?
userCreatedId String
viaChannel MessageViaType? @default(WEB)
createdAt DateTime @default(now())
updatedAt DateTime
User User @relation(fields: [userCreatedId], references: [id], onDelete: Cascade)
@@index([createdAt(sort: Desc)])
@@index([userCreatedId])
@@index([viaChannel])
}
model OTP {
id String @id @default(dbgenerated("nanoid(24)"))
phone String @unique
otp String
expirationTime Int
}
model Onboarding {
id String @id @default(dbgenerated("nanoid(24)"))
homeEvaluationServiceId String? @unique
createdAt DateTime @default(now())
updatedAt DateTime
homeplanId String? @unique
isActive Boolean? @default(false)
currentStep OnboardingStepType?
status OnboardingStatus @default(OPEN)
membershipId String?
version Int? @default(1)
completedAt DateTime?
currentStage OnboardingStage?
flowId String?
Goal Goal[]
ListItem ListItem[]
Flow Flow? @relation(fields: [flowId], references: [id])
Service Service? @relation(fields: [homeEvaluationServiceId], references: [id])
HomePlan HomePlan? @relation(fields: [homeplanId], references: [id], onDelete: Cascade)
Membership Membership? @relation(fields: [membershipId], references: [id], onDelete: Cascade)
OnboardingStep OnboardingStep[]
SpaceDraftList SpaceDraftList[]
@@index([status])
}
model OnboardingStep {
id String @id @default(dbgenerated("nanoid(24)"))
onboardingId String
step OnboardingStepType @default(PRODUCT_INTRO)
status OnboardingStepStatus @default(NOT_STARTED)
payload Json?
createdAt DateTime @default(now())
updatedAt DateTime
completedAt DateTime?
startedAt DateTime?
dueAt DateTime?
entity String?
linkedServiceId String?
manageExperience OnboardingExperience?
memberExperience OnboardingExperience?
order Int? @default(1)
stage OnboardingStage?
isAuto Boolean?
name String?
Service Service? @relation(fields: [linkedServiceId], references: [id])
Onboarding Onboarding @relation(fields: [onboardingId], references: [id], onDelete: Cascade)
@@index([onboardingId])
@@index([status])
}
model Participant {
id String @id @default(dbgenerated("nanoid(24)"))
userId String
participantItemId String
participantItemType String
createdAt DateTime @default(now())
updatedAt DateTime
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([participantItemId], type: Hash)
@@index([participantItemType], type: Hash)
@@index([userId], type: Hash)
}
model Permission {
id String @id @default(dbgenerated("nanoid(24)"))
roleId String @unique
createdAt DateTime @default(now())
updatedAt DateTime
Role Role @relation(fields: [roleId], references: [id], onDelete: Cascade)
PermissionTypesOnPermissions PermissionTypesOnPermissions[]
}
model PermissionType {
id String @id @default(dbgenerated("nanoid(24)"))
name String @unique
createdAt DateTime @default(now())
updatedAt DateTime
PermissionTypesOnPermissions PermissionTypesOnPermissions[]
}
model PermissionTypesOnPermissions {
id String @id @default(dbgenerated("nanoid(24)"))
permissionId String
permissionTypeId String
createdAt DateTime @default(now())
updatedAt DateTime
Permission Permission @relation(fields: [permissionId], references: [id], onDelete: Cascade)
PermissionType PermissionType @relation(fields: [permissionTypeId], references: [id], onDelete: Cascade)
}