MarketDeck docs
db
SQLite database operations — path resolution, open + migrate, JSON import.
Every persisted record in marketdeck lives in one SQLite file under your data dir. marketdeck db is the CLI surface for the database itself — opening it, running migrations, and importing legacy JSON state into the schema.
Usage#
marketdeck db <subcommand>
Subcommands#
| Subcommand | What it does |
|---|---|
path | Print the resolved DB path. |
open | Open the DB and run migrations. Returns the schema version after migrations finish. |
import | Open + run the JSON importer. Returns per-source row counts. |
info | High-level stats — table row counts, file size on disk. |
Examples#
marketdeck db path
# → /home/<you>/.local/share/marketdeck/marketdeck.db
marketdeck db open --format text
marketdeck db info --format text
marketdeck db import --format text
Schema#
Schema migrations are an append-only list in db/schema.js. Each migration is a single function that runs idempotent DDL inside a transaction; the schema-version tracker prevents re-application. Current versions:
- v1 — initial: wallets, positions, analyses, paper_analysis_snapshots, import_log.
- v2 —
position_reviewstable + trailing-SL columns on positions. - v3 — analyses + paper-snapshots offload large blobs to
<uuid>.json.gz. - v4 —
backtest_runsmetadata + sibling gzipped equity-curve / trade files. - v5 / v6 — Hyperliquid asset metadata cache (re-keyed in v6 to support HIP-3 builder dexes).
- v7 —
position_reviews.reject_reasonfor unparsed AI replies. - v8 —
paper_equity_snapshotsfor end-of-UTC-day curve points. - v9 —
notification_logfor persistent desktop-notification recovery. - v10 — explicit foreign keys on positions / position_reviews / paper_analysis_snapshots with cascade semantics.
PRAGMA foreign_keys = ON is set on every open. WAL mode + synchronous=NORMAL + busy_timeout=5000 give multi-process write safety across the CLI, the daemon, the GNOME plugin's panel, and its window subprocesses.
Importer#
The JSON importer pulls pre-DB state from:
- Wallet records under
~/.local/share/marketdeck/wallets/. - Per-coin analyses under
~/.local/share/marketdeck/analyses/.
The import_log table tracks which sources have been imported so re-runs are idempotent. To force a reimport, delete the relevant row from import_log and run marketdeck db import again.