summaryrefslogtreecommitdiff
path: root/db/post_migrate/20211005010101_rereschedule_delete_orphaned_deployments.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20211005010101_rereschedule_delete_orphaned_deployments.rb')
-rw-r--r--db/post_migrate/20211005010101_rereschedule_delete_orphaned_deployments.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/db/post_migrate/20211005010101_rereschedule_delete_orphaned_deployments.rb b/db/post_migrate/20211005010101_rereschedule_delete_orphaned_deployments.rb
new file mode 100644
index 00000000000..f49a0fe2f56
--- /dev/null
+++ b/db/post_migrate/20211005010101_rereschedule_delete_orphaned_deployments.rb
@@ -0,0 +1,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