+ Entity Relationship Diagram

Scroll to zoom Drag to pan Double-click to fit 100%
erDiagram CreditCard { string card_id PK int stripe_account FK string type string status bool is_current } DepositAddress { string id PK int added FK int removed FK int account FK string api_id } DepositAddress }o--|| DepositAddressAdded : added DepositAddress }o--|| DepositAddressRemoved : removed DepositAddress }o--|| Account : account DepositAddressAdded { string id PK } DepositAddressEvent { string id PK int address FK } DepositAddressEvent }o--|| DepositAddress : address DepositAddressRemoved { string id PK } Refund { string id PK int account FK int card FK string api_id string created FK } Refund }o--|| Account : account Refund ||--|| RefundCreated : created Refund ||--|| RefundPulled : pulled Refund ||--|| RefundPaid : paid RefundCreated { string id PK } RefundEvent { string id PK int refund FK } RefundEvent }o--|| Refund : refund RefundPaid { string id PK } RefundPulled { string id PK string currency int brand FK string brand_field_deprecated int amount } WithdrawAddress { string id PK int first_added FK int account FK string api_id string currency } WithdrawAddress }o--|| WithdrawAddressAdded : first_added WithdrawAddress }o--|| Account : account WithdrawAddressAdded { string id PK } WithdrawAddressEvent { string id PK int address FK } WithdrawAddressEvent }o--|| WithdrawAddress : address WithdrawAddressRemoved { string id PK } Withdrawal { string id PK int method string payment_address int profile FK string reference_number } WithdrawalCreated { string id PK } WithdrawalEvent { string id PK int withdrawal FK } WithdrawalEvent }o--|| Withdrawal : withdrawal

CreditCard

Table: credit_card Extends: BaseModelMixin
Field Type Constraints
card_id CharField(255) unique PK
stripe_account FK → StripeAccount
type CharField(255) choicesCreditCardType
status CharField(255) choices nullableCreditCardStatus
is_current BooleanField default=False
exp_date DateField
tracking_url URLField nullable
shipping_status CharField(100) choices nullableCreditCardShippingStatus
first_time_activation DateTimeField nullable
manual_expiration_type CharField(50) choices nullableCreditCardManualExpirationType
manual_expiration_at DateTimeField nullable
one_time_used BooleanField default=False

Relationships

.stripe_account N:1 StripeAccount

Referenced By (3 tables)

CreditCardEvent N:1 .credit_card
CreditCardVerification 1:1 .credit_card
Account N:1 .default_credit_card

Sample Queries (click to expand)

Get all records
CreditCard.objects.all()
Get by ID
CreditCard.objects.get(id=1)
With related StripeAccount
CreditCard.objects.select_related("stripe_account")
Filter by exp_date (last 7 days)
CreditCard.objects.filter(exp_date__gte=datetime.now()-timedelta(days=7))

DepositAddress

Table: fold_deposit_address Extends: SubtypedModel
Field Type Constraints
id BigAutoField PK
added FK → DepositAddressAdded nullable
removed FK → DepositAddressRemoved nullable
account FK → Account
api_id CharField(40)
currency CharField(6)
address CharField(256)
extra_data JSONField default=dict()
webhook_url CharField(256) default=""
backup_webhook_url CharField(256) default=""

Relationships

.account N:1 Account

Referenced By (2 tables)

Deposit N:1 .address
DepositAddressEvent N:1 .address

Sample Queries (click to expand)

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

DepositAddressAdded

Table: fold_deposit_address_added Extends: DepositAddressEvent
Field Type Constraints
id BigAutoField PK

Referenced By (1 tables)

DepositAddress N:1 .added

Sample Queries (click to expand)

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

DepositAddressEvent

Table: fold_deposit_address_event Extends: AccountEvent
Field Type Constraints
id BigAutoField PK
address FK → DepositAddress

Relationships

.address N:1 DepositAddress

Sample Queries (click to expand)

Get all records
DepositAddressEvent.objects.all()
Get by ID
DepositAddressEvent.objects.get(id=1)
With related DepositAddress
DepositAddressEvent.objects.select_related("address")

DepositAddressRemoved

Table: fold_deposit_address_removed Extends: DepositAddressEvent
Field Type Constraints
id BigAutoField PK

Referenced By (1 tables)

DepositAddress N:1 .removed

Sample Queries (click to expand)

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

Refund

Table: fold_refund
Field Type Constraints
id BigAutoField PK
account FK → Account
card FK → AccountCard nullable
api_id CharField(40)
created OneToOne → RefundCreated nullable
pulled OneToOne → RefundPulled nullable
paid OneToOne → RefundPaid nullable
refund_rate DecimalField(30,8) nullable

Relationships

.account N:1 Account
.card N:1 AccountCard
.created 1:1 RefundCreated
.pulled 1:1 RefundPulled
.paid 1:1 RefundPaid

Referenced By (1 tables)

RefundEvent N:1 .refund

Sample Queries (click to expand)

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

Schema History (click to expand)

