BigW Consortium Gitlab

Commit 5292eb65 by Grzegorz Bizon

Schedule background migration only when it is needed

parent 02bb40e2
...@@ -12,11 +12,13 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration ...@@ -12,11 +12,13 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
end end
def up def up
Build.find_in_batches(batch_size: BATCH_SIZE).with_index do |builds, batch| Build.where(stage_id: nil)
migrations = builds.map { |build| [MIGRATION, [build.id]] } .find_in_batches(batch_size: BATCH_SIZE)
.with_index do |builds, batch|
migrations = builds.map { |build| [MIGRATION, [build.id]] }
BackgroundMigrationWorker.perform_bulk(*migrations) BackgroundMigrationWorker.perform_bulk(*migrations)
end end
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