From beb6bfa04eab691d0c3eca85a99d40600a013a3f Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Thu, 26 Mar 2015 11:41:21 -0300 Subject: [PATCH] fix-yaml-migration: use find_each to reduce memory consumption --- db/migrate/20140724134601_fix_yaml_encoding.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db/migrate/20140724134601_fix_yaml_encoding.rb b/db/migrate/20140724134601_fix_yaml_encoding.rb index bf10f67..53b3ec1 100644 --- a/db/migrate/20140724134601_fix_yaml_encoding.rb +++ b/db/migrate/20140724134601_fix_yaml_encoding.rb @@ -18,9 +18,8 @@ class FixYamlEncoding < ActiveRecord::Migration private def self.fix_encoding(model, param) - result = model.all - puts "Fixing #{result.count} rows of #{model} (#{param})" - result.each do |r| + puts "Fixing #{model.count} rows of #{model} (#{param})" + model.find_each do |r| begin yaml = r.send(param) # if deserialization failed then a string is returned -- libgit2 0.21.2