Mantis 1.2.16 to Redmine Conversion - Here is an updated script & instructions
Added by Aaron Schroeder over 10 years ago
Our office recently made the transition to Redmine and the migrate_from_mantis.rake did not work very well. We ended up fixing the script and also documenting a process that made the migration work without losing any information. I thought I'd share this here in case others are having trouble migrating. Here is the process and attached is an updated migrate_from_mantis.rake file that fixes several issues related to schema changes in the newer version of Mantis. Please note that all queries assume MySQL.
The following cleanup needs to be performed on your mantis database before migrating. We made a copy of our db before doing these actions:- Create a new global category called “Uncategorized” and check the ID in the mantis_category_table. In our case we were not using the category with id = 1 so I deleted that and updated the id for this new category to 1.
- Run the following query to assign all un-categorized tickets to the newly created category. This is important because Mantis uses 0 as a default category_id, which is not a proper foreign key and so the redmine script skips any bugs with category_id = 0.
UPDATE mantis_bug_table SET category_id = 1 WHERE category_id = 0
- Check reporter_id and handler_id foreign keys for bug and bugnotes tables. If users were deleted from Mantis, their ID remains in the related table and the redmine import script won’t like this because it’s an invalid foreign key. Run the following 3 queries and if any return > 0 records, add users for the ids needed:
SELECT mantis_bug_table.* FROM mantis_bug_table LEFT JOIN mantis_user_table ON mantis_bug_table.reporter_id = mantis_user_table.id WHERE mantis_user_table.id IS NULL SELECT mantis_bug_table.* FROM mantis_bug_table LEFT JOIN mantis_user_table ON mantis_bug_table.handler_id = mantis_user_table.id WHERE mantis_user_table.id IS NULL SELECT mantis_bugnote_table.* FROM mantis_bugnote_table LEFT JOIN mantis_user_table ON mantis_bugnote_table.reporter_id = mantis_user_table.id WHERE mantis_user_table.id IS NULL
In our case we had apparently deleted a few user accounts rather than marking them in-active. I ended up creating new user accounts for 5 different ID's and then manually going into the mantis user table to edit their generated IDs and assign them to the missing ones.
Next, run the attached migration script in the redmine home directory:
sudo rake redmine:migrate_from_mantis RAILS_ENV=production
If not all bugs were migrated, use the following query to check which bugs are in Mantis but not Redmine. This assumes your mantis database is named mantisbt and exists on the same database server as redmine:
SELECT * FROM mantisbt.mantis_bug_table LEFT JOIN redmine.issues on redmine.issues.id = mantisbt.mantis_bug_table.id WHERE redmine.issues.id IS NULL
Finally, the migration script does not preserve issue created and update date/times. We simply updated these from the mantis database using the following query.
UPDATE redmine.issues INNER JOIN mantisbt.mantis_bug_table ON redmine.issues.id = mantisbt.mantis_bug_table.id SET created_on = FROM_UNIXTIME(date_submitted), updated_on = FROM_UNIXTIME(last_updated)