summaryrefslogtreecommitdiff
path: root/db/post_migrate/20190909141517_update_cs_vulnerability_confidence_column.rb
blob: befa08e0cb68942c7510de16c78adbf0ac25b90a (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
27
28
29
30
31
32
# frozen_string_literal: true

# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class UpdateCsVulnerabilityConfidenceColumn < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  disable_ddl_transaction!

  DOWNTIME = false
  BATCH_SIZE = 1_000
  INTERVAL = 5.minutes

  # 137_424 records to be updated on GitLab.com,
  # giving us an estimated runtime of 12 hours.
  def up
    # no-op in CE
    return unless Gitlab.ee?

    migration = Gitlab::BackgroundMigration::UpdateVulnerabilityConfidence
    migration_name = migration.to_s.demodulize
    relation = migration::Occurrence.container_scanning_reports_with_medium_confidence
    queue_background_migration_jobs_by_range_at_intervals(relation,
                                                          migration_name,
                                                          INTERVAL,
                                                          batch_size: BATCH_SIZE)
  end

  def down
    # no-op
  end
end