Browse Source

feat: don't add old_id to new location as there is a uniqueness constraint on this attribute

pull/2011/head
natdeanlewissoftwire 3 years ago
parent
commit
2b8ba97252
  1. 2
      app/services/merge/merge_organisations_service.rb

2
app/services/merge/merge_organisations_service.rb

@ -70,7 +70,7 @@ private
new_scheme = Scheme.create!(scheme.attributes.except("id", "owning_organisation_id").merge(owning_organisation: @absorbing_organisation)) new_scheme = Scheme.create!(scheme.attributes.except("id", "owning_organisation_id").merge(owning_organisation: @absorbing_organisation))
scheme.locations.each do |location| scheme.locations.each do |location|
new_scheme.locations << Location.new(location.attributes.except("id", "scheme_id")) unless location.deactivated? new_scheme.locations << Location.new(location.attributes.except("id", "scheme_id", "old_id")) unless location.deactivated?
end end
@merged_schemes[merging_organisation.name] << { name: new_scheme.service_name, code: new_scheme.id } @merged_schemes[merging_organisation.name] << { name: new_scheme.service_name, code: new_scheme.id }
SchemeDeactivationPeriod.create!(scheme:, deactivation_date: @merge_date) SchemeDeactivationPeriod.create!(scheme:, deactivation_date: @merge_date)

Loading…
Cancel
Save