Class: Gitlab::BackgroundMigration::CopyMergeRequestTargetProjectToMergeRequestMetrics

Inherits:
Object
  • Object
show all
Extended by:
Utils::Override
Defined in:
lib/gitlab/background_migration/copy_merge_request_target_project_to_merge_request_metrics.rb

Instance Method Summary collapse

Methods included from Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Instance Method Details

#perform(start_id, stop_id) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/background_migration/copy_merge_request_target_project_to_merge_request_metrics.rb', line 9

def perform(start_id, stop_id)
  ActiveRecord::Base.connection.execute <<~SQL
    WITH merge_requests_batch AS (
      SELECT id, target_project_id
      FROM merge_requests WHERE id BETWEEN #{Integer(start_id)} AND #{Integer(stop_id)}
    )
    UPDATE
      merge_request_metrics
    SET
      target_project_id = merge_requests_batch.target_project_id
    FROM merge_requests_batch
    WHERE merge_request_metrics.merge_request_id=merge_requests_batch.id
  SQL
end