summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent.rb
blob: bf83781e89cdd981df5ce0adfcb690f3cbd765f6 (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
# frozen_string_literal: true

class ScheduleBackfillVulnerabilityReadsClusterAgent < Gitlab::Database::Migration[2.0]
  restrict_gitlab_migration gitlab_schema: :gitlab_main

  BATCH_SIZE = 10_000
  SUB_BATCH_SIZE = 1_000
  DELAY_INTERVAL = 2.minutes
  MIGRATION_NAME = 'BackfillVulnerabilityReadsClusterAgent'
  BATCH_CLASS_NAME = 'BackfillVulnerabilityReadsClusterAgentBatchingStrategy'

  disable_ddl_transaction!

  def up
    queue_batched_background_migration(
      MIGRATION_NAME,
      :vulnerability_reads,
      :id,
      job_interval: DELAY_INTERVAL,
      batch_size: BATCH_SIZE,
      batch_class_name: BATCH_CLASS_NAME,
      sub_batch_size: SUB_BATCH_SIZE
    )
  end

  def down
    delete_batched_background_migration(MIGRATION_NAME, :vulnerability_reads, :id, [])
  end
end