mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 09:27:19 +02:00
16 lines
502 B
Ruby
16 lines
502 B
Ruby
class UpdateContactData < ActiveRecord::Migration
|
|
def change
|
|
Address.all.each do |a|
|
|
c = a.contact
|
|
c.city = a.city
|
|
c.street = ""
|
|
c.street << a.street if a.street.present?
|
|
c.street << "\n#{a.street2}" if a.street2.present?
|
|
c.street << "\n#{a.street3}" if a.street3.present?
|
|
c.zip = a.zip
|
|
c.country_code = a.country_code
|
|
c.state = a.state
|
|
puts "#{c.id} changes: #{c.changes.inspect}; #{c.save(validate: false)}"
|
|
end
|
|
end
|
|
end
|