diff --git a/db/migrate/20121003223358_extract_backtraces.rb b/db/migrate/20121003223358_extract_backtraces.rb index 388f905..f518cf2 100644 --- a/db/migrate/20121003223358_extract_backtraces.rb +++ b/db/migrate/20121003223358_extract_backtraces.rb @@ -1,11 +1,11 @@ class ExtractBacktraces < Mongoid::Migration def self.up say "It could take long time (hours if you have many Notices)" - Notice.unscoped.all.each do |notice| + Notice.unscoped.where(backtrace_id: nil).each do |notice| next if notice.backtrace.present? || notice['backtrace'].nil? backtrace = Backtrace.find_or_create(:raw => notice['backtrace'] || []) + notice.unset(:backtrace) notice.backtrace = backtrace - notice['backtrace'] = nil notice.save! end say "run `db.repairDatabase()` (in mongodb console) to recover deleted space" @@ -13,4 +13,4 @@ class ExtractBacktraces < Mongoid::Migration def self.down end -end \ No newline at end of file +end -- libgit2 0.21.2