fix: Graceful fallback if Migration 031 not yet applied
All checks were successful
Deploy Development / deploy (push) Successful in 52s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 15s

- Wrap focus_contributions loading in try/catch
- If tables don't exist (migration not run), continue without them
- Backward compatible with pre-migration state
- Logs warning but doesn't crash
This commit is contained in:
Lars 2026-03-27 20:24:16 +01:00
parent 34ea51b8bd
commit ba5d460e92

View File

@ -720,6 +720,7 @@ def get_goals_grouped(session: dict = Depends(require_auth)):
focus_map = {} # goal_id → [contributions]
if goal_ids:
try:
placeholders = ','.join(['%s'] * len(goal_ids))
cur.execute(f"""
SELECT
@ -743,6 +744,10 @@ def get_goals_grouped(session: dict = Depends(require_auth)):
'category': row['category'],
'contribution_weight': float(row['contribution_weight'])
})
except Exception as e:
# Migration 031 not yet applied - focus_contributions tables don't exist
print(f"[WARNING] Could not load focus_contributions: {e}")
# Continue without focus_contributions (backward compatible)
# Group by category and attach focus_contributions
grouped = {}