Schedule background migration only when it is needed
This commit is contained in:
parent
02bb40e2ac
commit
5292eb651e
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue