In-game economy and virtual currency database schema

How a game backend models virtual currency: hard and soft currencies, player wallets, an append-only double-entry ledger of every source and sink, a personalised item shop, validated store receipts, refunds and a battle pass.

In Game Economy ER diagram

In-game economy and virtual currency database schema n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 11 n1 n1 n1 n1 n1 n1 n1 n1 players idBIGINT external_idVARCHAR display_nameVARCHAR country_codeCHAR segment_codeVARCHAR is_payment_blockedBOOLEAN created_atTIMESTAMPTZ currencies idBIGINT codeVARCHAR nameVARCHAR kindVARCHAR is_purchasableBOOLEAN is_tradableBOOLEAN expires_after_daysINTEGER max_balance_minorBIGINT sort_orderSMALLINT wallets idBIGINT player_idBIGINT currency_idBIGINT account_kindVARCHAR balance_minorBIGINT lifetime_credited…BIGINT lifetime_debited_…BIGINT versionINTEGER updated_atTIMESTAMPTZ ledger_transactions idBIGINT currency_idBIGINT kindVARCHAR reason_codeVARCHAR idempotency_keyVARCHAR reverses_transact…BIGINT actorVARCHAR reference_typeVARCHAR reference_idBIGINT metadataJSONB occurred_atTIMESTAMPTZ ledger_entries idBIGINT transaction_idBIGINT wallet_idBIGINT delta_minorBIGINT balance_afterBIGINT created_atTIMESTAMPTZ shop_offers idBIGINT codeVARCHAR nameVARCHAR item_refVARCHAR item_quantityINTEGER currency_idBIGINT base_price_minorBIGINT starts_atTIMESTAMPTZ ends_atTIMESTAMPTZ max_per_playerINTEGER max_totalINTEGER is_activeBOOLEAN offer_prices idBIGINT offer_idBIGINT audience_codeVARCHAR price_minorBIGINT prioritySMALLINT starts_atTIMESTAMPTZ ends_atTIMESTAMPTZ purchases idBIGINT player_idBIGINT offer_idBIGINT offer_price_idBIGINT quantityINTEGER price_minorBIGINT currency_idBIGINT stateVARCHAR ledger_transactio…BIGINT reversal_transact…BIGINT refund_reasonVARCHAR idempotency_keyVARCHAR created_atTIMESTAMPTZ completed_atTIMESTAMPTZ refunded_atTIMESTAMPTZ iap_receipts idBIGINT player_idBIGINT purchase_idBIGINT storeVARCHAR store_product_idVARCHAR store_transaction…VARCHAR price_minorBIGINT currency_codeCHAR validation_stateVARCHAR validation_errorVARCHAR raw_payloadJSONB purchased_atTIMESTAMPTZ validated_atTIMESTAMPTZ revoked_atTIMESTAMPTZ battle_passes idBIGINT codeVARCHAR nameVARCHAR starts_atTIMESTAMPTZ ends_atTIMESTAMPTZ premium_offer_idBIGINT tier_countSMALLINT xp_per_tierINTEGER battle_pass_tiers idBIGINT battle_pass_idBIGINT tier_indexSMALLINT xp_requiredINTEGER free_reward_typeVARCHAR free_reward_refVARCHAR free_reward_quant…INTEGER premium_reward_ty…VARCHAR premium_reward_refVARCHAR premium_reward_qu…INTEGER battle_pass_progress idBIGINT player_idBIGINT battle_pass_idBIGINT xpINTEGER has_premiumBOOLEAN premium_purchase_…BIGINT started_atTIMESTAMPTZ updated_atTIMESTAMPTZ battle_pass_claims idBIGINT progress_idBIGINT tier_idBIGINT trackVARCHAR ledger_transactio…BIGINT claimed_atTIMESTAMPTZ

Related database schemas