Make SchoolProject destroy dependent Transitions #667
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix an incorrect
depdendent:rule betweenSchoolProjectandSchoolProjectTransition.Status
Points for consideration:
What's changed?
Database and Model Relations and Nullify Rules
Previously, when a SchoolProject was destroyed, there was a rule that dependent
school_project_transitionswould be nullified rather than destroyed.At the same time, the definition of a
SchoolProjectTransitionstates that theschool_project_id, which refers to the project being transitioned, CANNOT be null.Therefore, when PR #637 allowed deletion of Students and, consequently, Projects, the error in these relations and nullification rules was exposed.
This leads to an error when deleting a Student who owns projects which have been transitioned.
This PR changes the
dependent:rule between SchoolProject and SchoolProjectTransition to destroy the transition when the Proejct is destroyed. It also adds a test to ensure this happens.Follow on Work
While this PR fixes the immediate problem, there remains an issue that
SchoolStudentsController#destroy_batchwill return a200status code on both success and failure. I suggest we address this in a follow up issue.Steps to perform after deploying to production
NA