Schema Map

This map documents future table-style storage for a database migration dry run. Production still uses JSON as the active source of truth.

Dataset Source JSON Future table Primary key Important fields Truth Migration risks
Blockschain.jsonblockshashindex, timestamp, previous_hash, nonce, difficulty, miner_address, hashSource of truthNever rewrite fields used by block hash calculation.
Confirmed transactionschain.jsonconfirmed_transactionstx_id plus block_index/transaction_index for legacy rowssender_address, receiver_address, amount, timestamp, type, category, signature, sender_public_key, metadataSource of truthLegacy transactions may not have tx_id; preserve original transaction object.
Pending transactionspending.jsonpending_transactionstx_id or pending sequencesender_address, receiver_address, amount, timestamp, signature, sender_public_key, metadataSource of truth for mempoolKeep separate from confirmed transactions until mined.
Peerspeers.jsonpeerspeer_urlurlApp stateStale peers should not affect chain validity.
Registry nodesregistry.jsonregistry_nodesnode_urldisplay_name, region, operator_wallet_address, last_seen, last_chain_height, reliability_scoreApp stateHeartbeat timestamps are mutable operational state.
Lending loanslending.jsonlending_loansloan_idrequester_address, amount, repayment_amount, status, votes, due_block, status_historyApp stateNested votes and history need deterministic serialization.
Exchange offersexchange.jsonexchange_offersoffer_idcreator_address, acceptor_address, offer_type, amount, price, status, status_historyApp stateLifecycle transitions must keep public trade history intact.
Governance proposalsgovernance.jsongovernance_proposalsproposal_idproposer_address, category, parameter, votes, status, voting_deadline, status_historyApp stateVote weights must match chain balance rules used at decision time.
Governance rule changesgovernance.jsongovernance_rule_changesrule_change_idproposal_id, category, old_value, new_value, applied_block_height, statusApp stateRule history affects later behavior and must remain ordered.
Treasury proposalstreasury.jsontreasury_proposalsproposal_idproposer_address, requested_amount, recipient_address, votes, status, payout_tx_idApp statePayout links must match confirmed chain transactions.
Treasury ledgerchain.json and indexes.jsontreasury_ledgerledger_id or tx_id/block tupletype, amount, from_address, to_address, tx_id, block_index, proposal_idDerived from chain and treasury stateDo not use indexes as authority; rebuild ledger from confirmed chain.
Price signalsprice.jsonprice_signalssignal_idaddress, amount, currency, timestamp, expires_atApp stateExpired signals may be pruned by current loaders.
Forum postsforum.jsonforum_postspost_idauthor_address, title, body, timestamp, vote_count, moderation_statusApp stateModeration state is mutable while post IDs remain stable.
Forum repliesforum.jsonforum_repliesreply_idpost_id, author_address, body, timestamp, moderation_statusApp stateNested replies need parent post linkage.
Forum reports/moderationforum.json and backend/data/reports.jsonforum_reports_moderationreport_id or moderation_event_idtarget_type, target_id, reason, status, moderator_note, timestampOperational moderation stateReports must not expose secrets submitted by users.
Achievementsachievements.jsonachievementswallet_address plus achievement_idwallet_address, achievement_id, earned_at, metadataApp stateNested earned records need stable composite keys.
Profilesprofiles.jsonprofileswallet_addressdisplay_name, bio, avatar, location, verified_wallet, reputation_scoreApp stateProfile content is public; do not add private key storage.
Faucet claimsfaucet.jsonfaucet_claimsclaim_idwallet_address, amount, status, tx_id, requested_at, completed_atApp stateClaim state must match treasury transaction lifecycle.
Analytics eventsbackend/data/analytics.jsonanalytics_eventsevent_idevent_type, route, category, timestamp, anonymous_session_id, metadataOperational logsRetention pruning and privacy rules must carry over.
Incidentsbackend/data/incidents.jsonincidentsidtitle, description, severity, status, affected_services, created_at, updated_atOperational stateResolved history should remain public and ordered.
Reportsbackend/data/reports.jsonreportsreport_idtarget_type, target_id, reported_by, reason, description, status, moderator_noteOperational moderation stateSanitize unsafe text and secrets during any export.
Audit export metadataGenerated audit exportsaudit_exports_metadataexport_idexport_type, chain_height, latest_block_hash, sha256, generated_atOperational metadataKeep export hashes tied to immutable chain snapshots.
Storage health snapshotsHealth/readiness endpointsstorage_health_snapshotssnapshot_idoverall_status, chain_height, latest_block_hash, warnings_count, errors_count, checked_atOperational metadataNever expose full server paths or raw file contents.
Indexesindexes.jsonindexes_cacheschema_version plus chain height/hashbuilt_at, chain_height, latest_block_hash, indexesDerived cacheAlways rebuild after migration; never treat as source of truth.

The PostgreSQL schema draft in the repository is preparation only and keeps raw JSONB columns for blocks and transactions so historical compatibility is preserved. See storage adapters, PostgreSQL readiness, and derived indexes for cache behavior.