summaryrefslogtreecommitdiff
path: root/db/post_migrate/20210918201050_remove_old_pending_jobs_for_recalculate_vulnerabilities_occurrences_uuid.rb
blob: 224d97243c5dc0572d8af550f42168aabe96b3f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class RemoveOldPendingJobsForRecalculateVulnerabilitiesOccurrencesUuid < Gitlab::Database::Migration[1.0]
  MIGRATION_NAME = 'RecalculateVulnerabilitiesOccurrencesUuid'
  NEW_MIGRATION_START_DATE = DateTime.new(2021, 8, 18, 0, 0, 0)

  def up
    Gitlab::Database::BackgroundMigrationJob
      .for_migration_class(MIGRATION_NAME)
      .where('created_at < ?', NEW_MIGRATION_START_DATE)
      .where(status: :pending)
      .delete_all
  end

  def down
    # no-op
  end
end