internetee-registry/db/migrate/20150202084444_refactor_countries.rb
2015-02-02 11:22:03 +02:00

22 lines
582 B
Ruby

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