From 6b6fc31328020bf0182ece02a5708dbf7b6b9a6c Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Mon, 3 Apr 2017 14:45:44 -0400 Subject: [PATCH] Merge pull request #14567 from jameswnl/nullify-dependents Nullify dependents when destroying configuration_script_sources/configuration_scripts (cherry picked from commit 2875c6caf47fae1fce9467e5191862ebc59188b3) https://bugzilla.redhat.com/show_bug.cgi?id=1438594 --- 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"