summaryrefslogtreecommitdiff
path: root/lib/gitlab
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 15:42:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 15:42:17 +0000
commit44fdf983bd35328dd577d3d3650d14163ef3e2b6 (patch)
tree84ff300d056cfbabb5a0fe2a9cbaa80aaeab1cc5 /lib/gitlab
parentbc9fa07b26184b5c94808f704db6ea1ac81bf4de (diff)
downloadgitlab-ce-44fdf983bd35328dd577d3d3650d14163ef3e2b6.tar.gz
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/background_migration/backfill_push_rules_id_in_projects.rb27
-rw-r--r--lib/gitlab/import_export/group/legacy_tree_saver.rb (renamed from lib/gitlab/import_export/group/tree_saver.rb)2
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/gitlab/background_migration/backfill_push_rules_id_in_projects.rb b/lib/gitlab/background_migration/backfill_push_rules_id_in_projects.rb
new file mode 100644
index 00000000000..9b9ef70424a
--- /dev/null
+++ b/lib/gitlab/background_migration/backfill_push_rules_id_in_projects.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # Class that will insert record into project_push_rules
+ # for each existing push_rule
+ class BackfillPushRulesIdInProjects
+ # Temporary AR table for push rules
+ class ProjectSetting < ActiveRecord::Base
+ self.table_name = 'project_settings'
+ end
+
+ def perform(start_id, stop_id)
+ ProjectSetting.connection.execute(<<~SQL)
+ UPDATE project_settings ps1
+ SET push_rule_id = pr.id
+ FROM project_settings ps2
+ INNER JOIN push_rules pr
+ ON ps2.project_id = pr.project_id
+ WHERE pr.is_sample = false
+ AND pr.id BETWEEN #{start_id} AND #{stop_id}
+ AND ps1.project_id = ps2.project_id
+ SQL
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/import_export/group/tree_saver.rb b/lib/gitlab/import_export/group/legacy_tree_saver.rb
index fd1eb329ad2..3776ef0d8f5 100644
--- a/lib/gitlab/import_export/group/tree_saver.rb
+++ b/lib/gitlab/import_export/group/legacy_tree_saver.rb
@@ -3,7 +3,7 @@
module Gitlab
module ImportExport
module Group
- class TreeSaver
+ class LegacyTreeSaver
attr_reader :full_path, :shared
def initialize(group:, current_user:, shared:, params: {})