Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-14 21:09:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-14 21:09:54 +0300
commitf697dc5e76dfc5894df006d53b2b7e751653cf05 (patch)
tree1387cd225039e611f3683f96b318bb17d4c422cb /lib/gitlab/background_migration
parent874ead9c3a50de4c4ca4551eaf5b7eb976d26b50 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/background_migration')
-rw-r--r--lib/gitlab/background_migration/backfill_deployment_clusters_from_deployments.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/backfill_deployment_clusters_from_deployments.rb b/lib/gitlab/background_migration/backfill_deployment_clusters_from_deployments.rb
new file mode 100644
index 00000000000..9778f360e87
--- /dev/null
+++ b/lib/gitlab/background_migration/backfill_deployment_clusters_from_deployments.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # Backfill deployment_clusters for a range of deployments
+ class BackfillDeploymentClustersFromDeployments
+ def perform(start_id, end_id)
+ ActiveRecord::Base.connection.execute <<~SQL
+ INSERT INTO deployment_clusters (deployment_id, cluster_id)
+ SELECT deployments.id, deployments.cluster_id
+ FROM deployments
+ WHERE deployments.cluster_id IS NOT NULL
+ AND deployments.id BETWEEN #{start_id} AND #{end_id}
+ ON CONFLICT DO NOTHING
+ SQL
+ end
+ end
+ end
+end