Added migration of Mantis bug monitors.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@626 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2007-08-13 15:35:52 +00:00
parent 5b4812add8
commit f179eee7a0
1 changed files with 12 additions and 0 deletions

View File

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