summaryrefslogtreecommitdiff
path: root/db/migrate/20200116051619_drop_background_migration_jobs.rb
blob: f492ec0af9d28240c0d5ff4c1cb7abb1f03953b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class DropBackgroundMigrationJobs < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  DROPPED_JOB_CLASS = 'ActivatePrometheusServicesForSharedClusterApplications'
  QUEUE = 'background_migration'

  def up
    Sidekiq::Queue.new(QUEUE).each do |job|
      klass, project_id, *should_be_empty = job.args
      next unless klass == DROPPED_JOB_CLASS && project_id.is_a?(Integer) && should_be_empty.empty?

      job.delete
    end
  end
end