Mantis Bug Tracker and Redmine are two of the most popular Bug Trackers or Project Management tools out there. Both free and Open Source. So it's natural to think in a migration process between them. In this article we will talk about migrating from Mantis BT to Redmine and a few tips about that.

Migration script

There's a very good tutorial about that in the official Redmine site. However, I encountered myself with a few problems.

First of all, the migration script is not working properly (Redmine 2.5.1). Luckily I found help on the Internet and a few fixes, but I also had to make adjustments myself. Here is my final version of the script:

migrate_from_mantis.rake
(You can replace the original at <path-to-redmine>\lib\tasks, or create a new script in a separate file)

Also, remember to run this SQL script after the migration because all issues in Redmine will be created with the current date instead of the original from Mantis:

-- Being:
-- "mantis" our Mantis database
-- "redmine" our Redmine database
UPDATE redmine.issues
INNER JOIN mantis.mantis_bug_table ON redmine.issues.id = mantis.mantis_bug_table.id
SET
  created_on = FROM_UNIXTIME(date_submitted),
  updated_on = FROM_UNIXTIME(last_updated)

Project Management plugin (with time tracking)

But there was another thing missing for me, and that was that we in our company, used the Project Management plugin for Mantis (by Vincent Sels). We tracked hours there. And, of course, the migration script doesn't take into consideration all the plugins out there. So, if you found yourself in the same situation, here is the SQL script that will migrate your tracked hours from Mantis to Redmine:

-- Being:
-- "mantis" our Mantis database
-- "redmine" our Redmine database
INSERT time_entries (id, project_id, user_id, issue_id, hours, comments, activity_id,
  spent_on, tyear, tmonth, tweek, created_on, updated_on)
SELECT w.id, rp.id, ru.id, w.bug_id, (w.minutes / 60), 'from MantisBT', 9 AS activity_id,
  DATE(FROM_UNIXTIME(w.book_date)),
  YEAR(FROM_UNIXTIME(w.book_date)), MONTH(FROM_UNIXTIME(w.book_date)), WEEK(FROM_UNIXTIME(w.book_date)),
  FROM_UNIXTIME(w.timestamp), FROM_UNIXTIME(w.timestamp)
FROM mantis.mantis_plugin_projectmanagement_work_table w
  INNER JOIN mantis.mantis_bug_table b ON w.bug_id = b.id
  INNER JOIN mantis.mantis_user_table mu ON w.user_id = mu.id
  INNER JOIN redmine.users ru ON ru.login = mu.username
  INNER JOIN mantis.mantis_project_table mp ON mp.id = b.project_id
  INNER JOIN redmine.projects rp ON rp.name = mp.name
WHERE minutes <> 0;

This script leaves all hours as "development" activity. Feel free to change that part of the script to suit your needs, for example:

-- According to your ID matching
CASE w.work_type WHEN 10 THEN 10 WHEN 20 THEN 11 WHEN 35 THEN 11 WHEN 50 THEN 9 WHEN 80 THEN 12 ELSE 9 END AS activity_id

In order to see (and manage) your tracked hours remember to enable the "Time tracking" module for the project. Or just run this SQL script:

INSERT INTO redmine.enabled_modules (project_id, name)
SELECT id, 'time_tracking'
FROM redmine.projects;

(this script assumes you just ran the migration and you haven't assigned the "Time tracking" module to any project yet)

 

I hope this few tips help you. If not, or you just want to provide some insight, please leave a comment.

Sources & Links

  1. http://www.redmine.org/projects/redmine/wiki/RedmineMigrate#Mantis (Tutorial for migration from Mantis to Redmine)
  2. http://www.redmine.org/issues/10504 (Fix for Mantis migration script on Redmine)
  3. http://www.redmine.org/boards/2/topics/41796 (Some tips on how to migrate Mantis to Redmine)
  4. https://github.com/vincentsels/ProjectManagement (Project Management plugin for Mantis)