lib/couch_tomato/migration.rb in couch_tomato-0.1.3 vs lib/couch_tomato/migration.rb in couch_tomato-0.1.4
- old
+ new
@@ -9,13 +9,15 @@
when :up then announce "migrating"
when :down then announce "reverting"
end
time = Benchmark.measure do
- docs = db.get('_all_docs', :include_docs => true)['rows']
- docs.each do |doc|
- next if /^_design/ =~ doc['id']
- send(direction, doc['doc'])
+ rows = db.get('_all_docs', :include_docs => true)['rows']
+ docs = []
+ rows.each do |row|
+ next if row['id'] =~ /^_design/
+ send(direction, row['doc'])
+ docs << row['doc']
end
db.bulk_save(docs)
end
case direction