Created
July 21, 2020 15:37
-
-
Save ctrlaltdylan/0c385e8bc70d3710b5c68f7f63e097a2 to your computer and use it in GitHub Desktop.
Change whole MySQL database collation to utf8mb4 with LHM
This file contains 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
class ChangeCollationDbWide < ActiveRecord::Migration[5.2] | |
def change | |
db = ActiveRecord::Base.connection | |
tables = ActiveRecord::Base.connection.tables.map { |t| t.to_sym } | |
tables.each do |t| | |
Lhm.change_table(t) do |table| | |
table.ddl "ALTER TABLE `#{table.name}` DEFAULT CHARACTER SET utf8mb4, DEFAULT COLLATE utf8mb4_unicode_ci" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment