summaryrefslogtreecommitdiff
path: root/db/post_migrate/20211005010101_rereschedule_delete_orphaned_deployments.rb
blob: f49a0fe2f56a067d9b5433342f137dc057f7a9aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

class RerescheduleDeleteOrphanedDeployments < Gitlab::Database::Migration[1.0]
  MIGRATION = 'DeleteOrphanedDeployments'
  DELAY_INTERVAL = 2.minutes

  disable_ddl_transaction!

  # This is the third time to schedule `DeleteOrphanedDeployments` migration.
  # The first time failed by an inappropriate batch size and the second time failed by a retry bug.
  # Since there is no issue in this migration itself, we can simply requeue the
  # migration jobs **without** no-op-ing the previous migration.
  # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69051#note_669230405 for more information.
  def up
    delete_queued_jobs(MIGRATION)

    requeue_background_migration_jobs_by_range_at_intervals(MIGRATION, DELAY_INTERVAL)
  end

  def down
    # no-op
  end
end