Skip to content

Conversation

@rtibbles
Copy link
Member

@rtibbles rtibbles commented Jan 5, 2026

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 🤖

@rtibbles rtibbles added this to the Studio: Patch Releases milestone Jan 5, 2026
@rtibbles rtibbles marked this pull request as draft January 6, 2026 00:00
@rtibbles
Copy link
Member Author

rtibbles commented Jan 6, 2026

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.
@rtibbles rtibbles marked this pull request as ready for review January 6, 2026 00:04
@bjester bjester self-assigned this Jan 6, 2026
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.

3 participants