Fix task deletion FK constraint error

Delete child records (task_run_logs) before parent (scheduled_tasks) to avoid foreign key constraint violation when cancelling tasks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Gavriel
2026-02-01 17:31:32 +02:00
parent 2dedd18491
commit 847032d41e

View File

@@ -175,8 +175,9 @@ export function updateTask(id: string, updates: Partial<Pick<ScheduledTask, 'pro
}
export function deleteTask(id: string): void {
db.prepare('DELETE FROM scheduled_tasks WHERE id = ?').run(id);
// Delete child records first (FK constraint)
db.prepare('DELETE FROM task_run_logs WHERE task_id = ?').run(id);
db.prepare('DELETE FROM scheduled_tasks WHERE id = ?').run(id);
}
export function getDueTasks(): ScheduledTask[] {