From ff08d81de317433a244ed09992006fdca2bfbc37 Mon Sep 17 00:00:00 2001 From: James Wong Date: Wed, 29 Mar 2017 16:23:40 -0400 Subject: [PATCH] nullify dependents when destroying configuration_script_sources and configuration_scripts https://github.com/ManageIQ/manageiq/pull/14432 --- app/models/configuration_script_base.rb | 5 ++++- app/models/configuration_script_source.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/configuration_script_base.rb b/app/models/configuration_script_base.rb index 38e472852d0..b22d134d73e 100644 --- a/app/models/configuration_script_base.rb +++ b/app/models/configuration_script_base.rb @@ -9,7 +9,10 @@ class ConfigurationScriptBase < ApplicationRecord belongs_to :manager, :class_name => "ExtManagementSystem" belongs_to :parent, :class_name => "ConfigurationScriptBase" - has_many :children, :class_name => "ConfigurationScriptBase", :foreign_key => "parent_id" + has_many :children, + :class_name => "ConfigurationScriptBase", + :foreign_key => "parent_id", + :dependent => :nullify has_many :authentication_configuration_script_bases, :dependent => :destroy diff --git a/app/models/configuration_script_source.rb b/app/models/configuration_script_source.rb index 19807c1fc36..3144f279185 100644 --- a/app/models/configuration_script_source.rb +++ b/app/models/configuration_script_source.rb @@ -1,5 +1,5 @@ class ConfigurationScriptSource < ApplicationRecord - has_many :configuration_script_payloads + has_many :configuration_script_payloads, :dependent => :destroy belongs_to :authentication belongs_to :manager, :class_name => "ExtManagementSystem"