@creator.co/creatorco-prisma-client 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/schema.prisma ADDED
@@ -0,0 +1,978 @@
1
+ generator erd {
2
+ provider = "prisma-erd-generator"
3
+ includeRelationFromFields = true
4
+ output = "../../docs/creatorco_erd.svg"
5
+ }
6
+
7
+ generator kysely {
8
+ provider = "prisma-kysely"
9
+ output = "../../client/creatorco/kysely"
10
+ fileName = "types.ts"
11
+ enumFileName = "enums.ts"
12
+ readOnlyIds = true
13
+ jsonTypeOverride = Json
14
+ }
15
+
16
+ generator client {
17
+ provider = "prisma-client-js"
18
+ output = "../../client/creatorco/client"
19
+ previewFeatures = ["fullTextIndex", "fullTextSearch"]
20
+ }
21
+
22
+ datasource db {
23
+ provider = "postgresql"
24
+ url = env("DATABASE_URL")
25
+ }
26
+
27
+ /// comment=This is your Prisma schema file,
28
+ model User {
29
+ /// comment=This is your id field,
30
+ id Int @id @default(autoincrement())
31
+ role String
32
+ email String? @unique
33
+ password String?
34
+ registered DateTime @default(now())
35
+ lastLoginDate DateTime?
36
+ firstName String?
37
+ lastName String?
38
+ phone String?
39
+ phoneCode Int?
40
+ phoneShort String?
41
+ profilePicUrl String? @db.VarChar(2083)
42
+ forgotPasswordKey String? @unique
43
+ affiliateSlug String? @unique
44
+ closed DateTime?
45
+ closedReason String?
46
+ usercomLastSynced DateTime?
47
+ extraData Json @default("{}")
48
+ referrerId Int?
49
+ affiliateLinks AffiliateLink[]
50
+ logs Log[]
51
+ paymentTransactions PaymentTransaction[]
52
+ assignedBrands Brand[]
53
+ brandProfiles BrandUserProfile[]
54
+ campaignPins CampaignPin[]
55
+ creatorProfile CreatorProfile?
56
+ facebookProfile FacebookProfile?
57
+ instagramProfile InstagramProfile?
58
+ messages Message[]
59
+ optIns OptIn[]
60
+ rakutenActivity RakutenActivity[]
61
+ socialPosts SocialPost[]
62
+ socialProfiles SocialProfile[]
63
+ tiktokProfile TiktokProfile?
64
+ twitchProfile TwitchProfile?
65
+ twitterProfile TwitterProfile?
66
+ referrer User? @relation("Referrals", fields: [referrerId], references: [id])
67
+ referredUsers User[] @relation("Referrals")
68
+ youtubeProfile YoutubeProfile?
69
+
70
+ @@map("user")
71
+ }
72
+
73
+ model Log {
74
+ id Int @id @default(autoincrement())
75
+ userId Int?
76
+ data Json?
77
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
78
+ }
79
+
80
+ model CreatorProfile {
81
+ id Int @id @default(autoincrement())
82
+ country String?
83
+ region String?
84
+ birthDate DateTime?
85
+ /// deprecated
86
+ interests Json?
87
+ gender String?
88
+ shippingAddress1 String?
89
+ shippingAddress2 String?
90
+ shippingCity String?
91
+ shippingRegion String?
92
+ shippingCountry String?
93
+ shippingPostcode String?
94
+ phylloUserId String?
95
+ profileSlug String? @unique
96
+ profileSettings Json?
97
+ walletAddress String? @unique
98
+ userId Int @unique
99
+ niches CreatorToCategory[]
100
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
101
+
102
+ @@index([phylloUserId])
103
+ @@map("creatorprofile")
104
+ }
105
+
106
+ model InstagramProfile {
107
+ id Int @id @default(autoincrement())
108
+ instagramId String?
109
+ /// fields consistent accross profiles
110
+ username String
111
+ url String? @db.VarChar(2083)
112
+ profilePicUrl String? @db.VarChar(2083)
113
+ followerCount Int?
114
+ engagement Float?
115
+ lastUpdated DateTime?
116
+ fullName String?
117
+ isBusiness Boolean?
118
+ isPrivate Boolean?
119
+ isVerified Boolean?
120
+ mediaCount Int?
121
+ followingCount Int?
122
+ totalComments Int?
123
+ totalLikes Int?
124
+ avgComments Float?
125
+ avgLikes Float?
126
+ bio String?
127
+ externalUrl String? @db.VarChar(2083)
128
+ hasHighlightReels Boolean?
129
+ category String?
130
+ hasClips Boolean?
131
+ hasGuides Boolean?
132
+ hasChannel Boolean?
133
+ totalIgtvVideos Int?
134
+ /// DEPRECATED
135
+ profilePicUrlHd String? @db.VarChar(2083)
136
+ lastStoriesUpdate DateTime?
137
+ extraData Json?
138
+ phylloData Json?
139
+ audienceData Json @default("{}")
140
+ visibility String? @default("public")
141
+ userId Int? @unique
142
+ brandId Int? @unique
143
+ brand Brand? @relation(fields: [brandId], references: [id], onDelete: Cascade)
144
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
145
+
146
+ @@index([username])
147
+ @@index([instagramId])
148
+ @@map("instagramprofile")
149
+ }
150
+
151
+ model TiktokProfile {
152
+ id Int @id @default(autoincrement())
153
+ tiktokId String @unique
154
+ /// fields consistent accross profiles
155
+ username String?
156
+ url String? @db.VarChar(2083)
157
+ profilePicUrl String? @db.VarChar(2083)
158
+ followerCount Int?
159
+ engagement Float?
160
+ lastUpdated DateTime?
161
+ handle String?
162
+ nickname String?
163
+ followingCount Int?
164
+ totalComments Int?
165
+ totalLikes Int?
166
+ extraData Json?
167
+ phylloData Json?
168
+ audienceData Json @default("{}")
169
+ visibility String? @default("public")
170
+ userId Int? @unique
171
+ brandId Int? @unique
172
+ brand Brand? @relation(fields: [brandId], references: [id], onDelete: Cascade)
173
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
174
+
175
+ @@index([username])
176
+ @@map("tiktokprofile")
177
+ }
178
+
179
+ model YoutubeProfile {
180
+ id Int @id @default(autoincrement())
181
+ youtubeId String @unique
182
+ /// fields consistent accross profiles
183
+ username String
184
+ url String? @db.VarChar(2083)
185
+ profilePicUrl String? @db.VarChar(2083)
186
+ followerCount Int?
187
+ engagement Float?
188
+ lastUpdated DateTime?
189
+ followingCount Int?
190
+ fullName String?
191
+ isVerified Boolean?
192
+ subscribers Int?
193
+ description String?
194
+ country String?
195
+ totalViews Int?
196
+ totalVideos Int?
197
+ extraData Json?
198
+ phylloData Json?
199
+ audienceData Json @default("{}")
200
+ visibility String? @default("public")
201
+ userId Int? @unique
202
+ brandId Int? @unique
203
+ brand Brand? @relation(fields: [brandId], references: [id], onDelete: Cascade)
204
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
205
+
206
+ @@index([username])
207
+ @@map("youtubeprofile")
208
+ }
209
+
210
+ model TwitchProfile {
211
+ id Int @id @default(autoincrement())
212
+ twitchId String @unique
213
+ /// fields consistent accross profiles
214
+ username String @unique
215
+ url String? @db.VarChar(2083)
216
+ profilePicUrl String? @db.VarChar(2083)
217
+ followerCount Int?
218
+ engagement Float?
219
+ lastUpdated DateTime?
220
+ extraData Json?
221
+ phylloData Json?
222
+ visibility String? @default("public")
223
+ userId Int? @unique
224
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
225
+
226
+ @@map("twitchprofile")
227
+ }
228
+
229
+ model FacebookProfile {
230
+ id Int @id @default(autoincrement())
231
+ facebookId String @unique
232
+ /// fields consistent accross profiles
233
+ username String @unique
234
+ url String? @db.VarChar(2083)
235
+ profilePicUrl String? @db.VarChar(2083)
236
+ followerCount Int?
237
+ engagement Float?
238
+ lastUpdated DateTime?
239
+ extraData Json?
240
+ phylloData Json?
241
+ visibility String? @default("public")
242
+ userId Int? @unique
243
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
244
+
245
+ @@map("facebookprofile")
246
+ }
247
+
248
+ model TwitterProfile {
249
+ id Int @id @default(autoincrement())
250
+ twitterId String @unique
251
+ /// fields consistent accross profiles
252
+ username String @unique
253
+ url String? @db.VarChar(2083)
254
+ profilePicUrl String? @db.VarChar(2083)
255
+ followerCount Int?
256
+ engagement Float?
257
+ lastUpdated DateTime?
258
+ extraData Json?
259
+ phylloData Json?
260
+ visibility String? @default("public")
261
+ userId Int? @unique
262
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
263
+
264
+ @@map("twitterprofile")
265
+ }
266
+
267
+ model BrandUserProfile {
268
+ id Int @id @default(autoincrement())
269
+ userId Int
270
+ brandId Int
271
+ brand Brand @relation(fields: [brandId], references: [id], onDelete: Cascade)
272
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
273
+
274
+ @@map("branduserprofile")
275
+ }
276
+
277
+ model Brand {
278
+ id Int @id @default(autoincrement())
279
+ name String
280
+ description String?
281
+ website String
282
+ monthlyContacts Int?
283
+ monthlyReports Int?
284
+ lastContactDistribution DateTime?
285
+ logoUrl String? @db.VarChar(2083)
286
+ affiliateBaseUrl String? @db.VarChar(2083)
287
+ affiliateCommission Float?
288
+ extraData Json @default("{}")
289
+ specialistId Int?
290
+ affiliateLinks BrandAffiliateLink[]
291
+ campaignInvites CampaignInvite[]
292
+ emailTemplates EmailTemplate[]
293
+ paymentTransactions PaymentTransaction[]
294
+ dedicatedSpecialist User? @relation(fields: [specialistId], references: [id])
295
+ categories BrandToCategory[]
296
+ images BrandToImage[]
297
+ brandUsers BrandUserProfile[]
298
+ campaigns Campaign[]
299
+ creatorLists CreatorList[]
300
+ instagramProfile InstagramProfile?
301
+ messageTemplate MessageTemplate[]
302
+ reportCredits ReportCredits[]
303
+ savedfiles SavedFile[]
304
+ searchContacts SearchContacts[]
305
+ socialListeningLists SocialListeningList[]
306
+ tiktokProfile TiktokProfile?
307
+ youtubeProfile YoutubeProfile?
308
+
309
+ @@map("brand")
310
+ }
311
+
312
+ model SearchContacts {
313
+ id Int @id @default(autoincrement())
314
+ type String
315
+ prevQty Float
316
+ changeQty Float
317
+ currentQty Float
318
+ created DateTime? @default(now())
319
+ prevQtyPostId Int? @unique
320
+ brandId Int
321
+ brand Brand @relation(fields: [brandId], references: [id])
322
+ prevQtyPost SearchContacts? @relation("prevSearchQtyPostId", fields: [prevQtyPostId], references: [id])
323
+ nextQtyPost SearchContacts? @relation("prevSearchQtyPostId")
324
+
325
+ @@map("searchcontacts")
326
+ }
327
+
328
+ model ReportCredits {
329
+ id Int @id @default(autoincrement())
330
+ type String
331
+ prevQty Float
332
+ changeQty Float
333
+ currentQty Float
334
+ created DateTime? @default(now())
335
+ prevQtyPostId Int? @unique
336
+ brandId Int
337
+ brand Brand @relation(fields: [brandId], references: [id])
338
+ prevQtyPost ReportCredits? @relation("prevReportsQtyPostId", fields: [prevQtyPostId], references: [id])
339
+ nextQtyPost ReportCredits? @relation("prevReportsQtyPostId")
340
+
341
+ @@map("reportcredits")
342
+ }
343
+
344
+ model BrandToImage {
345
+ id Int @id @default(autoincrement())
346
+ brandId Int
347
+ type String
348
+ sizes BrandImage[]
349
+ brand Brand @relation(fields: [brandId], references: [id], onDelete: Cascade)
350
+
351
+ @@map("brandtoimage")
352
+ }
353
+
354
+ model BrandToCategory {
355
+ brandId Int
356
+ categoryId Int
357
+ campaign Brand @relation(fields: [brandId], references: [id], onDelete: Cascade)
358
+ category Category @relation(fields: [categoryId], references: [id])
359
+
360
+ @@id([brandId, categoryId])
361
+ @@map("brandtocategory")
362
+ }
363
+
364
+ model CreatorToCategory {
365
+ creatorProfileId Int
366
+ categoryId Int
367
+ category Category @relation(fields: [categoryId], references: [id])
368
+ creatorProfile CreatorProfile @relation(fields: [creatorProfileId], references: [id], onDelete: Cascade)
369
+
370
+ @@id([creatorProfileId, categoryId])
371
+ }
372
+
373
+ model Chat {
374
+ id Int @id @default(autoincrement())
375
+ created DateTime? @default(now())
376
+ conversationId String? @unique
377
+ metaData Json @default("{}")
378
+ optInId Int? @unique
379
+ optIn OptIn? @relation(fields: [optInId], references: [id])
380
+ messages Message[]
381
+
382
+ @@map("chat")
383
+ }
384
+
385
+ model Message {
386
+ id Int @id @default(autoincrement())
387
+ created DateTime? @default(now())
388
+ sender String
389
+ content String
390
+ read Boolean @default(false)
391
+ type String @default("text")
392
+ messageSid String?
393
+ userId Int?
394
+ chatId Int
395
+ chat Chat @relation(fields: [chatId], references: [id], onDelete: Cascade)
396
+ user User? @relation(fields: [userId], references: [id])
397
+
398
+ @@map("message")
399
+ }
400
+
401
+ model Campaign {
402
+ id Int @id @default(autoincrement())
403
+ title String
404
+ slug String? @unique
405
+ /// draft, paused, pending, private, publish, trash
406
+ status String @default("draft")
407
+ date DateTime @default(now())
408
+ publishDate DateTime?
409
+ description String?
410
+ productDescription String?
411
+ prizeDescription String?
412
+ strategy String? @default("shoutout")
413
+ socialChannel String?
414
+ socialChannels Json?
415
+ facebookReach Int?
416
+ facebookEngagement Float?
417
+ instagramReach Int?
418
+ instagramEngagement Float?
419
+ youtubeReach Int?
420
+ youtubeEngagement Float?
421
+ twitterReach Int?
422
+ twitterEngagement Float?
423
+ tiktokReach Int?
424
+ tiktokEngagement Float?
425
+ twitchReach Int?
426
+ twitchEngagement Float?
427
+ quantity Int @default(0)
428
+ holdCost Float?
429
+ value Float?
430
+ paidAmount Float?
431
+ minAge Int?
432
+ maxAge Int?
433
+ visuals String?
434
+ photoTags Json?
435
+ hashtags Json?
436
+ storyHashtags Json?
437
+ storyMentions Json?
438
+ caption String?
439
+ password String?
440
+ contentFormats Json?
441
+ paidCampaign Boolean?
442
+ minPaidAmount Float?
443
+ maxPaidAmount Float?
444
+ paymentType String?
445
+ /// Redundant/Deprecated
446
+ monthlyActivatedGoal Int?
447
+ /// Redundant/Deprecated
448
+ expectedOptIns Int?
449
+ goalActivations Float?
450
+ goalOptIns Float?
451
+ requiresShipping Boolean?
452
+ disableQualifications Boolean?
453
+ disableActivations Boolean?
454
+ affiliateLinkPath String?
455
+ metaData Json @default("{}")
456
+ brandId Int
457
+ campaignInvites CampaignInvite[]
458
+ variables Variable[]
459
+ brand Brand @relation(fields: [brandId], references: [id], onDelete: Cascade)
460
+ campaignPins CampaignPin[]
461
+ steps CampaignStep[]
462
+ categories CampaignToCategory[]
463
+ countries CampaignToCountry[]
464
+ images CampaignToImage[]
465
+ creatorLists CreatorList[]
466
+ optIns OptIn[]
467
+ optInViews OptInView[]
468
+ socialPosts SocialPost[]
469
+
470
+ @@map("campaign")
471
+ }
472
+
473
+ model CampaignPin {
474
+ id Int @id @default(autoincrement())
475
+ userId Int
476
+ campaignId Int
477
+ created DateTime @default(now())
478
+ notified DateTime?
479
+ campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
480
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
481
+
482
+ @@map("campaignpin")
483
+ }
484
+
485
+ model CampaignToImage {
486
+ id Int @id @default(autoincrement())
487
+ campaignId Int
488
+ type String
489
+ campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
490
+ sizes Image[]
491
+
492
+ @@map("campaigntoimage")
493
+ }
494
+
495
+ model CampaignToCategory {
496
+ campaignId Int
497
+ categoryId Int
498
+ campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
499
+ category Category @relation(fields: [categoryId], references: [id])
500
+
501
+ @@id([campaignId, categoryId])
502
+ @@map("campaigntocategory")
503
+ }
504
+
505
+ model CampaignToCountry {
506
+ campaignId Int
507
+ countryId Int
508
+ campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
509
+ country Country @relation(fields: [countryId], references: [id])
510
+
511
+ @@id([campaignId, countryId])
512
+ @@map("campaigntocountry")
513
+ }
514
+
515
+ model Variable {
516
+ id Int @id @default(autoincrement())
517
+ title String
518
+ description String?
519
+ metaData Json @default("{}")
520
+ campaignId Int
521
+ optInVariables OptInVariable[]
522
+ campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
523
+ options VariableOption[]
524
+ }
525
+
526
+ model VariableOption {
527
+ id Int @id @default(autoincrement())
528
+ title String
529
+ description String?
530
+ metaData Json @default("{}")
531
+ variableId Int
532
+ optInVariables OptInVariable[]
533
+ variable Variable @relation(fields: [variableId], references: [id], onDelete: Cascade)
534
+ }
535
+
536
+ model Step {
537
+ id Int @id @default(autoincrement())
538
+ slug String @unique
539
+ title String?
540
+ description String?
541
+ data Json?
542
+ campaignSteps CampaignStep[]
543
+
544
+ @@map("step")
545
+ }
546
+
547
+ model CampaignStep {
548
+ id Int @id @default(autoincrement())
549
+ placement Int
550
+ stepSettings Json?
551
+ actionee String?
552
+ instructions String?
553
+ customStepTitle String?
554
+ customForm Json?
555
+ metaData Json @default("{}")
556
+ campaignId Int
557
+ stepId Int?
558
+ campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
559
+ step Step? @relation(fields: [stepId], references: [id])
560
+ currentOptIns OptIn[]
561
+ optInSteps OptInStep[]
562
+
563
+ @@map("campaignstep")
564
+ }
565
+
566
+ model OptInStep {
567
+ id Int @id @default(autoincrement())
568
+ completed DateTime?
569
+ data Json?
570
+ optInId Int
571
+ campaignStepId Int
572
+ /// temporary for moving shoutoutData to socialPosts
573
+ socialPostId Int?
574
+ campaignStep CampaignStep @relation(fields: [campaignStepId], references: [id], onDelete: Cascade)
575
+ optIn OptIn @relation(fields: [optInId], references: [id], onDelete: Cascade)
576
+
577
+ @@map("optinstep")
578
+ }
579
+
580
+ model Category {
581
+ id Int @id @default(autoincrement())
582
+ slug String @unique
583
+ title String
584
+ creators CreatorToCategory[]
585
+ brands BrandToCategory[]
586
+ campaigns CampaignToCategory[]
587
+
588
+ @@map("category")
589
+ }
590
+
591
+ model OptIn {
592
+ id Int @id @default(autoincrement())
593
+ status String @default("pending")
594
+ created DateTime @default(now())
595
+ activated DateTime?
596
+ completed DateTime?
597
+ cancelled DateTime?
598
+ cancelledData Json @default("{}")
599
+ cancelRequested DateTime?
600
+ reinvited DateTime?
601
+ seen Boolean @default(false)
602
+ instructions String?
603
+ paymentAmount Float?
604
+ paymentStatus String @default("pending")
605
+ extraData Json @default("{}")
606
+ userId Int
607
+ campaignId Int
608
+ currentStepId Int?
609
+ campaignInvites CampaignInvite?
610
+ variables OptInVariable[]
611
+ chat Chat?
612
+ campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
613
+ currentStep CampaignStep? @relation(fields: [currentStepId], references: [id])
614
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
615
+ optInSteps OptInStep[]
616
+
617
+ @@map("optin")
618
+ }
619
+
620
+ model OptInVariable {
621
+ id Int @id @default(autoincrement())
622
+ optInId Int
623
+ variableId Int
624
+ selectedOptionId Int
625
+ optIn OptIn @relation(fields: [optInId], references: [id], onDelete: Cascade)
626
+ selectedOption VariableOption @relation(fields: [selectedOptionId], references: [id], onDelete: Cascade)
627
+ variable Variable @relation(fields: [variableId], references: [id], onDelete: Cascade)
628
+ }
629
+
630
+ model SocialPost {
631
+ id Int @id @default(autoincrement())
632
+ phylloId String? @unique
633
+ metaData Json @default("{}")
634
+ /// DEPRECATED, USE metaData instead, seems to be an error when attempting to remove this field, proabably due to table size
635
+ data Json @default("{}")
636
+ lastFetched DateTime?
637
+ lastWebhook DateTime?
638
+ /// TODO: this field is here because prisma doesn't support comparing one column to another, ideally we could just check if lastFetched > lastWebhook but for now we need to control/check this field
639
+ isStale Boolean?
640
+ /// BASIC INFO
641
+ posted DateTime?
642
+ title String?
643
+ description String?
644
+ url String? @db.VarChar(2083)
645
+ /// This is here so we have some external identifier to quickly search by
646
+ urlPath String? @unique
647
+ format String?
648
+ type String?
649
+ platform String?
650
+ visibility String?
651
+ isSponsored Boolean?
652
+ hasCollaborators Boolean?
653
+ isOwnedByUser Boolean?
654
+ /// METRICS
655
+ views Int?
656
+ impressions Int?
657
+ impressionsOrganic Int?
658
+ impressionsPaid Int?
659
+ reach Int?
660
+ reachOrganic Int?
661
+ reachPaid Int?
662
+ watchHours Float?
663
+ /// ENGAGEMENT METRICS
664
+ likes Int?
665
+ dislikes Int?
666
+ comments Int?
667
+ saves Int?
668
+ shares Int?
669
+ userId Int?
670
+ campaignId Int?
671
+ lists ListToSocialPost[]
672
+ campaign Campaign? @relation(fields: [campaignId], references: [id])
673
+ user User? @relation(fields: [userId], references: [id])
674
+ socialPostTags SocialPostTag[]
675
+
676
+ @@index([isStale])
677
+ @@map("socialpost")
678
+ }
679
+
680
+ model SocialPostTag {
681
+ id Int @id @default(autoincrement())
682
+ title String
683
+ type String
684
+ socialPostId Int
685
+ socialPost SocialPost @relation(fields: [socialPostId], references: [id])
686
+
687
+ @@index([title, type])
688
+ @@map("socialposttag")
689
+ }
690
+
691
+ model Image {
692
+ id Int @id @default(autoincrement())
693
+ url String @db.VarChar(2083)
694
+ size String
695
+ campaignImageId Int
696
+ campaignImage CampaignToImage @relation(fields: [campaignImageId], references: [id], onDelete: Cascade)
697
+
698
+ @@map("image")
699
+ }
700
+
701
+ model BrandImage {
702
+ id Int @id @default(autoincrement())
703
+ url String @db.VarChar(2083)
704
+ size String
705
+ brandImageId Int
706
+ brandImage BrandToImage @relation(fields: [brandImageId], references: [id], onDelete: Cascade)
707
+
708
+ @@map("brandimage")
709
+ }
710
+
711
+ model Country {
712
+ id Int @id @default(autoincrement())
713
+ countryCode String @unique @db.VarChar(2)
714
+ countryName String @db.VarChar(500)
715
+ teleCode String @db.VarChar(10)
716
+ campaigns CampaignToCountry[]
717
+ states State[]
718
+
719
+ @@map("country")
720
+ }
721
+
722
+ model State {
723
+ id Int @id @default(autoincrement())
724
+ countryId Int
725
+ stateCode String @db.VarChar(50)
726
+ stateName String @db.VarChar(500)
727
+ country Country @relation(fields: [countryId], references: [id])
728
+
729
+ @@map("state")
730
+ }
731
+
732
+ model PaymentTransaction {
733
+ id Int @id @default(autoincrement())
734
+ amount Float
735
+ balance Float
736
+ type String
737
+ date DateTime @default(now())
738
+ notes String?
739
+ metaData Json @default("{}")
740
+ accountId Int
741
+ brandId Int?
742
+ creatorId Int?
743
+ prevTransactionId Int? @unique
744
+ brand Brand? @relation(fields: [brandId], references: [id])
745
+ creator User? @relation(fields: [creatorId], references: [id])
746
+ prevTransaction PaymentTransaction? @relation("TransactionHistory", fields: [prevTransactionId], references: [id])
747
+ nextTransaction PaymentTransaction? @relation("TransactionHistory")
748
+ }
749
+
750
+ model BrandAffiliateLink {
751
+ id Int @id @default(autoincrement())
752
+ created DateTime @default(now())
753
+ description String?
754
+ urlPath String
755
+ commission Float @default(0.2)
756
+ metaData Json @default("{}")
757
+ brandId Int
758
+ affiliateLinks AffiliateLink[]
759
+ brand Brand @relation(fields: [brandId], references: [id])
760
+ }
761
+
762
+ model AffiliateLink {
763
+ id Int @id @default(autoincrement())
764
+ created DateTime @default(now())
765
+ metaData Json @default("{}")
766
+ userId Int
767
+ brandAffiliateLinkId Int
768
+ affiliateClicks AffiliateClick[]
769
+ brandAffiliateLink BrandAffiliateLink @relation(fields: [brandAffiliateLinkId], references: [id])
770
+ affiliate User @relation(fields: [userId], references: [id])
771
+ }
772
+
773
+ model AffiliateClick {
774
+ id Int @id @default(autoincrement())
775
+ created DateTime @default(now())
776
+ visitorIp String?
777
+ metaData Json @default("{}")
778
+ affiliateLinkId Int
779
+ affiliateLink AffiliateLink @relation(fields: [affiliateLinkId], references: [id])
780
+ affiliateEvent AffiliateEvent[]
781
+ }
782
+
783
+ model AffiliateEvent {
784
+ id Int @id @default(autoincrement())
785
+ /// click, purchase, etc.
786
+ event String
787
+ created DateTime @default(now())
788
+ visitorIp String?
789
+ urlPath String?
790
+ revenue Float?
791
+ commissionAmount Float?
792
+ commissionPercent Float?
793
+ metaData Json @default("{}")
794
+ affiliateClickId Int
795
+ affiliateClick AffiliateClick @relation(fields: [affiliateClickId], references: [id])
796
+ }
797
+
798
+ model SavedFile {
799
+ id Int @id @default(autoincrement())
800
+ title String?
801
+ /// audience-report, search-export, campaign-invite
802
+ type String?
803
+ url String?
804
+ savedDate DateTime?
805
+ metaData Json? @default("{}")
806
+ brandId Int?
807
+ brand Brand? @relation(fields: [brandId], references: [id])
808
+
809
+ @@map("savedfile")
810
+ }
811
+
812
+ model CampaignInvite {
813
+ id Int @id @default(autoincrement())
814
+ socialProfileId Int?
815
+ brandId Int
816
+ campaignId Int?
817
+ optInId Int? @unique
818
+ code String? @unique
819
+ createdAt DateTime @default(now())
820
+ metaData Json? @default("{}")
821
+ brand Brand @relation(fields: [brandId], references: [id], onDelete: Cascade)
822
+ campaign Campaign? @relation(fields: [campaignId], references: [id])
823
+ optIn OptIn? @relation(fields: [optInId], references: [id])
824
+ socialProfile SocialProfile? @relation(fields: [socialProfileId], references: [id])
825
+ }
826
+
827
+ model CreatorList {
828
+ id Int @id @default(autoincrement())
829
+ brandId Int
830
+ campaignId Int?
831
+ created DateTime @default(now())
832
+ archived DateTime?
833
+ title String
834
+ metaData Json? @default("{}")
835
+ brand Brand @relation(fields: [brandId], references: [id], onDelete: Cascade)
836
+ campaign Campaign? @relation(fields: [campaignId], references: [id])
837
+ creators CreatorListItem[]
838
+
839
+ @@map("creatorlist")
840
+ }
841
+
842
+ model CreatorListItem {
843
+ id Int @id @default(autoincrement())
844
+ socialProfileId Int
845
+ creatorListId Int
846
+ saved DateTime @default(now())
847
+ invited DateTime?
848
+ tags Json?
849
+ feedback String?
850
+ archived DateTime?
851
+ metaData Json? @default("{}")
852
+ creatorList CreatorList @relation(fields: [creatorListId], references: [id], onDelete: Cascade)
853
+ socialProfile SocialProfile @relation(fields: [socialProfileId], references: [id], onDelete: Cascade)
854
+
855
+ @@map("creatorlistitem")
856
+ }
857
+
858
+ model SocialProfile {
859
+ id Int @id @default(autoincrement())
860
+ /// need to make sure this can never overlap across multiple platforms, we should append the platform to the beginning to ensure it’s always unique
861
+ socialId String? @unique
862
+ /// registered user id, if available
863
+ userId Int?
864
+ /// social data
865
+ platform String
866
+ username String
867
+ fullname String?
868
+ profileUrl String?
869
+ /// need to specify length, default size is too small
870
+ profilePicUrl String? @db.VarChar(2083)
871
+ followerCount Int?
872
+ engagement Float?
873
+ avgViews Int?
874
+ verified Boolean?
875
+ metaData Json @default("{}")
876
+ audienceData Json @default("{}")
877
+ phylloData Json @default("{}")
878
+ created DateTime @default(now())
879
+ updated DateTime?
880
+ campaignInvites CampaignInvite[]
881
+ creatorListItems CreatorListItem[]
882
+ user User? @relation(fields: [userId], references: [id])
883
+
884
+ @@index([username])
885
+ @@map("socialprofile")
886
+ }
887
+
888
+ model MessageTemplate {
889
+ id Int @id @default(autoincrement())
890
+ label String?
891
+ template String
892
+ brandId Int?
893
+ /// to save any additional data such as user defined variables
894
+ metaData Json @default("{}")
895
+ brand Brand? @relation(fields: [brandId], references: [id])
896
+
897
+ @@map("messagetemplate")
898
+ }
899
+
900
+ model EmailTemplate {
901
+ id Int @id @default(autoincrement())
902
+ label String?
903
+ subject String?
904
+ template String
905
+ brandId Int?
906
+ /// to save any additional data such as user defined variables
907
+ metaData Json @default("{}")
908
+ brand Brand? @relation(fields: [brandId], references: [id])
909
+ }
910
+
911
+ model SocialListeningList {
912
+ id Int @id @default(autoincrement())
913
+ brandId Int
914
+ /// optionally linked to a campaign
915
+ campaignId Int? @unique
916
+ created DateTime @default(now())
917
+ updated DateTime?
918
+ title String
919
+ /// sponsored posts, top posts, or recent posts
920
+ postType String
921
+ /// filters to search posts by (location, date, hashtags, mentions, etc.)
922
+ filters Json? @default("{}")
923
+ /// last time posts were fetched
924
+ lastFetched DateTime?
925
+ posts ListToSocialPost[]
926
+ brand Brand @relation(fields: [brandId], references: [id], onDelete: Cascade)
927
+
928
+ @@map("sociallisteninglist")
929
+ }
930
+
931
+ model ListToSocialPost {
932
+ id Int @id @default(autoincrement())
933
+ listId Int
934
+ postId Int
935
+ list SocialListeningList @relation(fields: [listId], references: [id], onDelete: Cascade)
936
+ socialPost SocialPost @relation(fields: [postId], references: [id], onDelete: Cascade)
937
+
938
+ @@map("listtosocialpost")
939
+ }
940
+
941
+ model OptInView {
942
+ id Int @id @default(autoincrement())
943
+ title String
944
+ filters Json @default("{}")
945
+ campaignId Int?
946
+ campaign Campaign? @relation(fields: [campaignId], references: [id])
947
+
948
+ @@map("optinview")
949
+ }
950
+
951
+ model RakutenActivity {
952
+ id Int @id @default(autoincrement())
953
+ orderId String?
954
+ metaData Json @default("{}")
955
+ created DateTime @default(now())
956
+ clicks Int?
957
+ orders Int?
958
+ sales Float?
959
+ commission Float?
960
+ advertiserId Int?
961
+ userId Int
962
+ user User @relation(fields: [userId], references: [id])
963
+
964
+ @@map("rakutenactivity")
965
+ }
966
+
967
+ model SlowQueries {
968
+ id Int @id @default(autoincrement())
969
+ model String @db.VarChar(255)
970
+ operation String @db.VarChar(255)
971
+ time Int
972
+ args Json
973
+ created_at DateTime @default(now())
974
+ completed Boolean
975
+ environment String? @db.VarChar(32)
976
+
977
+ @@map("slow_queries")
978
+ }