fix: mysql referential integrity error in update_user during retire_forum#39
Merged
Alam-2U merged 1 commit intorelease-ulmofrom Apr 23, 2026
Merged
fix: mysql referential integrity error in update_user during retire_forum#39Alam-2U merged 1 commit intorelease-ulmofrom
Alam-2U merged 1 commit intorelease-ulmofrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes user retirement failures after the MongoDB → MySQL migration by preventing unintended updates to auth_user fields that can violate MySQL constraints during retire_forum.
Changes:
- Limit Django
User.save()calls in the MySQL backend to only updateusername(viaupdate_fields) and skip saving when no user fields changed. - Adjust the retire-user flow to only blank
emailfor non-MySQL backends (MongoDB), since LMS ownsauth_user.emailin the MySQL deployment. - Bump package version to
0.5.2.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
forum/backends/mysql/api.py |
Restricts User.save() to username updates (and only when needed) to avoid touching email and triggering constraint issues. |
forum/api/users.py |
Makes retirement email-blanking conditional by backend type (MongoDB vs MySQL). |
forum/__init__.py |
Version bump to reflect the fix release. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
545cef6 to
2b7dec1
Compare
naincy128
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
After migrating the forum backend from MongoDB to MySQL, the
retire_forumAPI started failing due to MySQL-specific referential integrity constraints that were not properly handled in the existing implementation.A previous fix was introduced in PR #38, but the issue persists. The failure occurs because
user.save()attempts to update the email field in theauth_usertable, which has already been modified by LMS, leading to conflicts.This PR addresses the issue by ensuring that updates to
auth_userdo not violate existing constraints and by aligning the deletion/update flow with MySQL’s referential integrity requirements.Ticket
COSMO2-917