diff --git a/lib/db.py b/lib/db.py index d419a6a..a7c1f3d 100644 --- a/lib/db.py +++ b/lib/db.py @@ -9,7 +9,7 @@ from . import config logger = logging.getLogger("pipeline.db") -SCHEMA_VERSION = 20 +SCHEMA_VERSION = 21 SCHEMA_SQL = """ CREATE TABLE IF NOT EXISTS schema_version ( @@ -70,6 +70,7 @@ CREATE TABLE IF NOT EXISTS prs ( last_attempt TEXT, cost_usd REAL DEFAULT 0, auto_merge INTEGER DEFAULT 0, + github_pr INTEGER, created_at TEXT DEFAULT (datetime('now')), merged_at TEXT ); @@ -546,6 +547,17 @@ def migrate(conn: sqlite3.Connection): conn.commit() logger.info("Migration v20: added conflict retry columns to prs") + if current < 21: + try: + conn.execute("ALTER TABLE prs ADD COLUMN github_pr INTEGER") + except sqlite3.OperationalError: + pass + conn.execute( + "CREATE INDEX IF NOT EXISTS idx_prs_github_pr ON prs (github_pr) WHERE github_pr IS NOT NULL" + ) + conn.commit() + logger.info("Migration v21: added github_pr column + index to prs") + if current < SCHEMA_VERSION: conn.execute( "INSERT OR REPLACE INTO schema_version (version) VALUES (?)",