-
Notifications
You must be signed in to change notification settings - Fork 6
/
schema.prisma
710 lines (594 loc) · 33.6 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
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DB_URL")
}
model Cause_areas {
ID Int @id @unique(map: "ID_UNIQUE") @default(autoincrement())
name String @unique(map: "name_UNIQUE") @db.VarChar(45)
short_desc String? @db.VarChar(255)
long_desc String? @db.VarChar(45)
info_url String? @db.VarChar(156)
is_active Int? @db.TinyInt
ordering Int? @db.TinyInt
std_percentage_share Int? @default(0) @db.TinyInt /// The percentage share of the standard distribution, determined by Effekt. Updated about twice a year
widget_display_name String? @db.VarChar(45)
widget_context String? @db.Text
Distribution_cause_areas Distribution_cause_areas[]
Organizations Organizations[]
}
model Organizations {
ID Int @id @unique(map: "ID_UNIQUE") @default(autoincrement())
cause_area_ID Int @default(1) @db.Int
full_name String @unique(map: "full_name_UNIQUE") @db.VarChar(45)
abbriv String @unique(map: "abbriv_UNIQUE") @db.VarChar(10)
short_desc String? @db.VarChar(255)
long_desc String @db.VarChar(45)
info_url String? @db.VarChar(156)
widget_display_name String? @db.VarChar(45)
widget_context String? @db.Text
std_percentage_share Int? @default(0) @db.TinyInt /// The percentage share of the standard distribution, determined by Effekt. Updated about twice a year
is_active Int? @db.TinyInt
ordering Int? @db.TinyInt
Cause_areas Cause_areas @relation(fields: [cause_area_ID], references: [ID], onDelete: Cascade, map: "fk_Organizations_to_Cause_areas_idx")
Distribution_cause_area_organizations Distribution_cause_area_organizations[]
Adoveo_fundraiser_org_shares Adoveo_fundraiser_org_shares[]
Adoveo_giftcard_org_shares Adoveo_giftcard_org_shares[]
}
model AvtaleGiro_replaced_distributions {
Original_AvtaleGiro_KID String @db.VarChar(15)
Replacement_KID String @id @db.VarChar(15)
Timestamp DateTime? @default(now()) @db.DateTime(0)
DistributionsOriginal Distributions @relation(name: "Original", fields: [Original_AvtaleGiro_KID], references: [KID], onDelete: Cascade, map: "fk_AvtaleGiro_replaced_distributions_to_Distributions_idx")
DistributionsReplacement Distributions @relation(name: "Replacement", fields: [Replacement_KID], references: [KID], onDelete: Cascade, map: "fk_AvtaleGiro_replaced_distributions_to_Distributions_idx2")
}
model AutoGiro_replaced_distributions {
Original_AutoGiro_KID String @db.VarChar(15)
Replacement_KID String @id @db.VarChar(15)
Timestamp DateTime? @default(now()) @db.DateTime(0)
DistributionsOriginal Distributions @relation(name: "Original", fields: [Original_AutoGiro_KID], references: [KID], onDelete: Cascade, map: "fk_AutoGiro_replaced_distributions_to_Distributions_idx")
DistributionsReplacement Distributions @relation(name: "Replacement", fields: [Replacement_KID], references: [KID], onDelete: Cascade, map: "fk_AutoGiro_replaced_distributions_to_Distributions_idx2")
}
model Avtalegiro_agreements {
ID Int @id @default(autoincrement())
KID String @db.VarChar(15)
amount Int
payment_date Int
notice Boolean
active Boolean @default(false)
last_updated DateTime? @default(now()) @db.DateTime(0)
created DateTime? @default(now()) @db.DateTime(0)
cancelled DateTime? @db.Date
// If we delete a distribution there should be no agreements with that distribution. Therefore we restrict on deletion of a distribution.
Distributions Distributions @relation(fields: [KID], references: [KID], onDelete: Restrict, map: "fk_Avtalegiro_agreements_to_Distributions_idx")
Recurring_agreement_stopped Recurring_agreement_stopped[]
}
model Avtalegiro_conversion_reminders {
ID Int @id @default(autoincrement())
KID String @unique(map: "KID_UNIQUE") @db.VarChar(45)
NumReminders Int @default(0)
LastReminderSent DateTime? @db.DateTime(0)
Distributions Distributions @relation(fields: [KID], references: [KID], onDelete: Cascade, map: "fk_Avtalegiro_conversion_reminders_to_Distributions_idx")
}
model Avtalegiro_shipment {
ID Int @id @default(autoincrement())
num_claims Int?
generated DateTime? @default(now()) @db.DateTime(0)
}
model AutoGiro_agreements {
ID Int @id @default(autoincrement())
mandateID Int @unique(map: "mandateID_UNIQUE") @db.Int
KID String @unique(map: "KID_UNIQUE") @db.VarChar(16)
amount Int
payment_date Int
notice Boolean
active Boolean @default(false)
last_updated DateTime? @default(now()) @db.DateTime(0)
created DateTime? @default(now()) @db.DateTime(0)
cancelled DateTime? @db.Date
mandate AutoGiro_mandates @relation(fields: [mandateID], references: [ID], onDelete: Restrict, onUpdate: Cascade)
Recurring_agreement_stopped Recurring_agreement_stopped[]
}
model AutoGiro_shipments {
ID Int @id @default(autoincrement())
num_charges Int
sent_date DateTime? @default(now()) @db.DateTime(0)
last_updated DateTime? @default(now()) @db.DateTime(0)
created DateTime? @default(now()) @db.DateTime(0)
charges AutoGiro_agreement_charges[]
}
model AutoGiro_agreement_charges {
ID Int @id @default(autoincrement())
agreementID Int
shipmentID Int
donationID Int? @unique
status String
amount String
claim_date DateTime?
last_updated DateTime? @default(now()) @db.DateTime(0)
created DateTime? @default(now()) @db.DateTime(0)
donation Donations? @relation(fields: [donationID], references: [ID], onDelete: Restrict, onUpdate: Cascade)
shipment AutoGiro_shipments @relation(fields: [shipmentID], references: [ID], onDelete: Restrict, onUpdate: Cascade)
}
model AutoGiro_mandates {
ID Int @id @default(autoincrement())
status String
last_updated DateTime? @default(now()) @db.DateTime(0)
created DateTime? @default(now()) @db.DateTime(0)
bank_account String? @db.VarChar(16)
special_information String?
name_and_address String?
postal_code String?
postal_label String?
KID String @unique @db.VarChar(16) // This binds mandates to both donor and tax units (SSN)
agreements AutoGiro_agreements?
}
model Recurring_agreement_stopped_reasons {
ID Int @id @default(autoincrement())
name String @unique @db.VarChar(45)
isOther Boolean @default(false)
order Int @default(99)
Recurring_agreement_stopped Recurring_agreement_stopped[]
}
model Recurring_agreement_stopped {
ID Int @id @default(autoincrement())
avtalegiroAgreementID Int? @db.Int
autoGiroAgreementID Int? @db.Int
vippsAgreementID String? @db.VarChar(20)
reasonID Int
otherComment String? @db.Text
timestamp DateTime? @default(now()) @db.DateTime(0)
last_updated DateTime? @default(now()) @db.DateTime(0)
reason Recurring_agreement_stopped_reasons @relation(fields: [reasonID], references: [ID], onDelete: Restrict, onUpdate: Cascade)
avtalegiro Avtalegiro_agreements? @relation(fields: [avtalegiroAgreementID], references: [ID], onDelete: SetNull, onUpdate: Cascade)
autoGiro AutoGiro_agreements? @relation(fields: [autoGiroAgreementID], references: [ID], onDelete: SetNull, onUpdate: Cascade)
vipps Vipps_agreements? @relation(fields: [vippsAgreementID], references: [ID], onDelete: SetNull, onUpdate: Cascade)
}
model Distributions {
KID String @id @db.VarChar(16)
Donor_ID Int
Tax_unit_ID Int? @default(0)
Meta_owner_ID Int @default(3)
Replaced_old_organizations Boolean? @default(false)
inserted DateTime? @default(now()) @db.DateTime(0)
last_updated DateTime? @default(now()) @db.DateTime(0)
Donors Donors @relation(fields: [Donor_ID], references: [ID], onDelete: Cascade, map: "fk_Distributions_to_Donors_idx")
Tax_unit Tax_unit? @relation(fields: [Tax_unit_ID], references: [ID], onDelete: SetNull, map: "fk_Distributions_to_Tax_unit_idx")
Data_owner Data_owner @relation(fields: [Meta_owner_ID], references: [ID], onDelete: Restrict, map: "fk_Distributions_to_Data_owner_idx")
Avtalgiro_agreements Avtalegiro_agreements[]
AvtaleGiro_replaced_distributions_original AvtaleGiro_replaced_distributions[] @relation(name: "Original")
AvtaleGiro_replaced_distributions_replacement AvtaleGiro_replaced_distributions[] @relation(name: "Replacement")
AutoGiro_replaced_distributions_original AutoGiro_replaced_distributions[] @relation(name: "Original")
AutoGiro_replaced_distributions_replacement AutoGiro_replaced_distributions[] @relation(name: "Replacement")
Avtalegiro_conversion_reminders Avtalegiro_conversion_reminders[]
Distribution_cause_areas Distribution_cause_areas[]
Donations Donations[]
Payment_intent Payment_intent[]
Paypal_historic_distributions Paypal_historic_distributions[]
Vipps_agreement_charges Vipps_agreement_charges[]
Vipps_agreements Vipps_agreements[]
Vipps_orders Vipps_orders[]
Swish_orders Swish_orders[]
Vipps_matching_rules Vipps_matching_rules[]
}
model Distribution_cause_areas {
ID Int @id @unique(map: "ID_UNIQUE") @default(autoincrement())
Distribution_KID String @db.VarChar(16)
Cause_area_ID Int @db.Int
Percentage_share Decimal @db.Decimal(18, 15)
Standard_split Boolean @default(false)
// This is the link to the specific distribtion. If we delete a distribution it should cascade from Distribution -> Distribution_cause_areas -> Distribution_cause_area_organizations to clean up everything.
Distributions Distributions @relation(fields: [Distribution_KID], references: [KID], onDelete: Cascade, map: "fk_Distribution_cause_areas_to_Distributions_idx")
// Restrict deletion of cause areas. If we delete a cause area there should be no distributions with that cause area.
Cause_areas Cause_areas @relation(fields: [Cause_area_ID], references: [ID], onDelete: Restrict, map: "fk_Distribution_cause_areas_to_Cause_areas_idx")
Distribution_cause_area_organizations Distribution_cause_area_organizations[]
}
model Distribution_cause_area_organizations {
ID Int @id @unique(map: "ID_UNIQUE") @default(autoincrement())
Distribution_cause_area_ID Int @db.Int
Organization_ID Int @db.Int
Percentage_share Decimal @db.Decimal(18, 15)
// This is the link to the cause area for a specific distribution. If we delete a distribution it should cascade from Distribution -> Distribution_cause_areas -> Distribution_cause_area_organizations to clean up everything.
Distribution_cause_areas Distribution_cause_areas @relation(fields: [Distribution_cause_area_ID], references: [ID], onDelete: Cascade, map: "fk_Distribution_ca_organizations_to_Distribution_ca_idx")
// Restrict deletion of organization. If we delete an organization there should be no distributions with that organization.
Organizations Organizations @relation(fields: [Organization_ID], references: [ID], onDelete: Restrict, map: "fk_Distribution_cause_area_organizations_to_Organizations_idx")
}
model Data_owner {
ID Int @id @unique(map: "ID_UNIQUE") @default(autoincrement())
owner String @unique(map: "owner_UNIQUE") @db.VarChar(128)
default Boolean @default(false)
Distributions Distributions[]
}
model Donations {
ID Int @id @unique(map: "ID_UNIQUE") @default(autoincrement()) /// Unik donasjonsID
Donor_ID Int /// Foreign key til donor_id
Payment_ID Int /// Foreign key til Payment_ID
PaymentExternal_ID String? @unique(map: "PaymentExternal_ID_UNIQUE") @db.VarChar(32) /// Payment ID in external system (ex: Vipps)
sum_confirmed Decimal @db.Decimal(16, 2) /// Donert sum bekreftet fra betalingstjeneste (NOK)
timestamp_confirmed DateTime @default(now()) @db.Timestamp(0) /// Timestamp/dato når donasjon er bekreftet fra betalingstjeneste
transaction_cost Decimal? @db.Decimal(16, 2) /// beregnet transaction cost basert på Payment_ID (oppslag på kostnad) og sum confirmed
KID_fordeling String @db.VarChar(16) /// Same as KID. Used to join to Combining_table for distribution percentages (registrert KID fra betalingstjeneste, oppslag i donations_distribution for Donor_ID)
inserted DateTime? @default(now()) @db.Timestamp(0)
last_updated DateTime? @default(now()) @db.Timestamp(0)
Meta_owner_ID Int @default(3)
Donors Donors @relation(fields: [Donor_ID], references: [ID], onDelete: Cascade, map: "fk_Donations_to_Donors_ID")
Payment Payment @relation(fields: [Payment_ID], references: [ID], onDelete: Cascade, map: "fk_Donations_to_Payment")
Swish_orders Swish_orders?
Adoveo_fundraiser_transactions Adoveo_fundraiser_transactions?
Adoveo_giftcard_transactions Adoveo_giftcard_transactions?
AutoGiro_agreement_charges AutoGiro_agreement_charges?
LegacySeDistributionConnection LegacySeDistributionConnection?
// When we delete a distribution we delete the associated donations.
Distributions Distributions @relation(fields: [KID_fordeling], references: [KID], onDelete: Cascade, map: "fk_Donations_to_Distributions_KID")
Vipps_orders Vipps_orders[]
@@index([KID_fordeling, timestamp_confirmed], map: "KidAndTimestamp")
@@index([timestamp_confirmed], map: "Timestamp")
@@index([Donor_ID], map: "fk_Donations_Donors_KID_idx")
@@index([Payment_ID], map: "fk_Donations_to_Donors_idx")
}
model Donors {
ID Int @id @unique(map: "KID_UNIQUE") @default(autoincrement()) /// Unik kundeID
email String @unique(map: "email_UNIQUE", length: 63) @db.TinyText /// epost registrert i donasjonsskjema,\ntrigger generering av ny donor hvis den ikke eksisterer fra før
full_name String? @db.TinyText
date_registered DateTime @default(now()) @db.Timestamp(0) /// The date the donor first registrered
Meta_owner_ID Int @default(3)
newsletter Boolean?
trash Int? @db.TinyInt
Donations Donations[]
Distributions Distributions[]
FB_payment_ID FB_payment_ID[]
Funds_donations Funds_donations[]
Tax_unit Tax_unit[]
Vipps_agreements Vipps_agreements[]
Swish_orders Swish_orders[]
Paypal_historic_distributions Paypal_historic_distributions[]
Referral_records Referral_records[]
Vipps_orders Vipps_orders[]
Mailersend_survey_responses Mailersend_survey_responses[]
Adoveo_fundraiser Adoveo_fundraiser[]
Adoveo_giftcard_transactions_sender Adoveo_giftcard_transactions[] @relation(name: "senderDonor")
Adoveo_giftcard_transactions_receiver Adoveo_giftcard_transactions[] @relation(name: "receiverDonor")
@@index([full_name(length: 63)], map: "full_name")
@@index([email(length: 63), full_name(length: 63)], map: "search")
}
model FB_campaign_org_shares {
ID Int @id @default(autoincrement())
FB_campaign_ID String @db.VarChar(20)
Org_ID Int
Share Decimal @db.Decimal(18, 15)
Standard_split Boolean?
@@index([Org_ID], map: "fk_FB_campaign_org_shares_1_idx")
@@index([FB_campaign_ID], map: "fk_FB_campaign_org_shares_2_idx")
}
model FB_campaigns {
ID String @id @db.VarChar(20)
Fundraiser_title String @db.VarChar(150)
Source_name String @db.VarChar(45)
Permalink String @db.VarChar(100)
Campaign_owner_name String @db.VarChar(45)
Fundraiser_type String @db.VarChar(45)
}
model FB_donation_reports {
ID Int @id @default(autoincrement())
FB_report Bytes
}
model FB_payment_ID {
ID Int @id @default(autoincrement())
donorID Int
paymentID String @db.VarChar(45)
inserted DateTime @default(now()) @db.Timestamp(0)
taxUnitID Int
Donors Donors @relation(fields: [donorID], references: [ID], onDelete: Cascade, map: "donorID")
Tax_unit Tax_unit @relation(fields: [taxUnitID], references: [ID], onDelete: Cascade, map: "fk_fbpayment_to_taxunit")
@@index([donorID], map: "donorID_idx")
@@index([taxUnitID], map: "fk_fbpayment_to_taxunit_idx")
}
model LegacySeDistributionConnection {
ID Int @id @default(autoincrement())
paymentID String @unique @db.VarChar(32)
legacyKID String @db.VarChar(16)
Donations Donations @relation(fields: [paymentID], references: [PaymentExternal_ID], onDelete: Restrict, map: "fk_LegacySeDistributionConnection_to_Donations_idx")
}
model Adoveo_fundraiser {
ID Int @id @default(autoincrement())
Donor_ID Int?
Name String @db.VarChar(45)
Adoveo_ID Int? @unique
Last_import DateTime? @default(now()) @db.DateTime(0)
Created DateTime @default(now()) @db.DateTime(0)
Last_updated DateTime @default(now()) @db.DateTime(0)
Donors Donors? @relation(fields: [Donor_ID], references: [ID], onDelete: SetNull, onUpdate: Cascade, map: "FK_Adoveo_fundraiser_donorid")
Adoveo_fundraiser_transactions Adoveo_fundraiser_transactions[]
Adoveo_fundraiser_org_shares Adoveo_fundraiser_org_shares[]
}
model Adoveo_fundraiser_org_shares {
ID Int @id @default(autoincrement())
Fundraiser_ID Int
Org_ID Int
Share Decimal @db.Decimal(18, 15)
Standard_split Boolean?
Created DateTime @default(now()) @db.DateTime(0)
Last_updated DateTime @default(now()) @db.DateTime(0)
Fundraiser Adoveo_fundraiser @relation(fields: [Fundraiser_ID], references: [ID], onDelete: Cascade, onUpdate: Cascade, map: "FK_Adoveo_fundraiser_org_shares_fundraiserid")
Organizations Organizations @relation(fields: [Org_ID], references: [ID], onDelete: Restrict, onUpdate: Cascade, map: "FK_Adoveo_fundraiser_org_shares_orgid")
}
model Adoveo_fundraiser_transactions {
ID Int @id @default(autoincrement())
Fundraiser_ID Int
Donation_ID Int? @unique(map: "Donation_ID_UNIQUE")
Sum Decimal @db.Decimal(15, 2)
Timestamp DateTime @db.DateTime(0)
Sender_email String @db.VarChar(45)
Sender_phone String @db.VarChar(15)
Status String @db.VarChar(10)
Location String @db.VarChar(45)
Hash String @unique(map: "Hash_UNIQUE") @db.VarChar(32)
Created DateTime @default(now()) @db.DateTime(0)
Last_updated DateTime @default(now()) @db.DateTime(0)
Fundraiser Adoveo_fundraiser @relation(fields: [Fundraiser_ID], references: [ID], onDelete: Cascade, onUpdate: Cascade, map: "FK_Adoveo_fundraiser_transactions_fundraiserid")
Donations Donations? @relation(fields: [Donation_ID], references: [ID], onDelete: SetNull, map: "FK_Adoveo_fundraiser_transactions_donationid")
}
model Adoveo_giftcard {
ID Int @id @default(autoincrement())
Name String @db.VarChar(45)
Created DateTime @default(now()) @db.DateTime(0)
Last_updated DateTime @default(now()) @db.DateTime(0)
Adoveo_giftcard_org_shares Adoveo_giftcard_org_shares[]
Adoveo_giftcard_transactions Adoveo_giftcard_transactions[]
}
model Adoveo_giftcard_org_shares {
ID Int @id @default(autoincrement())
Giftcard_ID Int
Org_ID Int
Share Decimal @db.Decimal(18, 15)
Standard_split Boolean?
Created DateTime @default(now()) @db.DateTime(0)
Last_updated DateTime @default(now()) @db.DateTime(0)
Giftcard Adoveo_giftcard @relation(fields: [Giftcard_ID], references: [ID], onDelete: Cascade, onUpdate: Cascade, map: "FK_Adoveo_giftcard_org_shares_giftcardid")
Organizations Organizations @relation(fields: [Org_ID], references: [ID], onDelete: Restrict, onUpdate: Cascade, map: "FK_Adoveo_giftcard_org_shares_orgid")
}
model Adoveo_giftcard_transactions {
ID Int @id @default(autoincrement())
Donation_ID Int? @unique(map: "Donation_ID_UNIQUE")
Giftcard_ID Int
Sum Decimal @db.Decimal(15, 2)
Timestamp DateTime @db.DateTime(0)
Sender_donor_ID Int? @db.Int
Sender_name String @db.VarChar(45)
Sender_email String @db.VarChar(45)
Sender_phone String @db.VarChar(15)
Receiver_donor_ID Int? @db.Int
Receiver_name String @db.VarChar(45)
Receiver_phone String @db.VarChar(15)
Message String @db.Text
Status String @db.VarChar(10)
Location String @db.VarChar(45)
CouponSend String @db.VarChar(45)
Hash String @unique(map: "Hash_UNIQUE") @db.VarChar(32)
Created DateTime @default(now()) @db.DateTime(0)
Last_updated DateTime @default(now()) @db.DateTime(0)
Donations Donations? @relation(fields: [Donation_ID], references: [ID], onDelete: SetNull, map: "FK_Adoveo_giftcard_transactions_donationid")
Adoveo_giftcard Adoveo_giftcard @relation(fields: [Giftcard_ID], references: [ID], onDelete: Cascade, onUpdate: Cascade, map: "FK_Adoveo_giftcard_transactions_giftcardid")
SenderDonor Donors? @relation(name: "senderDonor", fields: [Sender_donor_ID], references: [ID], onDelete: SetNull, map: "FK_Adoveo_giftcard_transactions_sender_donorid")
ReceiverDonor Donors? @relation(name: "receiverDonor", fields: [Receiver_donor_ID], references: [ID], onDelete: SetNull, map: "FK_Adoveo_giftcard_transactions_receiver_donorid")
}
model Funds_donations {
ID Int @id @default(autoincrement())
DonorID Int?
TaxUnitID Int?
Sum Decimal @db.Decimal(15, 2)
Timestamp DateTime @db.DateTime(0)
PaymentExternalID String @db.VarChar(45)
Donors Donors? @relation(fields: [DonorID], references: [ID], onDelete: Cascade, map: "FK_Funds_donorid")
Tax_unit Tax_unit? @relation(fields: [TaxUnitID], references: [ID], map: "FK_Funds_taxunit")
@@index([DonorID], map: "FK_Funds_donorid_idx")
@@index([TaxUnitID], map: "FK_Funds_taxunit_idx")
}
model Import_logs {
ID Int @id @default(autoincrement())
label String? @db.VarChar(45)
result Json?
timestamp DateTime? @default(now()) @db.DateTime(0)
}
model Payment {
ID Int @id @default(autoincrement())
payment_name String @unique(map: "payment_name_UNIQUE") @db.VarChar(45)
abbriv String @unique(map: "abbriv_UNIQUE") @db.VarChar(45)
short_desc String? @db.VarChar(45)
flat_fee Decimal? @db.Decimal(5, 2) /// Part of the transaction fee that is a constant number
percentage_fee Decimal? @db.Decimal(5, 2) /// Part of the transaction fee that is a share of the transaction sum
lastUpdated DateTime @default(now()) @db.Timestamp(0) /// New ID and Payment_name increment with updated fee information
Donations Donations[]
}
model Payment_intent {
Id Int @id @unique(map: "Id_UNIQUE") @default(autoincrement())
Payment_method Int? @db.Int
Payment_amount Decimal? @db.Decimal(16, 2)
KID_fordeling String? @db.VarChar(20)
timestamp DateTime? @default(now()) @db.DateTime(0)
// When we delete a distribution we save the payment intent for statistics. Simply set the KID to null.
Distributions Distributions? @relation(fields: [KID_fordeling], references: [KID], onDelete: SetNull, map: "fk_Payment_intent_to_Distributions_idx")
Payment_follow_up Payment_follow_up[]
@@index([KID_fordeling], map: "KID_fordeling_idx")
}
model Payment_follow_up {
Id Int @id @default(autoincrement())
Payment_intent_id Int
Follow_up_date DateTime @db.DateTime(0)
Payment_intent Payment_intent @relation(fields: [Payment_intent_id], references: [Id], onDelete: Cascade, map: "fk_Payment_follow_up_to_Payment_intent_idx")
}
model Paypal_historic_distributions {
ID Int @id @default(autoincrement())
Donor_ID Int @unique(map: "Donor_ID_UNIQUE")
KID String @unique(map: "KID_UNIQUE")
ReferenceTransactionNumber String @unique(map: "ReferenceTransactionNumber_UNIQUE") @db.VarChar(32)
// When we delete a donor we also delete all associated paypal historic distributions.
Donors Donors @relation(fields: [Donor_ID], references: [ID], onDelete: Cascade, map: "fk_Paypal_historic_distributions_to_Donors_idx")
// When we delete a distribution we delete the associated paypal historic distributions.
Distributions Distributions @relation(fields: [KID], references: [KID], onDelete: Cascade, map: "fk_Paypal_historic_distributions_to_Distributions_idx")
}
model Referral_records {
ID Int @id @default(autoincrement())
ReferralID Int
DonorID Int?
Registered DateTime? @default(now()) @db.DateTime(0)
other_comment String? @db.VarChar(1000)
website_session String? @db.VarChar(45)
// When deleting a donor we should not delete the referral record. We should set the donor to null.
Donors Donors? @relation(fields: [DonorID], references: [ID], onDelete: SetNull, map: "fk_Referral_records_to_Donors_idx")
// We don't allow deletion of referral types. If we delete a referral type we should not have any referral records with that type.
Referral_types Referral_types @relation(fields: [ReferralID], references: [ID], onDelete: Restrict, map: "referral_type")
@@index([ReferralID], map: "referral_type_idx")
}
model Referral_types {
ID Int @id @default(autoincrement())
name String @db.VarChar(256)
is_active Boolean @default(true)
ordering Int?
Referral_records Referral_records[]
}
model Mailersend_survey_responses {
ID Int @id @default(autoincrement())
surveyID Int
questionID Int
DonorID Int
answer String
answerID String
timestamp DateTime @default(now()) @db.DateTime(0)
Donors Donors @relation(fields: [DonorID], references: [ID], onDelete: Cascade, onUpdate: Cascade, map: "fk_Mailersend_survey_responses_to_Donors_idx")
}
model Swish_orders {
ID Int @id @default(autoincrement())
KID String @db.VarChar(15)
instructionUUID String @unique @db.VarChar(36) /// Swish uses this to identify the order
donorID Int
donationID Int? @unique
status String? /// External status from swish
reference String @db.VarChar(32)
registered DateTime @default(now()) @db.DateTime(0)
donor Donors @relation(fields: [donorID], references: [ID], onDelete: Cascade, onUpdate: Cascade)
donation Donations? @relation(fields: [donationID], references: [ID], onDelete: Cascade, onUpdate: Cascade)
Distributions Distributions @relation(fields: [KID], references: [KID], onDelete: Cascade, onUpdate: Cascade)
}
model Tax_unit {
ID Int @id @default(autoincrement())
Donor_ID Int
ssn String @db.VarChar(32)
full_name String @db.VarChar(128)
registered DateTime? @default(now()) @db.DateTime(0)
archived DateTime? @db.DateTime(0)
FB_payment_ID FB_payment_ID[]
Funds_donations Funds_donations[]
Distributions Distributions[]
// When a donor is deleted we also delete the tax unit.
Donors Donors @relation(fields: [Donor_ID], references: [ID], onDelete: Cascade, map: "FK_tax_unit_donor_id")
@@index([Donor_ID], map: "FK_tax_unit_donor_id_idx")
}
model Vipps_agreement_charges {
chargeID String @unique(map: "chargeID_UNIQUE") @db.VarChar(11)
agreementID String @db.VarChar(20)
amountNOK Int @db.UnsignedInt
KID String @db.VarChar(16)
dueDate String @db.VarChar(100)
timestamp_created DateTime? @default(now()) @db.Timestamp(0)
status String @db.VarChar(30)
type String? @db.VarChar(20)
Vipps_agreements Vipps_agreements @relation(fields: [agreementID], references: [ID], onDelete: Cascade, map: "FK_agreementID_ID")
// We don't allow deletion of a distribution with an associated vipps agreement. If we delete a distribution we should not have any vipps agreements with that distribution.
Distributions Distributions @relation(fields: [KID], references: [KID], onDelete: Restrict, map: "FK_KID_KID")
@@id([chargeID, agreementID])
@@index([agreementID], map: "FK_ID_agreementID_idx")
}
model Vipps_agreements {
ID String @id @db.VarChar(20)
donorID Int
KID String @db.VarChar(16)
amount Int
status String? @db.VarChar(30)
monthly_charge_day Int
paused_until_date String? @db.VarChar(255)
agreement_url_code String @db.VarChar(100)
timestamp_created DateTime? @default(now()) @db.Timestamp(0)
force_charge_date String? @db.VarChar(100)
cancellation_date DateTime? @db.Date
Vipps_agreement_charges Vipps_agreement_charges[]
Donors Donors @relation(fields: [donorID], references: [ID], onDelete: Cascade, map: "FK_donorID")
// We don't allow deletion of a distribution with an associated vipps agreement. If we delete a distribution we should not have any vipps agreements with that distribution.
Distributions Distributions @relation(fields: [KID], references: [KID], onDelete: Cascade, map: "FK_KID")
Recurring_agreement_stopped Recurring_agreement_stopped[]
@@index([KID], map: "KID_idx")
@@index([donorID], map: "donorID_idx")
}
model Vipps_matching_rules {
ID Int @id @default(autoincrement())
SalesLocation String? @db.VarChar(45)
Message String? @db.VarChar(45)
PeriodFrom DateTime @db.Date
PeriodTo DateTime @db.Date
ResolveKID String @db.VarChar(16)
precedence Int?
// We don't allow deletion of a distribution with an associated vipps matching rule. If we delete a distribution we should not have any vipps matching rules with that distribution.
Distributions Distributions @relation(fields: [ResolveKID], references: [KID], onDelete: Restrict, map: "fk_Vipps_matching_rules_to_Distributions_idx")
}
model Vipps_order_transaction_statuses {
ID Int @id @default(autoincrement())
orderID String @db.VarChar(256)
transactionID String? @db.VarChar(45)
amount Int
operation String @db.VarChar(45)
timestamp DateTime @db.DateTime(0)
success String @db.VarChar(45)
}
model Vipps_orders {
ID Int @id @default(autoincrement())
orderID String @db.VarChar(256)
donorID Int
donationID Int?
KID String @db.VarChar(16)
token String? @db.VarChar(256)
registered DateTime? @default(now()) @db.DateTime(0)
// When we delete a donor we also delete all associated vipps orders.
Donors Donors @relation(fields: [donorID], references: [ID], onDelete: Cascade, map: "fk_Vipps_orders_to_Donors_idx")
// When we delete a donation we also delete all associated vipps orders.
Donations Donations? @relation(fields: [donationID], references: [ID], onDelete: Cascade, map: "fk_Vipps_orders_to_Donations_idx")
// When we delete a distribution we also delete all associated vipps orders.
Distribution Distributions @relation(fields: [KID], references: [KID], onDelete: Cascade, map: "fk_Vipps_orders_to_Distributions_idx")
@@index([donationID, orderID], map: "DonationID")
@@index([donorID], map: "Donor_ID_idx")
@@index([ID, orderID], map: "ID_order_id")
}
model Vipps_tokens {
ID Int @id @default(autoincrement())
expires DateTime @db.DateTime(0)
type String @db.VarChar(45)
token String @db.Text
}
model schema_migrations {
version String @id @db.VarChar(255)
}
model Conversion_rates {
ID Int @id @default(autoincrement())
Month Int
Year Int
PaymentMethod String @db.VarChar(45)
Rate Float
}
model Agreement_inflation_adjustments {
ID Int @id @default(autoincrement())
agreement_ID String @db.VarChar(45)
agreement_type String @db.VarChar(20) // "avtaleGiro", "autoGiro", "vipps"
current_amount Int // Stored in øre (cents)
proposed_amount Int // Stored in øre (cents)
inflation_percentage Decimal @db.Decimal(10, 6)
token String @unique @db.VarChar(64)
status String @default("pending") @db.VarChar(20) // "pending", "accepted", "rejected", "expired"
created DateTime @default(now()) @db.DateTime(0)
updated DateTime? @db.DateTime(0)
expires DateTime @db.DateTime(0)
@@index([agreement_ID, agreement_type])
@@index([status])
@@index([expires])
@@map("Agreement_inflation_adjustments")
}