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