diff options
Diffstat (limited to 'db/post_migrate/20210722010101_reschedule_delete_orphaned_deployments.rb')
-rw-r--r-- | db/post_migrate/20210722010101_reschedule_delete_orphaned_deployments.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/db/post_migrate/20210722010101_reschedule_delete_orphaned_deployments.rb b/db/post_migrate/20210722010101_reschedule_delete_orphaned_deployments.rb new file mode 100644 index 00000000000..b0608f15ce1 --- /dev/null +++ b/db/post_migrate/20210722010101_reschedule_delete_orphaned_deployments.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class RescheduleDeleteOrphanedDeployments < ActiveRecord::Migration[6.1] + include Gitlab::Database::MigrationHelpers + + MIGRATION = 'DeleteOrphanedDeployments' + BATCH_SIZE = 10_000 + DELAY_INTERVAL = 2.minutes + + disable_ddl_transaction! + + def up + Gitlab::BackgroundMigration.steal(MIGRATION) + Gitlab::Database::BackgroundMigrationJob.for_migration_class(MIGRATION).delete_all + + queue_background_migration_jobs_by_range_at_intervals( + define_batchable_model('deployments'), + MIGRATION, + DELAY_INTERVAL, + batch_size: BATCH_SIZE, + track_jobs: true + ) + end + + def down + # no-op + end +end |