Commit beb6bfa04eab691d0c3eca85a99d40600a013a3f
Committed by
Victor Costa
1 parent
ed3e7a3d
Exists in
staging
and in
4 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 | ... | ... |