Fix Language foreign key column lengths#5623
Merged
bjester merged 2 commits intolearningequality:hotfixesfrom Jan 13, 2026
Merged
Fix Language foreign key column lengths#5623bjester merged 2 commits intolearningequality:hotfixesfrom
bjester merged 2 commits intolearningequality:hotfixesfrom
Conversation
Member
Author
|
And... of course I should have rerun the tests after rebasing... |
When Language.id was changed from max_length=7 to max_length=14 in migration 0081, Django 1.9 did not cascade the primary key column size change to foreign key and many-to-many junction table columns. This migration fixes those columns for databases that were created before the migration squash. It is idempotent - columns that are already varchar(14) are not modified. Fixes: contentcuration_channel.language_id Fixes: contentcuration_channel_included_languages.language_id Fixes: contentcuration_contentnode.language_id Fixes: contentcuration_file.language_id Adds migration test that deliberately corrupts the DB columns then runs the migration and confirms the fix.
bjester
requested changes
Jan 9, 2026
Member
bjester
left a comment
There was a problem hiding this comment.
The only column that is still limited to 7 characters is contentcuration_channel_included_languages.language_id. This makes sense because that's where the error occurred, and if a channel already included content for a language that exceeded the limit, that means a content node and file must already have it. I've confirmed, on every cloud instance DB, the aforementioned column is the only column named language_id that is less than 14 characters limit.
After verification on production servers, only the contentcuration_channel_included_languages junction table is affected by the varchar(7) issue. The other FK columns (channel.language_id, contentnode.language_id, file.language_id) are already varchar(14). This simplifies the migration to only fix the one affected column. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Member
Author
|
Have updated with a follow up commit to narrow the scope here - left it as a follow up commit to make review easier, but we can squash merge this, as the first commit is not needed! |
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.
Summary
When Language.id was changed from max_length=7 to max_length=14 in migration 0081, Django 1.9 did not cascade the primary key column size change to many-to-many junction table columns.
This migration fixes the included_languages through table language_id column for databases that were created before the migration squash. It is idempotent - columns that are already varchar(14) are not modified.
Fixes: contentcuration_channel_included_languages.language_id
Adds migration test that deliberately corrupts the DB columns then runs the migration and confirms the fix.
References
Fixes #5618
Reviewer guidance
Because of our migration squashing, the bug is not extant on development machines, so coercing the database column length manually and then running the migration to ensure the change in the migration test was the best I could do here.
🤖 This was created by Claude Code. @rtibbles then reviewed the generated output, and made updates before making it ready for review 🤖