forked from podkrepi-bg/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
podkrepi.dbml
916 lines (786 loc) · 21.1 KB
/
podkrepi.dbml
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
//// ------------------------------------------------------
//// THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
//// ------------------------------------------------------
Project "Podkrepi.bg" {
database_type: 'PostgreSQL'
Note: ''
}
Table people {
id String [pk]
firstName String [not null]
lastName String [not null]
email String [unique]
phone String
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
newsletter Boolean [default: false]
address String
birthday DateTime
emailConfirmed Boolean [default: false]
personalNumber String [unique, note: 'Uniform Civil Number (NCN, EGN)
https://en.wikipedia.org/wiki/National_identification_number#Bulgaria']
companyId String [unique]
keycloakId String [unique]
stripeCustomerId String [unique]
picture String
profileEnabled Boolean [not null, default: true]
benefactors benefactors [not null]
beneficiaries beneficiaries [not null]
campaignFiles campaign_files [not null]
campaigns campaigns [not null]
coordinators coordinators
documents documents [not null]
donationWish donation_wishes [not null]
Donation donations [not null]
expenses expenses [not null]
infoRequests info_requests [not null]
irregularities irregularities [not null]
irregularityFiles irregularity_files [not null]
expenseFiles expense_files [not null]
organizer organizers
recurringDonations recurring_donations [not null]
supporters supporters [not null]
transfers transfers [not null]
withdrawals withdrawals [not null]
publishedNews campaign_news [not null]
newsFiles campaign_news_files [not null]
company companies
Note: 'Generic person object'
}
Table companies {
id String [pk]
companyName String [not null]
companyNumber String [unique, not null, note: 'BULSTAT Unified Identification Code (UIC)
https://psc.egov.bg/en/psc-starting-a-business-bulstat']
legalPersonName String
countryCode String
cityId String
personId String [unique]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
beneficiaries beneficiaries [not null]
Campaign campaigns [not null]
person people
affiliate affiliates
}
Table affiliates {
id String [pk]
status AffiliateStatus [not null, default: 'pending']
affiliateCode String [unique]
companyId String [unique, not null]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
company companies [not null]
donations donations [not null]
}
Table organizers {
id String [pk]
personId String [unique, not null]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
person people [not null]
beneficiaries beneficiaries [not null]
campaigns campaigns [not null]
Note: 'Organizer is the person who manages the campaign on behalf of the Beneficiary'
}
Table coordinators {
id String [pk]
personId String [unique, not null]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
person people [not null]
beneficiaries beneficiaries [not null]
campaigns campaigns [not null]
Note: 'Coordinator is the person who manages the campaign on behalf of Podkrepi.bg'
}
Table benefactors {
id String [pk]
personId String [not null]
extCustomerId String [unique, note: 'Payment provider customer id']
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
person people [not null]
Note: 'Benefactor is the person who gives money'
}
Table beneficiaries {
id String [pk]
type BeneficiaryType [not null]
personId String [note: 'Person in need when type is `individual`']
coordinatorId String
countryCode String [not null]
cityId String [not null]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
coordinatorRelation PersonRelation [default: 'none']
description String
privateData Json
publicData Json
companyId String [note: 'Company in need when type is `company`']
organizerId String [note: 'Organizer for this beneficiary']
organizerRelation PersonRelation [default: 'none']
city cities [not null]
company companies
coordinator coordinators
organizer organizers
person people
campaigns campaigns [not null]
Note: 'Beneficiary is the person who receives the benefit'
}
Table campaign_types {
id String [pk]
name String [not null]
slug String [unique, not null]
description String
parentId String
category CampaignTypeCategory [not null, default: 'others']
parent campaign_types
children campaign_types [not null]
campaigns campaigns [not null]
}
Table campaigns {
id String [pk]
state CampaignState [not null, default: 'draft']
slug String [unique, not null]
title String [not null]
essence String [not null]
coordinatorId String [not null]
beneficiaryId String [not null]
campaignTypeId String [not null]
description String
targetAmount Int [default: 0]
startDate DateTime
endDate DateTime
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
deletedAt DateTime
approvedById String
currency Currency [not null, default: 'BGN']
allowDonationOnComplete Boolean [not null, default: false]
paymentReference String [unique, not null]
organizerId String
companyId String
approvedBy people
beneficiary beneficiaries [not null]
campaignType campaign_types [not null]
coordinator coordinators [not null]
organizer organizers
company companies
campaignFiles campaign_files [not null]
donationWish donation_wishes [not null]
irregularities irregularities [not null]
outgoingTransfers transfers [not null]
incomingTransfers transfers [not null]
vaults vaults [not null]
withdrawals withdrawals [not null]
slugArchive slug_archive [not null]
campaignNews campaign_news [not null]
notificationLists notification_list [not null]
}
Table campaign_news {
id String [pk]
campaignId String [not null]
publisherId String [not null]
slug String [unique, not null]
title String [not null]
author String [not null]
sourceLink String
state CampaignNewsState [not null, default: 'draft']
createdAt DateTime [default: `now()`, not null]
publishedAt DateTime
editedAt DateTime
description String [not null]
campaign campaigns [not null]
publisher people [not null]
newsFiles campaign_news_files [not null]
}
Table notification_list {
id String [pk]
campaignId String [not null]
name String
campaign campaigns [not null]
}
Table marketing_templates {
id String [pk]
name String
}
Table unregistered_notification_consent {
id String [pk]
email String [unique, not null]
consent Boolean [not null, default: false]
}
Table email_sent_registry {
id String [pk]
email String [not null]
dateSent DateTime [not null]
campaignId String
type EmailType [not null]
}
Table slug_archive {
slug String [pk]
campaignId String [not null, note: 'Stores the id of the last campaign that has used it']
campaign campaigns [not null]
Note: 'Keeps track of previous slugs that are not used currently in any active campaign'
}
Table irregularities {
id String [pk]
campaignId String [not null]
personId String [not null]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
status IrregularityStatus [not null, default: 'initial']
reason IrregularityReason [not null, default: 'other']
description String [not null]
notifierType NotifierType [not null, default: 'other']
campaign campaigns [not null]
person people [not null]
files irregularity_files [not null]
}
Table campaign_files {
id String [pk]
filename String [not null]
campaignId String [not null]
personId String [not null]
mimetype String [not null]
role CampaignFileRole [not null]
campaign campaigns [not null]
person people [not null]
}
Table campaign_news_files {
id String [pk]
filename String [not null]
newsId String [not null]
personId String [not null]
mimetype String [not null]
role CampaignFileRole [not null]
news campaign_news [not null]
person people [not null]
}
Table irregularity_files {
id String [pk]
filename String [not null]
mimetype String [not null]
irregularityId String [not null]
uploaderId String [not null]
irregularity irregularities [not null]
uploadedBy people [not null]
}
Table info_requests {
id String [pk]
personId String [not null]
message String [not null]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
deletedAt DateTime
person people [not null]
}
Table supporters {
id String [pk]
personId String [not null]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
deletedAt DateTime
comment String
associationMember Boolean [not null, default: false]
benefactorCampaign Boolean [not null, default: false]
benefactorPlatform Boolean [not null, default: false]
companyOtherText String
companySponsor Boolean [not null, default: false]
companyVolunteer Boolean [not null, default: false]
partnerBussiness Boolean [not null, default: false]
partnerNpo Boolean [not null, default: false]
partnerOtherText String
roleAssociationMember Boolean [not null, default: false]
roleBenefactor Boolean [not null, default: false]
roleCompany Boolean [not null, default: false]
rolePartner Boolean [not null, default: false]
roleVolunteer Boolean [not null, default: false]
volunteerBackend Boolean [not null, default: false]
volunteerDesigner Boolean [not null, default: false]
volunteerDevOps Boolean [not null, default: false]
volunteerFinancesAndAccounts Boolean [not null, default: false]
volunteerFrontend Boolean [not null, default: false]
volunteerLawyer Boolean [not null, default: false]
volunteerMarketing Boolean [not null, default: false]
volunteerProjectManager Boolean [not null, default: false]
volunteerQa Boolean [not null, default: false]
volunteerSecurity Boolean [not null, default: false]
person people [not null]
}
Table cities {
id String [pk]
name String [not null]
postalCode String [unique, not null]
countryId String [not null]
countryCode countries [not null]
beneficiaries beneficiaries [not null]
}
Table countries {
id String [pk]
name String [not null]
countryCode String [unique, not null]
cities cities [not null]
}
Table vaults {
id String [pk]
currency Currency [not null, default: 'BGN']
amount Int [not null, default: 0]
campaignId String [not null]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
name String [not null, default: '']
blockedAmount Int [not null, default: 0]
campaign campaigns [not null]
donations donations [not null]
expenses expenses [not null]
recurringDonations recurring_donations [not null]
sourceTransfers transfers [not null]
targetTransfers transfers [not null]
withdraws withdrawals [not null]
}
Table donations {
id String [pk]
type DonationType [not null]
status DonationStatus [not null, default: 'initial']
provider PaymentProvider [not null, default: 'none']
targetVaultId String [not null, note: 'Vault where the funds are going']
extCustomerId String [not null, note: 'Payment provider attributes']
extPaymentIntentId String [unique, not null]
extPaymentMethodId String [not null]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
amount Int [not null, default: 0]
currency Currency [not null, default: 'BGN']
affiliateId String
personId String
billingEmail String
billingName String
chargedAmount Int [not null, default: 0]
person people
targetVault vaults [not null]
affiliate affiliates
DonationWish donation_wishes
metadata donation_metadata
}
Table donation_metadata {
donationId String [pk]
name String
createdAt DateTime [default: `now()`, not null]
extraData Json
donation donations [not null]
}
Table donation_wishes {
id String [pk]
message String [not null]
campaignId String [not null]
personId String
donationId String [unique]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
campaign campaigns [not null]
person people
donation donations
}
Table recurring_donations {
id String [pk]
status RecurringDonationStatus [not null]
vaultId String [not null]
personId String [not null]
extSubscriptionId String [not null, note: 'Payment provider Subscription id']
extCustomerId String
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
amount Int [not null, default: 0]
currency Currency [not null, default: 'BGN']
person people [not null]
sourceVault vaults [not null]
Note: 'Donate on monthly basis'
}
Table transfers {
id String [pk]
status TransferStatus [not null, default: 'initial']
currency Currency [not null]
amount Int [not null, default: 0]
reason String [not null]
sourceVaultId String [not null, note: 'Source vault']
sourceCampaignId String [not null]
targetVaultId String [not null, note: 'Destination vault']
targetCampaignId String [not null]
approvedById String
documentId String
targetDate DateTime [default: `now()`]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
approvedBy people
sourceCampaign campaigns [not null]
sourceVault vaults [not null]
targetCampaign campaigns [not null]
targetVault vaults [not null]
Note: 'Move funds from one vault to another'
}
Table withdrawals {
id String [pk]
status WithdrawStatus [not null, default: 'initial']
currency Currency [not null]
amount Int [not null, default: 0]
reason String [not null]
sourceVaultId String [not null, note: 'Source vault']
sourceCampaignId String [not null]
bankAccountId String [not null, note: 'Destination bank account']
documentId String
approvedById String
targetDate DateTime [default: `now()`]
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
approvedBy people
bankAccount bank_accounts [not null]
sourceCampaign campaigns [not null]
sourceVault vaults [not null]
Note: 'Remove funds from a vault to given bank account'
}
Table bank_accounts {
id String [pk]
status BankAccountStatus [not null, default: 'new']
ibanNumber String [not null, note: 'IBAN number']
accountHolderName String [not null, note: 'Name of account holder']
accountHolderType AccountHolderType [not null, note: 'Company or individual']
bankName String [note: 'Bank name']
bankIdCode String [note: 'Bank Identification Code, BIC/SWIFT code']
fingerprint String
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
withdraws withdrawals [not null]
}
Table bank_transactions {
id String [pk]
ibanNumber String [not null, note: 'IBAN number of the account tracked']
bankName String [not null, note: 'Bank name']
bankIdCode String [not null, note: 'Bank Identification Code, BIC/SWIFT code']
transactionDate DateTime [not null]
senderName String
recipientName String
senderIban String
recipientIban String
amount Float [not null, default: 0]
currency Currency [not null, default: 'BGN']
description String [not null]
matchedRef String
type BankTransactionType [not null]
bankDonationStatus BankDonationStatus
notified Boolean [default: false]
}
Table expenses {
id String [pk]
type ExpenseType [not null]
description String
vaultId String [not null]
documentId String
approvedById String
amount Int [not null, default: 0]
currency Currency [not null, default: 'BGN']
status ExpenseStatus [not null]
deleted Boolean [not null, default: false]
approvedBy people
document documents
vault vaults [not null]
spentAt DateTime [default: `now()`, not null]
expenseFiles expense_files [not null]
Note: 'Pay for something from a given vault'
}
Table expense_files {
id String [pk]
filename String [not null]
mimetype String [not null]
expenseId String [not null]
uploaderId String [not null]
expense expenses [not null]
uploadedBy people [not null]
}
Table documents {
id String [pk]
type DocumentType [not null]
name String [not null]
filename String [not null]
filetype String
description String
sourceUrl String [not null, note: 'Data storage source url']
ownerId String [not null, note: 'Person who uploaded the document']
owner people [not null]
expenses expenses [not null]
}
Table bank_transactions_files {
id String [pk]
filename String [not null]
mimetype String [not null]
bankTransactionsFileId String [not null]
type BankTransactionsFileType [not null, default: 'xml']
personId String [not null]
}
Enum BeneficiaryType {
individual
company
}
Enum PersonRelation {
none
parent
spouse
child
mother
father
brother
sister
friend
relative
partner
domesticPartner
manager
assistant
colleague
myself
myorg
}
Enum CampaignState {
initial
draft
pending_validation
approved
rejected
active
active_pending_validation
suspended
complete
disabled
error
deleted
}
Enum CampaignNewsState {
draft
published
}
Enum Currency {
BGN
EUR
USD
}
Enum ExpenseStatus {
pending
approved
canceled
}
Enum ExpenseType {
none
internal
operating
administrative
medical
services
groceries
transport
accommodation
shipping
utility
rental
legal
bank
advertising
other
}
Enum PaymentProvider {
none
stripe
paypal
epay
bank
cash
}
Enum DocumentType {
invoice
receipt
medical_record
other
}
Enum DonationType {
donation
corporate
}
Enum DonationStatus {
initial
invalid
incomplete
declined
waiting
cancelled
guaranteed
succeeded
deleted
refund
paymentRequested
}
Enum RecurringDonationStatus {
trialing
active
canceled
incomplete
incompleteExpired
pastDue
unpaid
}
Enum WithdrawStatus {
initial
invalid
incomplete
declined
cancelled
succeeded
}
Enum TransferStatus {
initial
invalid
incomplete
declined
cancelled
succeeded
}
Enum AccountHolderType {
individual
company
}
Enum BankAccountStatus {
new
validated
verified
verification_failed
errored
}
Enum BankTransactionType {
debit
credit
}
Enum BankDonationStatus {
unrecognized
imported
incomplete
reImported
importFailed
}
Enum CampaignTypeCategory {
medical
charity
disasters
education
events
environment
sport
art
nature
animals
others
}
Enum AffiliateStatus {
active
pending
cancelled
rejected
}
Enum CampaignFileRole {
background
coordinator
campaignPhoto
invoice
document
profilePhoto
campaignListPhoto
beneficiaryPhoto
organizerPhoto
gallery
}
Enum IrregularityStatus {
initial
confirmed
declined
}
Enum IrregularityReason {
duplicate
inappropriate
illegalActivity
misinformation
privacyViolation
spam
irrelevant
political
discrimination
explicitContent
fraud
other
}
Enum NotifierType {
benefactor
other
}
Enum BankTransactionsFileType {
xml
other
}
Enum EmailType {
confirmConsent
confirmCampaignConsent
raised50
raised90
raised100
}
Ref: people.companyId - companies.id
Ref: affiliates.companyId - companies.id
Ref: organizers.personId - people.id
Ref: coordinators.personId - people.id
Ref: benefactors.personId > people.id
Ref: beneficiaries.cityId > cities.id
Ref: beneficiaries.companyId > companies.id
Ref: beneficiaries.coordinatorId > coordinators.id
Ref: beneficiaries.organizerId > organizers.id
Ref: beneficiaries.personId > people.id
Ref: campaign_types.parentId - campaign_types.id
Ref: campaigns.approvedById > people.id
Ref: campaigns.beneficiaryId > beneficiaries.id
Ref: campaigns.campaignTypeId > campaign_types.id [delete: Cascade]
Ref: campaigns.coordinatorId > coordinators.id
Ref: campaigns.organizerId > organizers.id
Ref: campaigns.companyId > companies.id
Ref: campaign_news.campaignId > campaigns.id
Ref: campaign_news.publisherId > people.id
Ref: notification_list.campaignId > campaigns.id
Ref: slug_archive.campaignId > campaigns.id
Ref: irregularities.campaignId > campaigns.id
Ref: irregularities.personId > people.id
Ref: campaign_files.campaignId > campaigns.id
Ref: campaign_files.personId > people.id
Ref: campaign_news_files.newsId > campaign_news.id [delete: Cascade]
Ref: campaign_news_files.personId > people.id
Ref: irregularity_files.irregularityId > irregularities.id
Ref: irregularity_files.uploaderId > people.id
Ref: info_requests.personId > people.id
Ref: supporters.personId > people.id
Ref: cities.countryId > countries.id
Ref: vaults.campaignId > campaigns.id
Ref: donations.personId > people.id
Ref: donations.targetVaultId > vaults.id
Ref: donations.affiliateId > affiliates.id
Ref: donation_metadata.donationId - donations.id
Ref: donation_wishes.campaignId > campaigns.id
Ref: donation_wishes.personId > people.id
Ref: donation_wishes.donationId - donations.id
Ref: recurring_donations.personId > people.id
Ref: recurring_donations.vaultId > vaults.id
Ref: transfers.approvedById > people.id
Ref: transfers.sourceCampaignId > campaigns.id
Ref: transfers.sourceVaultId > vaults.id
Ref: transfers.targetCampaignId > campaigns.id
Ref: transfers.targetVaultId > vaults.id
Ref: withdrawals.approvedById > people.id
Ref: withdrawals.bankAccountId > bank_accounts.id
Ref: withdrawals.sourceCampaignId > campaigns.id
Ref: withdrawals.sourceVaultId > vaults.id
Ref: expenses.approvedById > people.id
Ref: expenses.documentId > documents.id
Ref: expenses.vaultId > vaults.id
Ref: expense_files.expenseId > expenses.id
Ref: expense_files.uploaderId > people.id
Ref: documents.ownerId > people.id