+ Entity Relationship Diagram

Scroll to zoom Drag to pan Double-click to fit 100%
erDiagram AdminReferralReward { string id PK string account FK bool global_reward string account_usernames string reason } AdminReferralReward ||--|| Account : account AdminReferralReward }o--|| User : admin_user ReferralCardSpendThresholdConversion { string id PK string signup FK int transaction FK string balance_change FK } ReferralCardSpendThresholdConversion ||--|| ReferralSignup : signup ReferralEvent { string id PK string type datetime date string balance_change FK int referred_account FK } ReferralEvent }o--|| Account : referred_account ReferralEvent }o--|| Account : referrer_account ReferralFICWaitlistConversion { string id PK string signup FK string fold_issued_card_waitlist_signup FK } ReferralFICWaitlistConversion ||--|| ReferralSignup : signup ReferralOrderConversion { string id PK string signup FK string order FK string balance_change FK } ReferralOrderConversion ||--|| ReferralSignup : signup ReferralSignup { string id PK int token FK string original_url string referred FK datetime time } ReferralSignup }o--|| ReferralToken : token ReferralToken { string id PK int profile FK string code }

AdminReferralReward

Table: fold_referral_reward Extends: BaseModelMixin
Field Type Constraints
id BigAutoField PK
account OneToOne → Account nullable
global_reward BooleanField default=False
account_usernames TextField nullable
reason CharField(250) choicesAdminReferralRewardReason
comment TextField nullable
admin_user FK → User nullable
expiration DateTimeField nullable
sender_amount PositiveIntegerField nullable
recipient_amount PositiveIntegerField nullable
referral_reward_spend_threshold PositiveIntegerField nullable
award_spin_amount PositiveIntegerField nullable
sender_currency CharField(250) choices default=valueReferralSupportCurrencies
recipient_currency CharField(250) choices default=valueReferralSupportCurrencies

Relationships

.account 1:1 Account
.admin_user N:1 User

Sample Queries (click to expand)

Get all records
AdminReferralReward.objects.all()
Get by ID
AdminReferralReward.objects.get(id=1)
With related Account
AdminReferralReward.objects.select_related("account")
Filter by account
AdminReferralReward.objects.filter(account_id=123)
Filter by expiration (last 7 days)
AdminReferralReward.objects.filter(expiration__gte=datetime.now()-timedelta(days=7))

ReferralCardSpendThresholdConversion

Table: fold_referralcardspendthresholdconversion
Field Type Constraints
id BigAutoField PK
signup OneToOne → ReferralSignup
transaction FK → FoldCardTransaction nullable
balance_change OneToOne → BalanceChange nullable

Relationships

.signup 1:1 ReferralSignup
.transaction N:1 FoldCardTransaction
.balance_change 1:1 BalanceChange

Sample Queries (click to expand)

Get all records
ReferralCardSpendThresholdConversion.objects.all()
Get by ID
ReferralCardSpendThresholdConversion.objects.get(id=1)
With related ReferralSignup
ReferralCardSpendThresholdConversion.objects.select_related("signup")

ReferralEvent

Table: fold_referral_events
Field Type Constraints
id BigAutoField PK
type CharField(50) choicesShow 2 choices
SQUAD_SWIPESquad Swipe
BTC_BUYBTC Buy
date DateTimeField
balance_change OneToOne → BalanceChange nullable
referred_account FK → Account
referrer_account FK → Account
fold_card_transaction FK → FoldCardTransaction nullable

Relationships

.balance_change 1:1 BalanceChange
.referred_account N:1 Account
.referrer_account N:1 Account
.fold_card_transaction N:1 FoldCardTransaction

Sample Queries (click to expand)

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

ReferralFICWaitlistConversion

Table: fold_referralficwaitlistconversion
Field Type Constraints
id BigAutoField PK
signup OneToOne → ReferralSignup
fold_issued_card_waitlist_signup OneToOne → FoldIssuedCardWaitlistEntry nullable

Relationships

.signup 1:1 ReferralSignup
.fold_issued_card_waitlist_signup 1:1 FoldIssuedCardWaitlistEntry

Sample Queries (click to expand)

Get all records
ReferralFICWaitlistConversion.objects.all()
Get by ID
ReferralFICWaitlistConversion.objects.get(id=1)
With related ReferralSignup
ReferralFICWaitlistConversion.objects.select_related("signup")

ReferralOrderConversion

Table: fold_referralorderconversion
Field Type Constraints
id BigAutoField PK
signup OneToOne → ReferralSignup
order OneToOne → Order
balance_change OneToOne → BalanceChange nullable

Relationships

.signup 1:1 ReferralSignup
.order 1:1 Order
.balance_change 1:1 BalanceChange

Sample Queries (click to expand)

Get all records
ReferralOrderConversion.objects.all()
Get by ID
ReferralOrderConversion.objects.get(id=1)
With related ReferralSignup
ReferralOrderConversion.objects.select_related("signup")

ReferralSignup

Table: fold_referralsignup
Field Type Constraints
id BigAutoField PK
token FK → ReferralToken
original_url URLField nullable
referred OneToOne → CardForCoinProfile
time DateTimeField default=now()

Relationships

.token N:1 ReferralToken
.referred 1:1 CardForCoinProfile

Referenced By (3 tables)

Sample Queries (click to expand)

Get all records
ReferralSignup.objects.all()
Get by ID
ReferralSignup.objects.get(id=1)
With related ReferralToken
ReferralSignup.objects.select_related("token")
Filter by time (last 7 days)
ReferralSignup.objects.filter(time__gte=datetime.now()-timedelta(days=7))

ReferralToken

Table: fold_referraltoken
Field Type Constraints
id BigAutoField PK
profile FK → CardForCoinProfile
code CharField(12) unique nullable default=new_token_code()

Relationships

.profile N:1 CardForCoinProfile

Referenced By (2 tables)

ReferralSignup N:1 .token

Sample Queries (click to expand)

Get all records
ReferralToken.objects.all()
Get by ID
ReferralToken.objects.get(id=1)
With related CardForCoinProfile
ReferralToken.objects.select_related("profile")