diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-14 21:09:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-14 21:09:54 +0300 |
commit | f697dc5e76dfc5894df006d53b2b7e751653cf05 (patch) | |
tree | 1387cd225039e611f3683f96b318bb17d4c422cb /lib/gitlab/background_migration | |
parent | 874ead9c3a50de4c4ca4551eaf5b7eb976d26b50 (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.rb | 19 |
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 |