Make Mantis importer preserve bug ids.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1146 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
71d089c833
commit
29e297d273
|
@ -308,7 +308,8 @@ task :migrate_from_mantis => :environment do
|
||||||
print "Migrating bugs"
|
print "Migrating bugs"
|
||||||
Issue.destroy_all
|
Issue.destroy_all
|
||||||
issues_map = {}
|
issues_map = {}
|
||||||
MantisBug.find(:all).each do |bug|
|
keep_bug_ids = (Issue.count == 0)
|
||||||
|
MantisBug.find(:all, :order => 'id ASC').each do |bug|
|
||||||
next unless projects_map[bug.project_id] && users_map[bug.reporter_id]
|
next unless projects_map[bug.project_id] && users_map[bug.reporter_id]
|
||||||
i = Issue.new :project_id => projects_map[bug.project_id],
|
i = Issue.new :project_id => projects_map[bug.project_id],
|
||||||
:subject => encode(bug.summary),
|
:subject => encode(bug.summary),
|
||||||
|
@ -321,6 +322,7 @@ task :migrate_from_mantis => :environment do
|
||||||
i.fixed_version = Version.find_by_project_id_and_name(i.project_id, bug.fixed_in_version) unless bug.fixed_in_version.blank?
|
i.fixed_version = Version.find_by_project_id_and_name(i.project_id, bug.fixed_in_version) unless bug.fixed_in_version.blank?
|
||||||
i.status = STATUS_MAPPING[bug.status] || DEFAULT_STATUS
|
i.status = STATUS_MAPPING[bug.status] || DEFAULT_STATUS
|
||||||
i.tracker = (bug.severity == 10 ? TRACKER_FEATURE : TRACKER_BUG)
|
i.tracker = (bug.severity == 10 ? TRACKER_FEATURE : TRACKER_BUG)
|
||||||
|
i.id = bug.id if keep_bug_ids
|
||||||
next unless i.save
|
next unless i.save
|
||||||
issues_map[bug.id] = i.id
|
issues_map[bug.id] = i.id
|
||||||
print '.'
|
print '.'
|
||||||
|
@ -357,6 +359,9 @@ task :migrate_from_mantis => :environment do
|
||||||
i.add_watcher(User.find_by_id(users_map[monitor.user_id]))
|
i.add_watcher(User.find_by_id(users_map[monitor.user_id]))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# update issue id sequence if needed (postgresql)
|
||||||
|
Issue.connection.reset_pk_sequence!(Issue.table_name) if Issue.connection.respond_to?('reset_pk_sequence!')
|
||||||
puts
|
puts
|
||||||
|
|
||||||
# Bug relationships
|
# Bug relationships
|
||||||
|
|
Loading…
Reference in New Issue