summaryrefslogtreecommitdiff
path: root/db/post_migrate
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-28 12:23:00 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-28 12:23:00 +0200
commit5292eb651e1e3595e409a4c216eb0be3445a9319 (patch)
tree31ff994016ce45f8211bf90050e86d7c20459d71 /db/post_migrate
parent02bb40e2acd7b1838e47e1a2f8b9288e42e6ca53 (diff)
downloadgitlab-ce-5292eb651e1e3595e409a4c216eb0be3445a9319.tar.gz
Schedule background migration only when it is needed
Diffstat (limited to 'db/post_migrate')
-rw-r--r--db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
index 6b326bc0b69..bfeb09f6da1 100644
--- a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
+++ b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
@@ -12,11 +12,13 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
end
def up
- Build.find_in_batches(batch_size: BATCH_SIZE).with_index do |builds, batch|
- migrations = builds.map { |build| [MIGRATION, [build.id]] }
+ Build.where(stage_id: nil)
+ .find_in_batches(batch_size: BATCH_SIZE)
+ .with_index do |builds, batch|
+ migrations = builds.map { |build| [MIGRATION, [build.id]] }
- BackgroundMigrationWorker.perform_bulk(*migrations)
- end
+ BackgroundMigrationWorker.perform_bulk(*migrations)
+ end
end
def down