summaryrefslogtreecommitdiff
path: root/db
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-07-07 15:08:15 +0200
commit1dc20f7ac7dbb68464cb4ea2727fd4e7171cfba8 (patch)
treed788346ad1a02b75c7c0082f6c3f05a695eb06ba /db
parent9a32ca409757b4b25520ea9957cdd4c8c97c0e95 (diff)
downloadgitlab-ce-1dc20f7ac7dbb68464cb4ea2727fd4e7171cfba8.tar.gz
Schedule background migration only when it is needed
Diffstat (limited to 'db')
-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