+ Entity Relationship Diagram

Scroll to zoom Drag to pan Double-click to fit 100%
erDiagram Card { string id PK string brand string card_number string pin string url_redemption_link } ExchangeRate { string id PK datetime date int currency_pair int rate } ExchangeRateHighFrequency { string id PK datetime timestamp int currency_pair int rate }

Card

Table: fold_card
Field Type Constraints
id BigAutoField PK
brand CharField(30)
card_number CharField(125) nullable
pin CharField(20) nullable
url_redemption_link TextField nullable
url_expiration_date DateTimeField nullable indexed
event_number CharField(50) nullable
barcode_value CharField(50) nullable
barcode_format CharField(20) nullable
registered BooleanField default=False
registered_to FK → BrandAccount nullable
physical BooleanField default=False
created_at DateTimeField nullable
updated_at DateTimeField nullable
secure BooleanField default=False
suspicious BooleanField default=False
nickname CharField(20) nullable
balance FK → CardBalance nullable
reservation FK → CardReservation nullable
card_number_unique BooleanField default=True nullable
url_redemption_link_unique BooleanField default=True nullable
origin CharField(100) nullable
notes TextField nullable
imported_batch FK → BulkImport nullable
sold BooleanField default=False

Relationships

.registered_to N:1 BrandAccount
.balance N:1 CardBalance
.reservation N:1 CardReservation
.imported_batch N:1 BulkImport

Referenced By (13 tables)

AccountCard N:1 .card
Slot 1:1 .card
OrderCard N:1 .card
Listing N:1 .card
CardHistory N:1 .card
CardBalance N:1 .card
Transfer N:M .sources
Transfer N:M .targets
TransferSource N:1 .card
...and 3 more

Sample Queries (click to expand)

Get all records
Card.objects.all()
Get by ID
Card.objects.get(id=1)
With related BrandAccount
Card.objects.select_related("registered_to")
Filter by url_expiration_date (last 7 days)
Card.objects.filter(url_expiration_date__gte=datetime.now()-timedelta(days=7))

Schema History (click to expand)

#0023AlterField: card_number2020-07-07
#0027AlterField: pin2021-12-17
#0028AlterField: card_number2022-02-01
#0030AlterField: card_number_unique2023-01-31
#0033AlterField: event_number2023-05-03
#0034AddField: barcode_format2023-08-30
#0034AddField: barcode_value2023-08-30
#0037AddField: url_redemption_link2025-09-17
#0038AddField: url_expiration_date2025-09-22
#0038AddField: url_redemption_link_unique2025-09-22

ExchangeRate

Table: merchant_dash_exchange_rate
Field Type Constraints
id BigAutoField PK
date DateField
currency_pair SmallIntegerField choicesShow 1 choices
0BTC_USDBTC/USD
rate DecimalField(10,2)

Sample Queries (click to expand)

Get all records
ExchangeRate.objects.all()
Get by ID
ExchangeRate.objects.get(id=1)
Filter by date (last 7 days)
ExchangeRate.objects.filter(date__gte=datetime.now()-timedelta(days=7))

ExchangeRateHighFrequency

Table: merchant_dash_exchange_rate_high_frequency Extends: BaseModelMixin
Field Type Constraints
id BigAutoField PK
timestamp DateTimeField default=now()
currency_pair SmallIntegerField choicesShow 1 choices
0BTC_USDBTC/USD
rate DecimalField(10,2)

Sample Queries (click to expand)

Get all records
ExchangeRateHighFrequency.objects.all()
Get by ID
ExchangeRateHighFrequency.objects.get(id=1)
Filter by timestamp (last 7 days)
ExchangeRateHighFrequency.objects.filter(timestamp__gte=datetime.now()-timedelta(days=7))