Commit 2d027056 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add index before going through builds in a migration

parent dfef5437
......@@ -15,12 +15,17 @@ class ScheduleBuildStageMigration < ActiveRecord::Migration
def up
disable_statement_timeout
add_concurrent_index(:ci_builds, :stage_id, where: 'stage_id IS NULL',
name: 'tmp_stage_id_partial_null_index')
Build.where('stage_id IS NULL').tap do |relation|
queue_background_migration_jobs_by_range_at_intervals(relation,
MIGRATION,
5.minutes,
batch_size: BATCH_SIZE)
end
remove_concurrent_index_by_name(:ci_builds, 'tmp_stage_id_partial_null_index')
end
def down
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment