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:
@@ -175,8 +175,9 @@ export function updateTask(id: string, updates: Partial<Pick<ScheduledTask, 'pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function deleteTask(id: string): void {
|
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 task_run_logs WHERE task_id = ?').run(id);
|
||||||
|
db.prepare('DELETE FROM scheduled_tasks WHERE id = ?').run(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDueTasks(): ScheduledTask[] {
|
export function getDueTasks(): ScheduledTask[] {
|
||||||
|
|||||||
Reference in New Issue
Block a user