Commit 08f0e80fa674a64fec688e2a10b5609f2eb8fd50

Authored by Nathan Broadbent
1 parent 507edf53
Exists in master and in 1 other branch production

Added 'puts' statements for each step of the migration.

db/migrate/20110905134638_link_errs_to_problems.rb
1 class LinkErrsToProblems < Mongoid::Migration 1 class LinkErrsToProblems < Mongoid::Migration
2 def self.up 2 def self.up
  3 + puts "== Migrating from Errs to Problems..."
3 4
4 - # Copy err.klass to notice.klass 5 + puts "==== Copy err.klass to notice.klass..."
5 Notice.all.each do |notice| 6 Notice.all.each do |notice|
6 if notice.err && (klass = notice.err['klass']) 7 if notice.err && (klass = notice.err['klass'])
7 notice.update_attribute(:klass, klass) 8 notice.update_attribute(:klass, klass)
8 end 9 end
9 end 10 end
10 11
11 - # Create a Problem for each Err 12 + puts "==== Create a Problem for each Err..."
12 Err.all.each do |err| 13 Err.all.each do |err|
13 if err['app_id'] && app = App.where(:_id => err['app_id']).first 14 if err['app_id'] && app = App.where(:_id => err['app_id']).first
14 err.problem = app.problems.create 15 err.problem = app.problems.create
@@ -16,7 +17,9 @@ class LinkErrsToProblems &lt; Mongoid::Migration @@ -16,7 +17,9 @@ class LinkErrsToProblems &lt; Mongoid::Migration
16 end 17 end
17 end 18 end
18 19
  20 + puts "==== Updating problem cached attributes..."
19 Rake::Task["errbit:db:update_problem_attrs"].invoke 21 Rake::Task["errbit:db:update_problem_attrs"].invoke
  22 + puts "==== Updating notice counts..."
20 Rake::Task["errbit:db:update_notices_count"].invoke 23 Rake::Task["errbit:db:update_notices_count"].invoke
21 end 24 end
22 25