Database Architecture
Gold Digger uses a relational database to store user data, NFT collections, transactions, and more.
Database Schema
The Gold Digger database schema is organized into several related tables
Table Categories
- Users: User profiles, settings, and subscriptions
- NFTs: Collections, NFTs, and marketplace listings
- Transactions: Wallets, transactions, and staking
- AI: AI conversations, messages, and saved prompts
- Governance: Proposals, votes, and governance tokens
Key Relationships
- User profiles are linked to settings, wallets, and AI conversations
- NFT collections contain multiple NFTs
- NFTs can be listed in the marketplace or staked
- Wallets are associated with transactions
- AI conversations contain multiple messages
- Governance proposals receive votes from users
Database Migrations
Gold Digger uses SQL migrations to manage database schema changes
The database schema is managed through a series of SQL migration files that are applied in order. This ensures consistent database structure across all environments.
Migration Files
- 01_initial_setup.sql
- 02_auth_profiles.sql
- 03_ai_conversations.sql
- 04_nft_collections.sql
- 05_transactions_wallets.sql
- 06_settings_subscribers.sql
- 07_functions.sql
- 08_rls_policies.sql
Migration Features
- Version-controlled schema changes
- Automatic rollbacks on failure
- Row-level security policies
- Database functions and triggers
- Indexes for performance optimization
Database Relationships
Key relationships between database tables
profiles
idPK
user_idFK
wallet_addressUNIQUE
settings
idPK
user_idFK
collections
idPK
creator_idFK
nfts
idPK
collection_idFK
owner_idFK
wallets
idPK
user_idFK
transactions
idPK
user_idFK
Legend
PKPrimary Key
FKForeign Key
UNIQUEUnique Constraint
Relationship