diff --git a/backend/app/db.py b/backend/app/db.py index 9d2c156..fe7397e 100644 --- a/backend/app/db.py +++ b/backend/app/db.py @@ -418,12 +418,16 @@ def init_db() -> None: ON requests_cache (updated_at DESC, request_id DESC) """ ) - conn.execute( - """ - CREATE INDEX IF NOT EXISTS idx_requests_cache_requested_by_id_created_at - ON requests_cache (requested_by_id, created_at DESC, request_id DESC) - """ - ) + try: + conn.execute( + """ + CREATE INDEX IF NOT EXISTS idx_requests_cache_requested_by_id_created_at + ON requests_cache (requested_by_id, created_at DESC, request_id DESC) + """ + ) + except sqlite3.OperationalError: + # Older databases may not have requested_by_id until later migrations run. + pass conn.execute( """ CREATE INDEX IF NOT EXISTS idx_requests_cache_requested_by_norm_created_at