summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220615154500_schedule_backfill_cluster_agents_has_vulnerabilities.rb
blob: 74aeb2947a972880e4524bea77c8b37ce8ba5d10 (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
# frozen_string_literal: true

class ScheduleBackfillClusterAgentsHasVulnerabilities < Gitlab::Database::Migration[2.0]
  disable_ddl_transaction!

  MIGRATION = 'BackfillClusterAgentsHasVulnerabilities'
  DELAY_INTERVAL = 2.minutes

  restrict_gitlab_migration gitlab_schema: :gitlab_main

  def up
    ensure_batched_background_migration_is_finished(
      job_class_name: 'BackfillVulnerabilityReadsClusterAgent',
      table_name: :vulnerability_reads,
      column_name: :id,
      job_arguments: []
    )

    queue_batched_background_migration(
      MIGRATION,
      :cluster_agents,
      :id,
      job_interval: DELAY_INTERVAL
    )
  end

  def down
    delete_batched_background_migration(MIGRATION, :cluster_agents, :id, [])
  end
end