From ecf8287ce5f81aafefaa7b505f620c22527515d9 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 4 May 2018 20:47:23 +0900 Subject: Use prepend: true to evaluate always perform_fast_destroy than dependent: :destroy --- app/models/concerns/fast_destroy_all.rb | 2 +- app/models/project.rb | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'app/models') diff --git a/app/models/concerns/fast_destroy_all.rb b/app/models/concerns/fast_destroy_all.rb index 367a2df854f..7ea042c6742 100644 --- a/app/models/concerns/fast_destroy_all.rb +++ b/app/models/concerns/fast_destroy_all.rb @@ -74,7 +74,7 @@ module FastDestroyAll # This method is to be defined on models which have fast destroyable models as children, # and let us avoid to use `dependent: :destroy` hook def use_fast_destroy(relation) - before_destroy do + before_destroy(prepend: true) do perform_fast_destroy(public_send(relation)) # rubocop:disable GitlabSecurity/PublicSend end end diff --git a/app/models/project.rb b/app/models/project.rb index dfe3a989c2c..e48ecea1053 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -80,9 +80,6 @@ class Project < ActiveRecord::Base before_destroy :remove_private_deploy_keys - ## - # `use_fast_destroy` must be defined **before** `has_many` and `has_one` such as `has_many :relation, dependent: :destroy` - # Otherwise `use_fast_destroy` performs against **deleted** rows, which fails to get identifiers of external data use_fast_destroy :build_trace_chunks after_destroy -> { run_after_commit { remove_pages } } -- cgit v1.2.1