+ Entity Relationship Diagram

Scroll to zoom Drag to pan Double-click to fit 100%
erDiagram Gift { string id PK datetime created_time int claim_token FK string applied FK string accepted FK } Gift }o--|| GiftClaimToken : claim_token Gift ||--|| GiftApplied : applied Gift ||--|| GiftAccepted : accepted Gift ||--|| GiftRejected : rejected Gift ||--|| GiftUsed : used GiftAccepted { string id PK } GiftApplied { string id PK string gift_api_id } GiftClaimToken { string id PK string token int gift FK datetime time } GiftClaimToken }o--|| Gift : gift GiftEvent { string id PK int gift FK } GiftEvent }o--|| Gift : gift GiftRejected { string id PK } GiftUsed { string id PK }

Gift

Table: fold_gift Extends: SubtypedModel
Field Type Constraints
id BigAutoField PK
created_time DateTimeField default=now()
claim_token FK → GiftClaimToken nullable
applied OneToOne → GiftApplied nullable
accepted OneToOne → GiftAccepted nullable
rejected OneToOne → GiftRejected nullable
used OneToOne → GiftUsed nullable

Relationships

.claim_token N:1 GiftClaimToken
.applied 1:1 GiftApplied
.accepted 1:1 GiftAccepted
.rejected 1:1 GiftRejected
.used 1:1 GiftUsed

Referenced By (2 tables)

GiftClaimToken N:1 .gift
GiftEvent N:1 .gift

Sample Queries (click to expand)

Get all records
Gift.objects.all()
Get by ID
Gift.objects.get(id=1)
With related GiftClaimToken
Gift.objects.select_related("claim_token")
Filter by created_time (last 7 days)
Gift.objects.filter(created_time__gte=datetime.now()-timedelta(days=7))

Schema History (click to expand)

#0001CreateModel2022-09-25
#0001AddField: accepted2022-09-25
#0001AddField: applied2022-09-25
#0001AddField: claim_token2022-09-25
#0001AddField: rejected2022-09-25
#0001AddField: used2022-09-25
#0001AddField: created_time2022-09-25

GiftAccepted

Table: fold_gift_accepted Extends: GiftEvent
Field Type Constraints
id BigAutoField PK

Referenced By (1 tables)

Gift 1:1 .accepted

Sample Queries (click to expand)

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

GiftApplied

Table: fold_gift_applied Extends: GiftEvent
Field Type Constraints
id BigAutoField PK
gift_api_id CharField(40) unique

Referenced By (1 tables)

Gift 1:1 .applied

Sample Queries (click to expand)

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

GiftClaimToken

Table: fold_gift_claim_token
Field Type Constraints
id BigAutoField PK
token CharField(256) unique
gift FK → Gift
time DateTimeField default=now()

Relationships

.gift N:1 Gift

Referenced By (1 tables)

Gift N:1 .claim_token

Sample Queries (click to expand)

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

GiftEvent

Table: fold_gift_event Extends: AccountEvent
Field Type Constraints
id BigAutoField PK
gift FK → Gift

Relationships

.gift N:1 Gift

Sample Queries (click to expand)

Get all records
GiftEvent.objects.all()
Get by ID
GiftEvent.objects.get(id=1)
With related Gift
GiftEvent.objects.select_related("gift")

GiftRejected

Table: fold_gift_rejected Extends: GiftEvent
Field Type Constraints
id BigAutoField PK

Referenced By (1 tables)

Gift 1:1 .rejected

Sample Queries (click to expand)

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

GiftUsed

Table: fold_gift_used Extends: GiftEvent
Field Type Constraints
id BigAutoField PK

Referenced By (1 tables)

Gift 1:1 .used

Sample Queries (click to expand)

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