Add index before going through builds in a migration

This commit is contained in:
Grzegorz Bizon 2018-02-20 13:37:59 +01:00
parent dfef5437a2
commit 2d027056f9
1 changed files with 5 additions and 0 deletions

View File

@ -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