From 82f7113d39986e773afd66184af4001491d2b05d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 11:36:42 +0000 Subject: [PATCH] fix(db): add saved_searches table to runtime schema migrations The Alembic migration alone doesn't run automatically. Add the saved_searches table creation to _run_schema_migrations() in database.py so existing databases are upgraded at startup. Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- app/database.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/database.py b/app/database.py index 8272a973..61c59263 100644 --- a/app/database.py +++ b/app/database.py @@ -137,6 +137,28 @@ def _run_schema_migrations(engine: Any) -> None: except Exception as exc: logger.warning(f"Skipping filehash unique index drop: {exc}") + # Migration: Create saved_searches table for user-defined filter combinations + if "saved_searches" not in inspector.get_table_names(): + logger.info("Migrating: creating 'saved_searches' table") + with engine.begin() as conn: + conn.execute( + text( + """ + CREATE TABLE saved_searches ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + filters TEXT NOT NULL, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, + UNIQUE (user_id, name) + ) + """ + ) + ) + conn.execute(text("CREATE INDEX IF NOT EXISTS ix_saved_searches_user_id ON saved_searches (user_id)")) + logger.info("Migration complete: 'saved_searches' table created") + def get_db() -> Generator[Session, None, None]: """