#0001CreateModel2022-09-25
#0001AddField: created2022-09-25
#0001AddField: paid2022-09-25
#0001AddField: pulled2022-09-25
#0001AddField: refund_rate2022-09-25
#0636AlterField: refund_rate2025-09-25

RefundCreated

Table: fold_refund_created Extends: RefundEvent
Field Type Constraints
id BigAutoField PK

Referenced By (1 tables)

Refund 1:1 .created

Sample Queries (click to expand)

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

RefundEvent

Table: fold_refund_event Extends: AccountEvent
Field Type Constraints
id BigAutoField PK
refund FK → Refund

Relationships

.refund N:1 Refund

Sample Queries (click to expand)

Get all records
RefundEvent.objects.all()
Get by ID
RefundEvent.objects.get(id=1)
With related Refund
RefundEvent.objects.select_related("refund")

RefundPaid

Table: fold_refund_paid Extends: RefundEvent
Field Type Constraints
id BigAutoField PK

Referenced By (1 tables)

Refund 1:1 .paid

Sample Queries (click to expand)

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

RefundPulled

Table: fold_refund_pulled Extends: RefundEvent
Field Type Constraints
id BigAutoField PK
currency CharField(6)
brand FK → Brand nullable
brand_field_deprecated CharField(30)
amount DecimalField(30,8)

Relationships

.brand N:1 Brand

Referenced By (1 tables)

Refund 1:1 .pulled

Sample Queries (click to expand)

Get all records
RefundPulled.objects.all()
Get by ID
RefundPulled.objects.get(id=1)
With related Brand
RefundPulled.objects.select_related("brand")

WithdrawAddress

Table: fold_withdraw_address
Field Type Constraints
id BigAutoField PK
first_added FK → WithdrawAddressAdded nullable
account FK → Account
api_id CharField(40)
currency CharField(6)
address CharField(256)
address_type CharField(10) choicesShow 2 choices
cryptoCrypto
emailEmail
active BooleanField default=True

Relationships

.first_added N:1 WithdrawAddressAdded
.account N:1 Account

Referenced By (2 tables)

DefaultWithdrawAddress N:1 .withdraw_address

Sample Queries (click to expand)

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

WithdrawAddressAdded

Table: fold_withdraw_address_added Extends: WithdrawAddressEvent
Field Type Constraints
id BigAutoField PK

Referenced By (1 tables)

WithdrawAddress N:1 .first_added

Sample Queries (click to expand)

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

WithdrawAddressEvent

Table: fold_withdraw_address_event Extends: AccountEvent
Field Type Constraints
id BigAutoField PK
address FK → WithdrawAddress

Relationships

.address N:1 WithdrawAddress

Sample Queries (click to expand)

Get all records
WithdrawAddressEvent.objects.all()
Get by ID
WithdrawAddressEvent.objects.get(id=1)
With related WithdrawAddress
WithdrawAddressEvent.objects.select_related("address")

WithdrawAddressRemoved

Table: fold_withdraw_address_removed Extends: WithdrawAddressEvent
Field Type Constraints
id BigAutoField PK

Sample Queries (click to expand)

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

Withdrawal

Table: fold_withdrawal
Field Type Constraints
id BigAutoField PK
method SmallIntegerField choicesShow 3 choices
0BITCOINBitcoin
1WIREWire
2CASHCash
payment_address CharField(34) nullable
profile FK → CardForCoinProfile
reference_number CharField(9) unique nullable default=new_withdrawal_reference_number()
amount_requested FK → CurrencyAmount
date_requested DateTimeField default=now()
payment FK → Payment nullable
automatic BooleanField default=False

Relationships

.profile N:1 CardForCoinProfile
.amount_requested N:1 CurrencyAmount
.payment N:1 Payment

Referenced By (2 tables)

BalanceChange N:1 .withdrawal
WithdrawalEvent N:1 .withdrawal

Sample Queries (click to expand)

Get all records
Withdrawal.objects.all()
Get by ID
Withdrawal.objects.get(id=1)
With related CardForCoinProfile
Withdrawal.objects.select_related("profile")
Filter by date_requested (last 7 days)
Withdrawal.objects.filter(date_requested__gte=datetime.now()-timedelta(days=7))

Schema History (click to expand)

#0001CreateModel2022-09-25
#0001AddField: created2022-09-25
#0636AlterField: amount2025-09-25

WithdrawalCreated

Table: fold_withdrawal_created Extends: WithdrawalEvent
Field Type Constraints
id BigAutoField PK

Sample Queries (click to expand)

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

WithdrawalEvent

Table: fold_withdrawal_event Extends: AccountEvent
Field Type Constraints
id BigAutoField PK
withdrawal FK → Withdrawal nullable

Relationships

.withdrawal N:1 Withdrawal

Sample Queries (click to expand)

Get all records
WithdrawalEvent.objects.all()
Get by ID
WithdrawalEvent.objects.get(id=1)
With related Withdrawal
WithdrawalEvent.objects.select_related("withdrawal")