+ Entity Relationship Diagram

Scroll to zoom Drag to pan Double-click to fit 100%
erDiagram AccountCard { string id PK int account FK string api_id int card FK string assigned FK } AccountCard }o--|| Account : account AccountCard ||--|| CardAssigned : assigned AccountCard ||--|| CardDestroyed : destroyed CardAssigned { string id PK string state } CardDestroyed { string id PK } CardEvent { string id PK int history FK int history_seq string json datetime date } CardExported { string id PK string email_address string message } CardSpend { string id PK }

AccountCard

Table: fold_account_card
Field Type Constraints
id BigAutoField PK
account FK → Account
api_id CharField(40)
card FK → Card
assigned OneToOne → CardAssigned nullable
destroyed OneToOne → CardDestroyed nullable
acknowledged_balance DecimalField(30,8) nullable
nonrefundable BooleanField default=False
nonrefundable_reason TextField nullable

Relationships

.account N:1 Account
.card N:1 Card
.assigned 1:1 CardAssigned
.destroyed 1:1 CardDestroyed

Referenced By (1 tables)

Refund N:1 .card

Sample Queries (click to expand)

Get all records
AccountCard.objects.all()
Get by ID
AccountCard.objects.get(id=1)
With related Account
AccountCard.objects.select_related("account")
Filter by account
AccountCard.objects.filter(account_id=123)

CardAssigned

Table: fold_card_assigned Extends: CardEvent
Field Type Constraints
id BigAutoField PK
state CharField(20) choices

Referenced By (1 tables)

AccountCard 1:1 .assigned

Sample Queries (click to expand)

Get all records
CardAssigned.objects.all()
Get by ID
CardAssigned.objects.get(id=1)

CardDestroyed

Table: fold_card_destroyed Extends: CardEvent
Field Type Constraints
id BigAutoField PK

Referenced By (1 tables)

AccountCard 1:1 .destroyed

Sample Queries (click to expand)

Get all records
CardDestroyed.objects.all()
Get by ID
CardDestroyed.objects.get(id=1)

CardEvent

Table: fold_cardevent
Field Type Constraints
id BigAutoField PK
history FK → CardHistory
history_seq IntegerField
json TextField
date DateField
amount DecimalField(7,2) nullable
currency CharField(30) nullable
is_activation BooleanField nullable
is_instore BooleanField nullable
is_transfer BooleanField nullable

Relationships

.history N:1 CardHistory

Sample Queries (click to expand)

Get all records
CardEvent.objects.all()
Get by ID
CardEvent.objects.get(id=1)
With related CardHistory
CardEvent.objects.select_related("history")
Filter by date (last 7 days)
CardEvent.objects.filter(date__gte=datetime.now()-timedelta(days=7))

CardExported

Table: fold_card_exported Extends: CardEvent
Field Type Constraints
id BigAutoField PK
email_address EmailField
message TextField

Sample Queries (click to expand)

Get all records
CardExported.objects.all()
Get by ID
CardExported.objects.get(id=1)

CardSpend

Table: fold_card_spend Extends: CardEvent
Field Type Constraints
id BigAutoField PK

Sample Queries (click to expand)

Get all records
CardSpend.objects.all()
Get by ID
CardSpend.objects.get(id=1)