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

20210111075105_schedule_uuid_population_for_security_findings.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 92241378495ddd0df9ddb419d1d0aa2db97f5b73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

class ScheduleUuidPopulationForSecurityFindings < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  MIGRATION_CLASS = 'PopulateUuidsForSecurityFindings'
  DELAY_INTERVAL = 2.minutes
  BATCH_SIZE = 25

  disable_ddl_transaction!

  def up
    Gitlab::BackgroundMigration::PopulateUuidsForSecurityFindings.security_findings.each_batch(column: :scan_id, of: BATCH_SIZE) do |batch, index|
      migrate_in(
        DELAY_INTERVAL * index,
        MIGRATION_CLASS,
        batch.pluck(:scan_id)
      )
    end
  end

  def down
    # no-op
  end
end