dealing with invalid live data in migration

This commit is contained in:
Maikel Linke
2015-02-21 18:43:03 +11:00
parent e05d64a0b4
commit a522242e7a

View File

@@ -6,7 +6,14 @@ class AddAddressInstancesToExistingEnterpriseGroups < ActiveRecord::Migration
next if g.address.present?
address = Spree::Address.new(firstname: 'unused', lastname: 'unused', address1: 'undefined', city: 'undefined', zipcode: 'undefined', state: state, country: country, phone: 'undefined')
g.address = address
g.save
# some groups are invalid, because of a missing description
g.save!(validate: false)
end
end
def self.down
# we can't know which addresses were already there and which weren't
# and we can't remove addresses as long as they are referenced and
# required by the model
end
end