diff --git a/app/models/concerns/account/associations.rb b/app/models/concerns/account/associations.rb index 3040da01de..ec8766f709 100644 --- a/app/models/concerns/account/associations.rb +++ b/app/models/concerns/account/associations.rb @@ -19,6 +19,7 @@ module Account::Associations has_many :conversations, class_name: 'AccountConversation', dependent: :destroy, inverse_of: :account has_many :scheduled_statuses, inverse_of: :account, dependent: :destroy has_many :scheduled_expiration_statuses, inverse_of: :account, dependent: :destroy + has_many :ng_rule_histories, inverse_of: :account, dependent: :destroy # Notifications has_many :notifications, inverse_of: :account, dependent: :destroy diff --git a/app/services/delete_account_service.rb b/app/services/delete_account_service.rb index 0c90eeb82d..925b2efea6 100644 --- a/app/services/delete_account_service.rb +++ b/app/services/delete_account_service.rb @@ -170,6 +170,7 @@ class DeleteAccountService < BaseService purge_feeds! purge_other_associations! + remove_ng_rule_history_relations! unless keep_account_record? @account.destroy unless keep_account_record? end @@ -273,6 +274,10 @@ class DeleteAccountService < BaseService @account.save! end + def remove_ng_rule_history_relations! + @account.ng_rule_histories.update_all(account_id: nil) + end + def fulfill_deletion_request! @account.deletion_request&.destroy end