Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix column collations and table default collation in a migration #94

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

coord-e
Copy link
Member

@coord-e coord-e commented Apr 16, 2024

follow-up of #93

In MySQL 8.0, the default collation used when charset is utf8mb4 is changed to utf8mb4_0900_ai_ci.
https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html

The column collations and table default collation will be utf8mb4_0900_ai_ci after we ran existing migrations on MySQL 8.0 to create tables because we did not specify collation in create_table (thus the default is used). This usually happens on testing/development environment, but we want to keep utf8mb4_general_ci in every environment.

I add a new migration to deal with this situation. This migration performs ALTER TABLE ... CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci on most tables to fix column collations and table default collation to utf8mb4_general_ci. This is expected to actually change the schema only in testing/development environment as described above. I've confirmed that this migration does nothing and finishes instantly when the actual schema already uses utf8mb4_general_ci.

@coord-e coord-e requested a review from a team April 16, 2024 06:13
@coord-e coord-e marked this pull request as draft April 16, 2024 06:29
@coord-e coord-e removed the request for review from a team April 16, 2024 06:29
@coord-e
Copy link
Member Author

coord-e commented Apr 16, 2024

I've missed schema.rb changes... (converted to draft)

@coord-e coord-e marked this pull request as ready for review April 16, 2024 06:44
@coord-e
Copy link
Member Author

coord-e commented Apr 16, 2024

included schema.rb changes. @cookpad/infra please review 🙏

@coord-e coord-e requested a review from a team April 16, 2024 06:44
Copy link

@nekketsuuu nekketsuuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO: It would be beneficial to add a line about this to the change log to avoid PendingMigrationError.

@coord-e
Copy link
Member Author

coord-e commented Apr 16, 2024

IMHO: It would be beneficial to add a line about this to the change log to avoid PendingMigrationError.

that would be nice, added to changelog 6b3d85e#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4edR8

@coord-e coord-e merged commit 9a8e4e8 into cookpad:master Apr 16, 2024
4 checks passed
@coord-e coord-e deleted the fix-collation-migration branch April 16, 2024 23:39
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