Migrate country id-s to country codes

This commit is contained in:
Martin Lensment 2015-02-02 11:22:03 +02:00
parent ea6bdc19f9
commit 864c451a61
7 changed files with 41 additions and 11 deletions

View file

@ -0,0 +1,22 @@
class RefactorCountries < ActiveRecord::Migration
def change
add_column :registrars, :country_code, :string
add_column :users, :country_code, :string
add_column :addresses, :country_code, :string
Registrar.all.each do |x|
x.country_code = x.country_deprecated.try(:iso)
x.save(validate: false)
end
User.all.each do |x|
x.country_code = x.country_deprecated.try(:iso)
x.save(validate: false)
end
Address.all.each do |x|
x.country_code = x.country_deprecated.try(:iso)
x.save(validate: false)
end
end
end