summaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-02-15 16:41:44 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-02-15 16:41:44 +0000
commit29e297d273941c79ea14b821f4aa054c4b98301d (patch)
tree2bb0d76ea2e1dc4d3a14b5a38ab3e3fe23815c87 /lib/tasks
parent71d089c83329a0dcaad650f3a97b8d5262db1dd8 (diff)
downloadredmine-29e297d273941c79ea14b821f4aa054c4b98301d.tar.gz
redmine-29e297d273941c79ea14b821f4aa054c4b98301d.zip
Make Mantis importer preserve bug ids.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1146 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/migrate_from_mantis.rake7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/tasks/migrate_from_mantis.rake b/lib/tasks/migrate_from_mantis.rake
index af8892a6b..99607f2a2 100644
--- a/lib/tasks/migrate_from_mantis.rake
+++ b/lib/tasks/migrate_from_mantis.rake
@@ -308,7 +308,8 @@ task :migrate_from_mantis => :environment do
print "Migrating bugs"
Issue.destroy_all
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]
i = Issue.new :project_id => projects_map[bug.project_id],
: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.status = STATUS_MAPPING[bug.status] || DEFAULT_STATUS
i.tracker = (bug.severity == 10 ? TRACKER_FEATURE : TRACKER_BUG)
+ i.id = bug.id if keep_bug_ids
next unless i.save
issues_map[bug.id] = i.id
print '.'
@@ -357,6 +359,9 @@ task :migrate_from_mantis => :environment do
i.add_watcher(User.find_by_id(users_map[monitor.user_id]))
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
# Bug relationships