@allpepper/task-orchestrator 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/repos/projects.ts +15 -10
package/package.json
CHANGED
package/src/repos/projects.ts
CHANGED
|
@@ -253,12 +253,19 @@ export function deleteProject(id: string, options?: { cascade?: boolean }): Resu
|
|
|
253
253
|
|
|
254
254
|
const result = transaction(() => {
|
|
255
255
|
if (cascade) {
|
|
256
|
-
// Get all
|
|
257
|
-
const
|
|
258
|
-
'SELECT id FROM
|
|
256
|
+
// Get all feature IDs for this project first (needed for task cleanup)
|
|
257
|
+
const featureIds = queryAll<{ id: string }>(
|
|
258
|
+
'SELECT id FROM features WHERE project_id = ?',
|
|
259
259
|
[id]
|
|
260
260
|
);
|
|
261
261
|
|
|
262
|
+
// Get all task IDs: tasks directly under project OR under features of this project
|
|
263
|
+
const taskIds = queryAll<{ id: string }>(
|
|
264
|
+
`SELECT id FROM tasks WHERE project_id = ?
|
|
265
|
+
OR feature_id IN (SELECT id FROM features WHERE project_id = ?)`,
|
|
266
|
+
[id, id]
|
|
267
|
+
);
|
|
268
|
+
|
|
262
269
|
// Delete each task's dependencies, sections, and tags
|
|
263
270
|
for (const task of taskIds) {
|
|
264
271
|
execute('DELETE FROM dependencies WHERE from_task_id = ? OR to_task_id = ?', [task.id, task.id]);
|
|
@@ -266,13 +273,11 @@ export function deleteProject(id: string, options?: { cascade?: boolean }): Resu
|
|
|
266
273
|
deleteTags(task.id, EntityType.TASK);
|
|
267
274
|
}
|
|
268
275
|
|
|
269
|
-
// Delete all tasks
|
|
270
|
-
execute(
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
'SELECT id FROM features WHERE project_id = ?',
|
|
275
|
-
[id]
|
|
276
|
+
// Delete all tasks: directly under project OR under features of this project
|
|
277
|
+
execute(
|
|
278
|
+
`DELETE FROM tasks WHERE project_id = ?
|
|
279
|
+
OR feature_id IN (SELECT id FROM features WHERE project_id = ?)`,
|
|
280
|
+
[id, id]
|
|
276
281
|
);
|
|
277
282
|
|
|
278
283
|
// Delete each feature's sections and tags
|