From 728da5f06c44aa06592112fc800850c4ed544b5c Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Fri, 28 Mar 2014 15:19:22 -0400 Subject: [PATCH] Unsed backtrace array on migration, instead of nil it --- db/migrate/20121003223358_extract_backtraces.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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