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.
This commit is contained in:
glifocat
2026-05-18 11:43:45 +02:00
parent d1a53a0deb
commit 4635c406e7
2 changed files with 7 additions and 2 deletions
+1
View File
@@ -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.
+6 -2
View File
@@ -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;
});