summaryrefslogtreecommitdiff
path: root/db/post_migrate/20201028160832_schedule_populate_missing_dismissal_information_for_vulnerabilities.rb
blob: f358ea863dbfdb8008c24832e6f5020fb4fb4ed5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

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

  DOWNTIME = false
  BATCH_SIZE = 1_000
  DELAY_INTERVAL = 3.minutes.to_i
  MIGRATION_CLASS = 'PopulateMissingVulnerabilityDismissalInformation'

  disable_ddl_transaction!

  def up
    ::Gitlab::BackgroundMigration::PopulateMissingVulnerabilityDismissalInformation::Vulnerability.broken.each_batch(of: BATCH_SIZE) do |batch, index|
      vulnerability_ids = batch.pluck(:id)
      migrate_in(index * DELAY_INTERVAL, MIGRATION_CLASS, vulnerability_ids)
    end
  end

  def down
    # no-op
  end
end