From 4635c406e7eeb563cc655a212d5168e13cacc34a Mon Sep 17 00:00:00 2001 From: glifocat Date: Mon, 18 May 2026 11:43:45 +0200 Subject: [PATCH] review(cli): explicit container_configs delete in cascade migration-014 has ON DELETE CASCADE on container_configs.agent_group_id, so the row was already being removed by the final DELETE FROM agent_groups. Doing the delete explicitly here mirrors the shape of every other table in the cascade and lets the handler surface a container_configs count in the `removed` response, matching the rest of the breakdown. --- src/cli/resources/groups.test.ts | 1 + src/cli/resources/groups.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cli/resources/groups.test.ts b/src/cli/resources/groups.test.ts index 892ebcf4a..bb5f08af8 100644 --- a/src/cli/resources/groups.test.ts +++ b/src/cli/resources/groups.test.ts @@ -156,6 +156,7 @@ describe('groups CLI delete cascades dependent rows (#2525)', () => { messaging_group_agents: 1, agent_group_members: 1, user_roles: 1, + container_configs: 1, }); // The group and every dependent row must be gone. diff --git a/src/cli/resources/groups.ts b/src/cli/resources/groups.ts index 161d1700d..e3765c0fb 100644 --- a/src/cli/resources/groups.ts +++ b/src/cli/resources/groups.ts @@ -99,6 +99,7 @@ registerResource({ messaging_group_agents: 0, agent_group_members: 0, user_roles: 0, + container_configs: 0, }; if (hasAgentDestinations) { @@ -135,8 +136,11 @@ registerResource({ .prepare('DELETE FROM agent_group_members WHERE agent_group_id = ?') .run(groupId).changes; counts.user_roles = db.prepare('DELETE FROM user_roles WHERE agent_group_id = ?').run(groupId).changes; - // container_configs.agent_group_id has ON DELETE CASCADE, so the - // matching row is removed automatically by the final delete below. + // migration-014 has ON DELETE CASCADE on container_configs.agent_group_id; + // the explicit delete here mirrors the other tables and surfaces the count. + counts.container_configs = db + .prepare('DELETE FROM container_configs WHERE agent_group_id = ?') + .run(groupId).changes; db.prepare('DELETE FROM agent_groups WHERE id = ?').run(groupId); return counts; });