"""SQLite schema for the media bot — subscriptions + digest state.""" from mautrix.util.async_db import Connection, UpgradeTable upgrade_table = UpgradeTable() @upgrade_table.register(description="Initial schema: subscriptions + digest_state") async def upgrade_v1(conn: Connection) -> None: await conn.execute( """ CREATE TABLE subscriptions ( mxid TEXT NOT NULL, sonarr_series_id INTEGER NOT NULL, title TEXT NOT NULL, added_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (mxid, sonarr_series_id) ) """ ) await conn.execute( """ CREATE TABLE digest_state ( id INTEGER PRIMARY KEY CHECK (id = 1), last_run_date TEXT ) """ ) await conn.execute("INSERT INTO digest_state (id, last_run_date) VALUES (1, NULL)")