From 2d027056f9c56ad733bcccf54c3b7cf8c7cb95bf Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 20 Feb 2018 13:37:59 +0100 Subject: [PATCH] Add index before going through builds in a migration --- .../20180212101928_schedule_build_stage_migration.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/post_migrate/20180212101928_schedule_build_stage_migration.rb b/db/post_migrate/20180212101928_schedule_build_stage_migration.rb index df15b2cd9d4..f42a09f2223 100644 --- a/db/post_migrate/20180212101928_schedule_build_stage_migration.rb +++ b/db/post_migrate/20180212101928_schedule_build_stage_migration.rb @@ -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