diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-07 18:08:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-07 18:08:21 +0000 |
commit | 996d54a81d799e6a69098b1e397a4ee7ea6d200c (patch) | |
tree | fffa63f837935d38b070b84eb6753f2cf60533de /lib | |
parent | 73f25276606bed7d822153814de9467900aac244 (diff) | |
download | gitlab-ce-996d54a81d799e6a69098b1e397a4ee7ea6d200c.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/import_export/relation_tree_restorer.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/gitlab/import_export/relation_tree_restorer.rb b/lib/gitlab/import_export/relation_tree_restorer.rb index e0d6ade51c2..8359eefc846 100644 --- a/lib/gitlab/import_export/relation_tree_restorer.rb +++ b/lib/gitlab/import_export/relation_tree_restorer.rb @@ -26,8 +26,13 @@ module Gitlab ActiveRecord::Base.uncached do ActiveRecord::Base.no_touching do update_params! - update_relation_hashes! - create_relations! + + bulk_inserts_enabled = @importable.class == ::Project && + Feature.enabled?(:import_bulk_inserts, @importable.group) + BulkInsertableAssociations.with_bulk_insert(enabled: bulk_inserts_enabled) do + update_relation_hashes! + create_relations! + end end end @@ -170,7 +175,7 @@ module Gitlab # if object is a hash we can create simple object # as it means that this is 1-to-1 vs 1-to-many - sub_data_hash = + current_item = if sub_data_hash.is_a?(Array) build_relations( sub_relation_key, @@ -183,9 +188,8 @@ module Gitlab sub_data_hash) end - # persist object(s) or delete from relation - if sub_data_hash - data_hash[sub_relation_key] = sub_data_hash + if current_item + data_hash[sub_relation_key] = current_item else data_hash.delete(sub_relation_key) end |