Created
August 18, 2016 10:39
-
-
Save timharding/bfebb9a6d95a9e837b1463d4a1a10d4e 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
Rails.application.eager_load! if Rails.env.development? | |
ActiveRecord::Base.descendants.each do |d| | |
puts d.table_name | |
d.columns_hash.each do |f, t| | |
if t.type == :string || t.type == :text | |
puts "\t#{f} #{t.type}" | |
queries = [] | |
queries << "#{f} = replace(#{f}, '“', '“')" | |
queries << "#{f} = replace(#{f}, '’', '’')" | |
queries << "#{f} = replace(#{f}, '‘', '‘')" | |
queries << "#{f} = replace(#{f}, '—', '–')" | |
queries << "#{f} = replace(#{f}, '–', '—')" | |
queries << "#{f} = replace(#{f}, '•', '-')" | |
queries << "#{f} = replace(#{f}, '…', '…')" | |
queries << "#{f} = replace(#{f}, 'â€', '”')" | |
queries << "#{f} = replace(#{f}, '―', '—')" | |
queries << "#{f} = replace(#{f}, '£', '£')" | |
queries << "#{f} = replace(#{f}, 'é', 'é')" | |
queries << "#{f} = replace(#{f}, 'ö', 'ö')" | |
queries.each do |q| | |
d.update_all(q) | |
end | |
end | |
end | |
end;nil | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment