Skip to content

clean up routine task references upon task deletion#1676

Open
Abhishek2005-ard wants to merge 1 commit into
aryandas2911:mainfrom
Abhishek2005-ard:fix/task-deletion-routine-integrity
Open

clean up routine task references upon task deletion#1676
Abhishek2005-ard wants to merge 1 commit into
aryandas2911:mainfrom
Abhishek2005-ard:fix/task-deletion-routine-integrity

Conversation

@Abhishek2005-ard

Copy link
Copy Markdown
Contributor

Description

When a task is deleted via the single task deletion endpoint (deleteTask controller), the backend removes the task from the database but fails to clean up corresponding references in the Routine model. This leaves orphaned taskId references inside user routines, leading to database integrity issues and potential API errors when retrieving or modifying routines.

This PR resolves the issue by executing a $pull operation on the Routine collection inside the deleteTask handler to clear references to the deleted task, matching the cleanup logic already used in the bulkDeleteTasks handler.

Changes Made

  • Updated deleteTask in backend/controllers/taskController.js to run Routine.updateMany with a $pull action targeting the deleted taskId.

Verification & Testing

  • Ran backend linter: npm run lint (Passed)
  • Ran backend unit tests: npm run test (Passed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant