OSDN Git Service

Added migration of Mantis bug monitors.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 13 Aug 2007 15:35:52 +0000 (15:35 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 13 Aug 2007 15:35:52 +0000 (15:35 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@626 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/tasks/migrate_from_mantis.rake

index 1a2d087..e571ae4 100644 (file)
@@ -133,6 +133,7 @@ task :migrate_from_mantis => :environment do
       belongs_to :bug_text, :class_name => "MantisBugText", :foreign_key => :bug_text_id\r
       has_many :bug_notes, :class_name => "MantisBugNote", :foreign_key => :bug_id\r
       has_many :bug_files, :class_name => "MantisBugFile", :foreign_key => :bug_id\r
+      has_many :bug_monitors, :class_name => "MantisBugMonitor", :foreign_key => :bug_id\r
     end\r
     \r
     class MantisBugText < ActiveRecord::Base\r
@@ -173,6 +174,10 @@ task :migrate_from_mantis => :environment do
       set_table_name :mantis_bug_relationship_table\r
     end\r
     \r
+    class MantisBugMonitor < ActiveRecord::Base\r
+      set_table_name :mantis_bug_monitor_table\r
+    end\r
+    \r
     class MantisNews < ActiveRecord::Base\r
       set_table_name :mantis_news_table\r
     end\r
@@ -307,6 +312,11 @@ task :migrate_from_mantis => :environment do
           a.container = i\r
           a.save\r
         end\r
+        \r
+        # Bug monitors\r
+        bug.bug_monitors.each do |monitor|\r
+          i.add_watcher(User.find_by_id(users_map[monitor.user_id]))\r
+        end\r
       end\r
       puts\r
       \r
@@ -320,6 +330,7 @@ task :migrate_from_mantis => :environment do
         pp r unless r.save\r
         print '.'\r
       end\r
+      puts\r
       \r
       # News\r
       print "Migrating news"\r
@@ -378,6 +389,7 @@ task :migrate_from_mantis => :environment do
       puts "Bug notes:       #{Journal.count}/#{MantisBugNote.count}"\r
       puts "Bug files:       #{Attachment.count}/#{MantisBugFile.count}"\r
       puts "Bug relations:   #{IssueRelation.count}/#{MantisBugRelationship.count}"\r
+      puts "Bug monitors:    #{Watcher.count}/#{MantisBugMonitor.count}"\r
       puts "News:            #{News.count}/#{MantisNews.count}"\r
       puts "Custom fields:   #{IssueCustomField.count}/#{MantisCustomField.count}"\r
     end\r