mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
dealing with invalid live data in migration
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user