feat: Wire up initiative deletion end-to-end

Add deleteInitiative tRPC procedure, wire Delete button in InitiativeCard
with confirm dialog (Shift+click bypass), remove unused onDelete prop chain.
Fix agents table FK constraints (initiative_id, account_id missing ON DELETE
SET NULL) via table recreation migration. Register conversations migration
in journal. Expand cascade delete tests to cover pages, projects, change
sets, agents (set null), and conversations (set null).
This commit is contained in:
Lukas May
2026-02-18 17:54:53 +09:00
parent 80aa3e42fb
commit 6fa025251e
8 changed files with 180 additions and 13 deletions

View File

@@ -0,0 +1,32 @@
-- Fix agents table FK constraints: initiative_id and account_id need ON DELETE SET NULL
-- SQLite cannot ALTER column constraints, so we must recreate the table
CREATE TABLE `agents_new` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`task_id` text REFERENCES `tasks`(`id`) ON DELETE SET NULL,
`initiative_id` text REFERENCES `initiatives`(`id`) ON DELETE SET NULL,
`session_id` text,
`worktree_id` text NOT NULL,
`provider` text DEFAULT 'claude' NOT NULL,
`account_id` text REFERENCES `accounts`(`id`) ON DELETE SET NULL,
`status` text DEFAULT 'idle' NOT NULL,
`mode` text DEFAULT 'execute' NOT NULL,
`pid` integer,
`exit_code` integer,
`output_file_path` text,
`result` text,
`pending_questions` text,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
`user_dismissed_at` integer
);--> statement-breakpoint
INSERT INTO `agents_new` SELECT
`id`, `name`, `task_id`, `initiative_id`, `session_id`, `worktree_id`,
`provider`, `account_id`, `status`, `mode`, `pid`, `exit_code`,
`output_file_path`, `result`, `pending_questions`,
`created_at`, `updated_at`, `user_dismissed_at`
FROM `agents`;--> statement-breakpoint
DROP TABLE `agents`;--> statement-breakpoint
ALTER TABLE `agents_new` RENAME TO `agents`;--> statement-breakpoint
CREATE UNIQUE INDEX `agents_name_unique` ON `agents` (`name`);

View File

@@ -169,6 +169,20 @@
"when": 1771545600000,
"tag": "0023_rename_breakdown_decompose",
"breakpoints": true
},
{
"idx": 24,
"version": "6",
"when": 1771632000000,
"tag": "0024_add_conversations",
"breakpoints": true
},
{
"idx": 25,
"version": "6",
"when": 1771718400000,
"tag": "0025_fix_agents_fk_constraints",
"breakpoints": true
}
]
}