From 27fa22eee1c8005c62c4feec538175ae38c5ea55 Mon Sep 17 00:00:00 2001 From: grymphen Date: Wed, 13 May 2026 18:29:25 +0200 Subject: [PATCH] cwa import --- db.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/db.py b/db.py index fc85aa9..a335808 100644 --- a/db.py +++ b/db.py @@ -65,6 +65,19 @@ def init_db() -> None: cached_at TEXT NOT NULL ); """) + _migrate(conn) + + +def _migrate(conn: sqlite3.Connection) -> None: + existing = {row[1] for row in conn.execute("PRAGMA table_info(sync_runs)")} + if "books_imported" not in existing: + conn.execute("ALTER TABLE sync_runs ADD COLUMN books_imported INTEGER DEFAULT 0") + for old_col in ("books_uploaded", "books_skipped"): + if old_col in existing: + try: + conn.execute(f"ALTER TABLE sync_runs DROP COLUMN {old_col}") + except Exception: + pass # --- Settings ---