Commit a3c427e81661ae172e790a19dcee188b592a4b3d
1 parent
1ab07b35
Exists in
master
and in
29 other branches
fix-yaml-migration: use find_each to reduce memory consumption
Showing
1 changed file
with
2 additions
and
3 deletions
Show diff stats
db/migrate/20140724134601_fix_yaml_encoding.rb
... | ... | @@ -18,9 +18,8 @@ class FixYamlEncoding < ActiveRecord::Migration |
18 | 18 | private |
19 | 19 | |
20 | 20 | def self.fix_encoding(model, param) |
21 | - result = model.all | |
22 | - puts "Fixing #{result.count} rows of #{model} (#{param})" | |
23 | - result.each do |r| | |
21 | + puts "Fixing #{model.count} rows of #{model} (#{param})" | |
22 | + model.find_each do |r| | |
24 | 23 | begin |
25 | 24 | yaml = r.send(param) |
26 | 25 | # if deserialization failed then a string is returned | ... | ... |