Class: Gitlab::BackgroundMigration::BackfillDeploymentClustersFromDeployments

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/background_migration/backfill_deployment_clusters_from_deployments.rb

Overview

Backfill deployment_clusters for a range of deployments

Instance Method Summary collapse

Instance Method Details

#perform(start_id, end_id) ⇒ Object


7
8
9
10
11
12
13
14
15
16
# File 'lib/gitlab/background_migration/backfill_deployment_clusters_from_deployments.rb', line 7

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