CoinFlow
Tables (9)
assets
- code — VARCHAR(20) — Primary key — NOT NULL
- name — VARCHAR(100) — NOT NULL
- display_name — VARCHAR(100) — NOT NULL
- status — VARCHAR(20) — NOT NULL
- created_at — DATETIME — NOT NULL
- updated_at — DATETIME — NOT NULL
domain_events
- id — BIGINT — Primary key — NOT NULL
- event_type — VARCHAR(60) — NOT NULL
- aggregate_type — VARCHAR(50) — NOT NULL
- aggregate_id — BIGINT — NOT NULL
- market_id — BIGINT — Foreign key → markets.id
- market_symbol — VARCHAR(50)
- payload — TEXT — NOT NULL
- published — TINYINT — NOT NULL
- published_at — DATETIME
- publish_attempts — INT — NOT NULL
- created_at — DATETIME — NOT NULL
- INDEX — idx_domain_events_aggregate
- INDEX — idx_domain_events_market_created
- INDEX — idx_domain_events_type_created
- INDEX — idx_domain_events_published_created
markets
- id — BIGINT — Primary key — NOT NULL
- symbol — VARCHAR(50) — NOT NULL
- display_name — VARCHAR(100) — NOT NULL
- base_asset — VARCHAR(20) — Foreign key → assets.code — NOT NULL
- quote_asset — VARCHAR(20) — Foreign key → assets.code — NOT NULL
- amount_scale — INT — NOT NULL
- tick_size — DECIMAL(38, 18) — NOT NULL
- step_size — DECIMAL(38, 18) — NOT NULL
- min_order_quantity — DECIMAL(38, 18) — NOT NULL
- min_order_amount — DECIMAL(38, 18) — NOT NULL
- status — VARCHAR(20) — NOT NULL
- cancel_only — TINYINT — NOT NULL
- created_at — DATETIME — NOT NULL
- updated_at — DATETIME — NOT NULL
order_sequences
- market_id — BIGINT — Foreign key → markets.id — NOT NULL
- last_sequence — BIGINT — NOT NULL
orders
- id — BIGINT — Primary key — NOT NULL
- client_order_id — VARCHAR(64)
- user_id — BIGINT — Foreign key → users.id — NOT NULL
- market_id — BIGINT — Foreign key → markets.id — NOT NULL
- market_symbol — VARCHAR(50) — NOT NULL
- side — VARCHAR(10) — NOT NULL
- type — VARCHAR(10) — NOT NULL
- time_in_force — VARCHAR(10) — NOT NULL
- price — DECIMAL(38, 18) — NOT NULL
- original_quantity — DECIMAL(38, 18) — NOT NULL
- remaining_quantity — DECIMAL(38, 18) — NOT NULL
- executed_quantity — DECIMAL(38, 18) — NOT NULL
- executed_quote_amount — DECIMAL(38, 18) — NOT NULL
- locked_asset — VARCHAR(20) — Foreign key → assets.code — NOT NULL
- locked_amount — DECIMAL(38, 18) — NOT NULL
- status — VARCHAR(30) — NOT NULL
- sequence — BIGINT — NOT NULL
- created_at — DATETIME — NOT NULL
- updated_at — DATETIME — NOT NULL
- closed_at — DATETIME
- INDEX — idx_orders_user_created
- INDEX — idx_orders_user_market_status_created
- INDEX — idx_orders_book
trades
- id — BIGINT — Primary key — NOT NULL
- market_id — BIGINT — Foreign key → markets.id — NOT NULL
- market_symbol — VARCHAR(50) — NOT NULL
- buy_order_id — BIGINT — Foreign key → orders.id — NOT NULL
- sell_order_id — BIGINT — Foreign key → orders.id — NOT NULL
- maker_order_id — BIGINT — Foreign key → orders.id — NOT NULL
- taker_order_id — BIGINT — Foreign key → orders.id — NOT NULL
- buy_user_id — BIGINT — Foreign key → users.id — NOT NULL
- sell_user_id — BIGINT — Foreign key → users.id — NOT NULL
- price — DECIMAL(38, 18) — NOT NULL
- quantity — DECIMAL(38, 18) — NOT NULL
- quote_amount — DECIMAL(38, 18) — NOT NULL
- traded_at — DATETIME — NOT NULL
- INDEX — idx_trades_market_traded
- INDEX — idx_trades_buy_user_traded
- INDEX — idx_trades_sell_user_traded
users
- id — BIGINT — Primary key — NOT NULL
- email — VARCHAR(255) — NOT NULL
- password_hash — VARCHAR(255) — NOT NULL
- nickname — VARCHAR(100) — NOT NULL
- status — VARCHAR(20) — NOT NULL
- created_at — DATETIME — NOT NULL
- updated_at — DATETIME — NOT NULL
wallet_ledgers
- id — BIGINT — Primary key — NOT NULL
- user_id — BIGINT — Foreign key → users.id — NOT NULL
- wallet_id — BIGINT — Foreign key → wallets.id — NOT NULL
- asset — VARCHAR(20) — Foreign key → assets.code — NOT NULL
- type — VARCHAR(40) — NOT NULL
- delta_available — DECIMAL(38, 18) — NOT NULL
- delta_locked — DECIMAL(38, 18) — NOT NULL
- available_balance_after — DECIMAL(38, 18) — NOT NULL
- locked_balance_after — DECIMAL(38, 18) — NOT NULL
- order_id — BIGINT — Foreign key → orders.id
- trade_id — BIGINT — Foreign key → trades.id
- created_at — DATETIME — NOT NULL
- INDEX — idx_wallet_ledgers_user_created
- INDEX — idx_wallet_ledgers_user_asset_created
- INDEX — idx_wallet_ledgers_wallet_created
wallets
- id — BIGINT — Primary key — NOT NULL
- user_id — BIGINT — Foreign key → users.id — NOT NULL
- asset — VARCHAR(20) — Foreign key → assets.code — NOT NULL
- available_balance — DECIMAL(38, 18) — NOT NULL
- locked_balance — DECIMAL(38, 18) — NOT NULL
- created_at — DATETIME — NOT NULL
- updated_at — DATETIME — NOT NULL