fix(coderd): clean up task snapshots on task deletion by mafredri · Pull Request #21949 · coder/coder

@mafredri

Task snapshots were orphaned when tasks were soft-deleted. The
`task_snapshots` table has an `ON DELETE CASCADE` foreign key, but
that only fires on hard deletes.

Modified DeleteTask to use a CTE that atomically soft-deletes the
task and removes its snapshot in a single transaction. The query now
returns just the task UUID instead of the full row.

Closes coder/internal#1283

@mafredri mafredri marked this pull request as ready for review

February 6, 2026 09:44

johnstcn

DanielleMaywood

@mafredri mafredri deleted the mafredri/feat-tasks-cleanup-snapshots branch

February 6, 2026 09:55