diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index 53713330dc6..746a9cf5a2f 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -49,7 +49,7 @@ def self.api_allowed_attributes has_many :hardwares, :through => :vms_and_templates has_many :networks, :through => :hardwares has_many :disks, :through => :hardwares - has_many :physical_servers, :foreign_key => :ems_id, :inverse_of => :ext_management_system + has_many :physical_servers, :foreign_key => :ems_id, :inverse_of => :ext_management_system, :dependent => :destroy has_many :storages, -> { distinct }, :through => :hosts has_many :ems_events, -> { order("timestamp") }, :class_name => "EmsEvent", :foreign_key => "ems_id", diff --git a/app/models/physical_server.rb b/app/models/physical_server.rb index ce3dcfa5ffe..17edc56683d 100644 --- a/app/models/physical_server.rb +++ b/app/models/physical_server.rb @@ -27,7 +27,7 @@ class PhysicalServer < ApplicationRecord has_one :host, :inverse_of => :physical_server has_one :asset_detail, :as => :resource, :dependent => :destroy has_many :guest_devices, :through => :hardware - has_many :miq_alert_statuses, :as => :resource, :dependent => :destroy + has_many :miq_alert_statuses, :as => :resource, :dependent => :destroy, :inverse_of => :physical_server scope :with_hosts, -> { where("physical_servers.id in (select hosts.physical_server_id from hosts)") }