Created
July 9, 2010 03:57
-
-
Save dchentech/469012 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 把部分latin1编码的mysql表转化为UTF8编码 | |
ActiveRecord::Base.connection.tables.select do |t| | |
ActiveRecord::Base.connection.execute("show create table #{t}").to_a[0][1].match(/CHARSET=latin1/) | |
end.each do |t| | |
ActiveRecord::Base.connection.execute("alter table #{t} CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment