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.
This commit is contained in:
Matt 2026-04-30 03:22:24 +00:00
commit 1b3ad1bf9e

View file

@ -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