fix(profiles): commit the whole profile delete cascade once

delete_generations_by_profile (and the version sweep under it) committed on
their own, so a failure between the generation sweep and the profile row
left the profile listed with its history already gone. Both helpers take a
commit flag now, and delete_profile passes commit=False so the single
db.commit() at its end publishes the entire cascade. Other callers keep the
default and are unchanged.
This commit is contained in:
jamiepine
2026-10-04 00:19:41 +00:00
committed by capy-ai-staging[bot]
parent 012c957f4d
commit f0f3802b79
3 changed files with 19 additions and 11 deletions
+1 -1
View File
@@ -440,7 +440,7 @@ async def delete_profile(
# Generations carry a non-null FK to the profile and the history query
# inner-joins profiles, so anything left behind here becomes a row the UI
# can never show and a .wav in data/generations the user can never reclaim.
deleted_generations = await history.delete_generations_by_profile(profile_id, db)
deleted_generations = await history.delete_generations_by_profile(profile_id, db, commit=False)
if deleted_generations:
logger.info("Deleted %d generations belonging to profile %s", deleted_generations, profile_id)