Add index before going through builds in a migration
This commit is contained in:
parent
dfef5437a2
commit
2d027056f9
1 changed files with 5 additions and 0 deletions
|
@ -15,12 +15,17 @@ class ScheduleBuildStageMigration < ActiveRecord::Migration
|
||||||
def up
|
def up
|
||||||
disable_statement_timeout
|
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|
|
Build.where('stage_id IS NULL').tap do |relation|
|
||||||
queue_background_migration_jobs_by_range_at_intervals(relation,
|
queue_background_migration_jobs_by_range_at_intervals(relation,
|
||||||
MIGRATION,
|
MIGRATION,
|
||||||
5.minutes,
|
5.minutes,
|
||||||
batch_size: BATCH_SIZE)
|
batch_size: BATCH_SIZE)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
remove_concurrent_index_by_name(:ci_builds, 'tmp_stage_id_partial_null_index')
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
|
Loading…
Reference in a new issue