fix(topology): delete topology_mutations in delete-cascade

delete_topology_cascade manually deletes status_events, edges, deckies
and lans but overlooked topology_mutations, so deleting any topology
that ever had a mutation enqueued (i.e. edits while active|degraded)
failed with an FK IntegrityError. Add the missing DELETE and extend
the cascade test to seed a mutation row.
This commit is contained in:
2026-04-22 17:50:30 -04:00
parent 3f460bab84
commit 5704e8fcce
2 changed files with 5 additions and 0 deletions

View File

@@ -1111,6 +1111,10 @@ class SQLModelRepository(BaseRepository):
text("DELETE FROM lans WHERE topology_id = :t"), text("DELETE FROM lans WHERE topology_id = :t"),
params, params,
) )
await session.execute(
text("DELETE FROM topology_mutations WHERE topology_id = :t"),
params,
)
result = await session.execute( result = await session.execute(
select(Topology).where(Topology.id == topology_id) select(Topology).where(Topology.id == topology_id)
) )

View File

@@ -138,6 +138,7 @@ async def test_cascade_delete_clears_all_children(repo):
{"topology_id": t_id, "decky_uuid": d_uuid, "lan_id": lan_id} {"topology_id": t_id, "decky_uuid": d_uuid, "lan_id": lan_id}
) )
await repo.update_topology_status(t_id, "deploying") await repo.update_topology_status(t_id, "deploying")
await repo.enqueue_topology_mutation(t_id, "noop", {"x": 1})
assert await repo.delete_topology_cascade(t_id) is True assert await repo.delete_topology_cascade(t_id) is True
assert await repo.get_topology(t_id) is None assert await repo.get_topology(t_id) is None