From c48a276062aa0f0d577de5ec20a86a0e905dcd0c Mon Sep 17 00:00:00 2001 From: ai-bot Date: Sun, 15 Nov 2026 18:29:51 +0000 Subject: [PATCH] Seed the bank row and its setting --- database.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/database.py b/database.py index 3f0c6bc..db22e35 100644 --- a/database.py +++ b/database.py @@ -86,7 +86,7 @@ def apply_schema(conn=None): def seed_defaults(conn=None): - """Insert the default settings and the seeded rates. Idempotent.""" + """Insert the default settings, the seeded rates and the bank. Idempotent.""" own = conn is None if own: conn = connect() @@ -101,6 +101,20 @@ def seed_defaults(conn=None): " VALUES ('BTC', ?, ?, ?)", (date, nok_per_btc_ore, SETTING_DEFAULTS["year_end_price_source"]), ) + # The bank holds no sats and is nobody's holding (section 3.11). + conn.execute( + "INSERT OR IGNORE INTO markets (name, kind, taxable, archived)" + " VALUES (?, ?, 0, 1)", + (BANK_NAME, BANK_KIND), + ) + row = conn.execute( + "SELECT id FROM markets WHERE name = ?", (BANK_NAME,) + ).fetchone() + if row is not None: + conn.execute( + "INSERT OR IGNORE INTO settings (key, value) VALUES ('bank_market_id', ?)", + (str(row["id"]),), + ) conn.commit() finally: if own: