Skip to content

clean up routine task references upon task deletion#1677

Open
Abhishek2005-ard wants to merge 1 commit into
aryandas2911:mainfrom
Abhishek2005-ard:fix/dangling-db-references-task-deletion
Open

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

Conversation

@Abhishek2005-ard

Copy link
Copy Markdown
Contributor

Description

When a single task is deleted via the deleteTask controller, the backend deletes the task from the database but leaves its ID referenced inside any Routine models that used it. This leads to orphaned task references inside routines, resulting in database integrity errors.

This PR updates the deleteTask handler to pull the deleted task's ID from the items array of the Routine collection, ensuring referential integrity (matching the cleanup behavior of bulkDeleteTasks).

Changes Made

  • Added a Routine.updateMany with a $pull operation in backend/controllers/taskController.js to remove references to the deleted task ID.

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