Commit 728da5f06c44aa06592112fc800850c4ed544b5c
1 parent
ca824290
Exists in
master
and in
1 other branch
Unsed backtrace array on migration, instead of nil it
Showing
1 changed file
with
3 additions
and
3 deletions
Show diff stats
db/migrate/20121003223358_extract_backtraces.rb
1 | 1 | class ExtractBacktraces < Mongoid::Migration |
2 | 2 | def self.up |
3 | 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 | 5 | next if notice.backtrace.present? || notice['backtrace'].nil? |
6 | 6 | backtrace = Backtrace.find_or_create(:raw => notice['backtrace'] || []) |
7 | + notice.unset(:backtrace) | |
7 | 8 | notice.backtrace = backtrace |
8 | - notice['backtrace'] = nil | |
9 | 9 | notice.save! |
10 | 10 | end |
11 | 11 | say "run `db.repairDatabase()` (in mongodb console) to recover deleted space" |
... | ... | @@ -13,4 +13,4 @@ class ExtractBacktraces < Mongoid::Migration |
13 | 13 | |
14 | 14 | def self.down |
15 | 15 | end |
16 | -end | |
17 | 16 | \ No newline at end of file |
17 | +end | ... | ... |