Skip to content

Commit

Permalink
Merge pull request #444 from agrare/fix_splitting_storages_of_archive…
Browse files Browse the repository at this point in the history
…d_hosts

Fix splitting storages for archived hosts
  • Loading branch information
bdunne authored Dec 10, 2019
2 parents 3822327 + 55a0db8 commit 8b5b6d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions db/migrate/20190729170013_split_storages_per_ems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def up
ems_id = hs.host&.ems_id
datastore_ems_ref = hs.ems_ref || storage.ems_ref

next if ems_id.nil?

[ems_id, datastore_ems_ref]
end

Expand All @@ -44,6 +42,8 @@ def up

# Link up the host_storage records to the new storages
host_storages_by_ems_id_and_ems_ref.each_key do |ems_id, ems_ref|
next if ems_id.nil?

# Connect all of the HostStorage records to the new Storage record
host_storages_ids = host_storages_by_ems_id_and_ems_ref[[ems_id, ems_ref]].map(&:id)
storage = storages_by_ems_id_and_ems_ref[[ems_id, ems_ref]]
Expand Down
4 changes: 2 additions & 2 deletions spec/migrations/20190729170013_split_storages_per_ems_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ class Host < ActiveRecord::Base
end

context "with an archived host" do
let(:archived_host) do
let!(:archived_host) do
host_stub.create!.tap do |h|
host_storage_stub.create!(:host_id => h.id, :storage_id => storage.id, ems_ref => "datastore-3")
host_storage_stub.create!(:host_id => h.id, :storage_id => storage.id, :ems_ref => "datastore-3")
end
end

Expand Down

0 comments on commit 8b5b6d3

Please sign in to comment.