summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-08 15:08:59 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-08 15:08:59 +0000
commitc6c5dd8848b78528d7ad7f044a0c95be629d372e (patch)
tree261577e229ade85472353eb5b380c1e4fed9bc60 /lib/gitlab/background_migration
parentd0aeb5df3d6b06165355b023a25b79c7bd74a27d (diff)
downloadgitlab-ce-c6c5dd8848b78528d7ad7f044a0c95be629d372e.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/background_migration')
-rw-r--r--lib/gitlab/background_migration/backfill_jira_tracker_deployment_type2.rb86
1 files changed, 0 insertions, 86 deletions
diff --git a/lib/gitlab/background_migration/backfill_jira_tracker_deployment_type2.rb b/lib/gitlab/background_migration/backfill_jira_tracker_deployment_type2.rb
deleted file mode 100644
index 669e5338dd1..00000000000
--- a/lib/gitlab/background_migration/backfill_jira_tracker_deployment_type2.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-# frozen_string_literal: true
-
-# Based on https://community.developer.atlassian.com/t/get-rest-api-3-filter-search/29459/2,
-# it's enough at the moment to simply notice if the url is from `atlassian.net`
-module Gitlab
- module BackgroundMigration
- # Backfill the deployment_type in jira_tracker_data table
- class BackfillJiraTrackerDeploymentType2
- # Migration only version of jira_tracker_data table
- class JiraTrackerDataTemp < ApplicationRecord
- self.table_name = 'jira_tracker_data'
-
- def self.encryption_options
- {
- key: Settings.attr_encrypted_db_key_base_32,
- encode: true,
- mode: :per_attribute_iv,
- algorithm: 'aes-256-gcm'
- }
- end
-
- attr_encrypted :url, encryption_options
- attr_encrypted :api_url, encryption_options
-
- enum deployment_type: { unknown: 0, server: 1, cloud: 2 }, _prefix: :deployment
- end
-
- # Migration only version of services table
- class JiraServiceTemp < ApplicationRecord
- self.table_name = 'services'
- self.inheritance_column = :_type_disabled
- end
-
- def perform(start_id, stop_id)
- @server_ids = []
- @cloud_ids = []
-
- JiraTrackerDataTemp
- .where(id: start_id..stop_id, deployment_type: 0)
- .each do |jira_tracker_data|
- collect_deployment_type(jira_tracker_data)
- end
-
- unless cloud_ids.empty?
- JiraTrackerDataTemp.where(id: cloud_ids)
- .update_all(deployment_type: JiraTrackerDataTemp.deployment_types[:cloud])
- end
-
- unless server_ids.empty?
- JiraTrackerDataTemp.where(id: server_ids)
- .update_all(deployment_type: JiraTrackerDataTemp.deployment_types[:server])
- end
-
- mark_jobs_as_succeeded(start_id, stop_id)
- end
-
- private
-
- attr_reader :server_ids, :cloud_ids
-
- def client_url(jira_tracker_data)
- jira_tracker_data.api_url.presence || jira_tracker_data.url.presence
- end
-
- def server_type(url)
- url.downcase.include?('.atlassian.net') ? :cloud : :server
- end
-
- def collect_deployment_type(jira_tracker_data)
- url = client_url(jira_tracker_data)
- return unless url
-
- case server_type(url)
- when :cloud
- cloud_ids << jira_tracker_data.id
- else
- server_ids << jira_tracker_data.id
- end
- end
-
- def mark_jobs_as_succeeded(*arguments)
- Gitlab::Database::BackgroundMigrationJob.mark_all_as_succeeded(self.class.name.demodulize, arguments)
- end
- end
- end
-end