From 1b3ad1bf9ea224554c160947b465de776b14732f Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 30 Apr 2026 03:22:24 +0000 Subject: [PATCH] fix(google_places): add schema migration for Google columns The place_cache table was missing google_place_id, google_data, and google_fetched_at columns needed by the Google Places enrichment. Adds ALTER TABLE migration in _get_db() to add columns if missing, wrapped in try/except to handle existing columns gracefully. Fixes HTTP 500 on /api/place/W/* endpoints. --- lib/google_places.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/google_places.py b/lib/google_places.py index 8272b81..55cf051 100644 --- a/lib/google_places.py +++ b/lib/google_places.py @@ -47,6 +47,18 @@ def _get_db(): ) """) _db_conn.commit() + # Schema migration: add Google columns to place_cache if missing + for col, coldef in [ + ('google_place_id', 'TEXT'), + ('google_data', 'TEXT'), + ('google_fetched_at', 'INTEGER'), + ]: + try: + _db_conn.execute(f'ALTER TABLE place_cache ADD COLUMN {col} {coldef}') + logger.info(f'Added column {col} to place_cache') + except sqlite3.OperationalError: + pass # Column already exists + _db_conn.commit() return _db_conn