Commit 728da5f06c44aa06592112fc800850c4ed544b5c

Authored by Arthur Neves
1 parent ca824290
Exists in master and in 1 other branch production

Unsed backtrace array on migration, instead of nil it

db/migrate/20121003223358_extract_backtraces.rb
1 class ExtractBacktraces < Mongoid::Migration 1 class ExtractBacktraces < Mongoid::Migration
2 def self.up 2 def self.up
3 say "It could take long time (hours if you have many Notices)" 3 say "It could take long time (hours if you have many Notices)"
4 - Notice.unscoped.all.each do |notice| 4 + Notice.unscoped.where(backtrace_id: nil).each do |notice|
5 next if notice.backtrace.present? || notice['backtrace'].nil? 5 next if notice.backtrace.present? || notice['backtrace'].nil?
6 backtrace = Backtrace.find_or_create(:raw => notice['backtrace'] || []) 6 backtrace = Backtrace.find_or_create(:raw => notice['backtrace'] || [])
  7 + notice.unset(:backtrace)
7 notice.backtrace = backtrace 8 notice.backtrace = backtrace
8 - notice['backtrace'] = nil  
9 notice.save! 9 notice.save!
10 end 10 end
11 say "run `db.repairDatabase()` (in mongodb console) to recover deleted space" 11 say "run `db.repairDatabase()` (in mongodb console) to recover deleted space"
@@ -13,4 +13,4 @@ class ExtractBacktraces &lt; Mongoid::Migration @@ -13,4 +13,4 @@ class ExtractBacktraces &lt; Mongoid::Migration
13 13
14 def self.down 14 def self.down
15 end 15 end
16 -end  
17 \ No newline at end of file 16 \ No newline at end of file
  17 +end