Commit 7798d7fd9447c20f440e9cfaf49544fe28fdeed8

Authored by Karol Hosiawa
1 parent 40453cc3
Exists in master and in 1 other branch production

do not trigger email notifications during migration

db/migrate/20110422152027_move_notices_to_separate_collection.rb
@@ -6,10 +6,14 @@ class MoveNoticesToSeparateCollection < Mongoid::Migration @@ -6,10 +6,14 @@ class MoveNoticesToSeparateCollection < Mongoid::Migration
6 errs.each do |err| 6 errs.each do |err|
7 next unless err['notices'] 7 next unless err['notices']
8 e = Err.find(err['_id']) 8 e = Err.find(err['_id'])
  9 + # disable email notifications
  10 + old_notify = e.app.notify_on_errs?
  11 + e.app.update_attribute(:notify_on_errs, false)
9 puts "Copying notices for Err #{err['_id']}" 12 puts "Copying notices for Err #{err['_id']}"
10 err['notices'].each do |notice| 13 err['notices'].each do |notice|
11 e.notices.create!(notice) 14 e.notices.create!(notice)
12 end 15 end
  16 + e.app.update_attribute(:notify_on_errs, old_notify)
13 mongo_db.collection("errs").update({ "_id" => err['_id']}, { "$unset" => { "notices" => 1}}) 17 mongo_db.collection("errs").update({ "_id" => err['_id']}, { "$unset" => { "notices" => 1}})
14 end 18 end
15 Rake::Task["errbit:db:update_notices_count"].invoke 19 Rake::Task["errbit:db:update_notices_count"].invoke