Prevent database migration from consuming all the RAM on the server
Prevent large production databases from consuming all the RAM on the server and causing the migration to take forever. With this patch, objects are read in batches from the database. This removes the need to hold ruby objects for all rows for a type in memory at once.
This commit is contained in:
commit
8315cd73f3
|
@ -37,7 +37,7 @@ class BuildInitialJournalsForActsAsJournalized < ActiveRecord::Migration
|
|||
activity_type = p.activity_provider_options.keys.first
|
||||
|
||||
# Create initial journals
|
||||
p.find(:all).each do |o|
|
||||
p.find_each(:batch_size => 100 ) do |o|
|
||||
# Using rescue and save! here because either the Journal or the
|
||||
# touched record could fail. This will catch either error and continue
|
||||
begin
|
||||
|
|
Loading…
Reference in New Issue