From e264edcd72a0f32b4867e57e6eafa188afbfbe3b Mon Sep 17 00:00:00 2001 From: Sulkta Date: Fri, 1 May 2026 20:42:05 -0700 Subject: [PATCH] discover: backfill mealie_group_id for existing households current_household_id() short-circuited on member-row presence and never called sync, so the mealie_group_id column added by migration 035 stayed NULL on existing households. Now: if the row is missing group_id, re-run sync_user_household once to backfill from who_am_i. After backfill the check is a cheap row read. --- cauldron/server.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cauldron/server.py b/cauldron/server.py index 6df246f..4d6a6ab 100644 --- a/cauldron/server.py +++ b/cauldron/server.py @@ -244,7 +244,15 @@ def create_app() -> Flask: return None h = db.get_user_household_id(u["sub"]) if h is None: - h = sync_user_household(u["sub"]) + return sync_user_household(u["sub"]) + # Re-sync once if the row is missing mealie_group_id (added in + # migration 035). This is the upgrade-path backfill: existing + # households were created before the column existed and need a + # one-shot sync to populate it. After that this is a cheap + # short-circuit on a per-request lookup. + hh = db.get_household(h) + if hh and not hh.get("mealie_group_id"): + sync_user_household(u["sub"]) return h def monday_of(d: date) -> date: