Remove legacy cookie auth and Person-based recipe helper; add composite indices; spec updated

This commit is contained in:
jableader 2025-11-01 21:25:18 +11:00
parent 93b9869735
commit 0ba9634131
4 changed files with 10 additions and 2 deletions

View file

@ -201,7 +201,7 @@ Route surface lockdown:
- ✅ **Acceptance (initial)**: Added `tests/test_migration_households.py` covering: new tables exist, `household_id` columns exist, default household created, and data porting from `Person` to `User` and `HouseholdMember`. Full test suite passes.
- Pending follow-ups for this step:
- Add composite indices `(household_id, id)` where high-cardinality pagination will benefit.
- (Done) Add composite indices `(household_id, id)` where high-cardinality pagination will benefit (Recipe, Meal).
- Extend migration to add FK constraints from tenant tables to `Household(id)` where safe.
- Plan and implement data backfill for cross-table references once `users` replace `persons` in code.
- Ensure fresh bootstraps include `household_id` in all tenant table DDL (now updated for Ingredient, Recipe, Meal, ShoppingList, ShoppingListItem).

View file

@ -192,4 +192,4 @@ app = create_app()
DATABASE_PATH = settings.database_path
# get_db, cookie_person, and error_response are imported from api.deps
# get_db and error_response are imported from api.deps

View file

@ -58,6 +58,10 @@ async def create(conn):
await conn.execute(
"CREATE INDEX IF NOT EXISTS idx_meal_recipes_meal_id ON MealRecipe(meal_id);"
)
# Composite index for household-scoped pagination/lookups
await conn.execute(
"CREATE INDEX IF NOT EXISTS idx_meal_household_id_id ON Meal(household_id, id);"
)
async def insert_meal_participant(conn, meal_id: int, person_id: int, role: str):

View file

@ -36,6 +36,10 @@ async def create(conn):
await conn.execute(
"CREATE INDEX IF NOT EXISTS idx_recipe_name_hidden_id ON Recipe(name, date_hidden, id);"
)
# Composite index for fast household-scoped pagination
await conn.execute(
"CREATE INDEX IF NOT EXISTS idx_recipe_household_id_id ON Recipe(household_id, id);"
)
def _as_insert_field(recipe: Recipe, name: str):