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:
@@ -1111,6 +1111,10 @@ class SQLModelRepository(BaseRepository):
|
||||
text("DELETE FROM lans WHERE topology_id = :t"),
|
||||
params,
|
||||
)
|
||||
await session.execute(
|
||||
text("DELETE FROM topology_mutations WHERE topology_id = :t"),
|
||||
params,
|
||||
)
|
||||
result = await session.execute(
|
||||
select(Topology).where(Topology.id == topology_id)
|
||||
)
|
||||
|
||||
@@ -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}
|
||||
)
|
||||
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.get_topology(t_id) is None
|
||||
|
||||
Reference in New Issue
Block a user