diff options
Diffstat (limited to 'lib/gitlab/import_export/relation_tree_restorer.rb')
-rw-r--r-- | lib/gitlab/import_export/relation_tree_restorer.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/gitlab/import_export/relation_tree_restorer.rb b/lib/gitlab/import_export/relation_tree_restorer.rb index 8d93098a80a..1eeacafef53 100644 --- a/lib/gitlab/import_export/relation_tree_restorer.rb +++ b/lib/gitlab/import_export/relation_tree_restorer.rb @@ -37,7 +37,7 @@ module Gitlab ActiveRecord::Base.no_touching do update_params! - BulkInsertableAssociations.with_bulk_insert(enabled: @importable.instance_of?(::Project)) do + BulkInsertableAssociations.with_bulk_insert(enabled: project?) do fix_ci_pipelines_not_sorted_on_legacy_project_json! create_relations! end @@ -55,6 +55,10 @@ module Gitlab private + def project? + @importable.instance_of?(::Project) + end + # Loops through the tree of models defined in import_export.yml and # finds them in the imported JSON so they can be instantiated and saved # in the DB. The structure and relationships between models are guessed from @@ -75,7 +79,7 @@ module Gitlab def process_relation_item!(relation_key, relation_definition, relation_index, data_hash) relation_object = build_relation(relation_key, relation_definition, relation_index, data_hash) return unless relation_object - return if importable_class == ::Project && group_model?(relation_object) + return if project? && group_model?(relation_object) relation_object.assign_attributes(importable_class_sym => @importable) @@ -114,7 +118,8 @@ module Gitlab excluded_keys: excluded_keys_for_relation(importable_class_sym)) @importable.assign_attributes(params) - @importable.drop_visibility_level! if importable_class == ::Project + + modify_attributes Gitlab::Timeless.timeless(@importable) do @importable.save! @@ -141,6 +146,13 @@ module Gitlab end end + def modify_attributes + return unless project? + + @importable.reconcile_shared_runners_setting! + @importable.drop_visibility_level! + end + def build_relations(relation_key, relation_definition, relation_index, data_hashes) data_hashes .map { |data_hash| build_relation(relation_key, relation_definition, relation_index, data_hash) } |