Fix column collations and table default collation in a migration #94
+51
−16
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.
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.