Fix Language foreign key column lengths #5623
Open
+162
−0
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 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.
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 🤖