summaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-08-13 15:29:16 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-08-13 15:29:16 +0000
commit5b4812add8d93ea9d8705beac10072081e4cae9b (patch)
tree19daec30571984fe9734f0b35457de0b7e16646d /lib/tasks
parent005ce1b21d519ce8e4264eac98031ef20f083843 (diff)
downloadredmine-5b4812add8d93ea9d8705beac10072081e4cae9b.tar.gz
redmine-5b4812add8d93ea9d8705beac10072081e4cae9b.zip
Added migration of Mantis bug relationships.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@625 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/migrate_from_mantis.rake31
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/tasks/migrate_from_mantis.rake b/lib/tasks/migrate_from_mantis.rake
index 3fbc048ff..1a2d0877b 100644
--- a/lib/tasks/migrate_from_mantis.rake
+++ b/lib/tasks/migrate_from_mantis.rake
@@ -19,6 +19,7 @@ desc 'Mantis migration script'
require 'active_record'
require 'iconv'
+require 'pp'
task :migrate_from_mantis => :environment do
@@ -58,7 +59,14 @@ task :migrate_from_mantis => :environment do
6 => 'list', # List
7 => 'list', # Multiselection list
8 => 'date', # Date
- }
+ }
+
+ RELATION_TYPE_MAPPING = {1 => IssueRelation::TYPE_RELATES, # related to
+ 2 => IssueRelation::TYPE_RELATES, # parent of
+ 3 => IssueRelation::TYPE_RELATES, # child of
+ 0 => IssueRelation::TYPE_DUPLICATES, # duplicate of
+ 4 => IssueRelation::TYPE_DUPLICATES # has duplicate
+ }
class MantisUser < ActiveRecord::Base
set_table_name :mantis_user_table
@@ -161,6 +169,10 @@ task :migrate_from_mantis => :environment do
end
end
+ class MantisBugRelationship < ActiveRecord::Base
+ set_table_name :mantis_bug_relationship_table
+ end
+
class MantisNews < ActiveRecord::Base
set_table_name :mantis_news_table
end
@@ -298,6 +310,17 @@ task :migrate_from_mantis => :environment do
end
puts
+ # Bug relationships
+ print "Migrating bug relations"
+ MantisBugRelationship.find(:all).each do |relation|
+ next unless issues_map[relation.source_bug_id] && issues_map[relation.destination_bug_id]
+ r = IssueRelation.new :relation_type => RELATION_TYPE_MAPPING[relation.relationship_type]
+ r.issue_from = Issue.find_by_id(issues_map[relation.source_bug_id])
+ r.issue_to = Issue.find_by_id(issues_map[relation.destination_bug_id])
+ pp r unless r.save
+ print '.'
+ end
+
# News
print "Migrating news"
News.destroy_all
@@ -354,6 +377,7 @@ task :migrate_from_mantis => :environment do
puts "Bugs: #{Issue.count}/#{MantisBug.count}"
puts "Bug notes: #{Journal.count}/#{MantisBugNote.count}"
puts "Bug files: #{Attachment.count}/#{MantisBugFile.count}"
+ puts "Bug relations: #{IssueRelation.count}/#{MantisBugRelationship.count}"
puts "News: #{News.count}/#{MantisNews.count}"
puts "Custom fields: #{IssueCustomField.count}/#{MantisCustomField.count}"
end
@@ -385,7 +409,7 @@ task :migrate_from_mantis => :environment do
print "Are you sure you want to continue ? [y/N] "
break unless STDIN.gets.match(/^y$/i)
- # default Mantis database settings
+ # Default Mantis database settings
db_params = {:adapter => 'mysql',
:database => 'bugtracker',
:host => 'localhost',
@@ -409,6 +433,9 @@ task :migrate_from_mantis => :environment do
end
puts
+ # Make sure bugs can refer bugs in other projects
+ Setting.cross_project_issue_relations = 1
+
MantisMigrate.establish_connection db_params
MantisMigrate.migrate
end