@@ -190,12 +190,12 task :migrate_from_mantis => :environment do | |||||
190 | end |
|
190 | end | |
191 |
|
191 | |||
192 | def read(*args) |
|
192 | def read(*args) | |
193 |
|
|
193 | if @read_finished | |
194 |
|
|
194 | nil | |
195 |
|
|
195 | else | |
196 |
|
|
196 | @read_finished = true | |
197 |
|
|
197 | content | |
198 |
|
|
198 | end | |
199 | end |
|
199 | end | |
200 | end |
|
200 | end | |
201 |
|
201 | |||
@@ -242,18 +242,18 task :migrate_from_mantis => :environment do | |||||
242 | users_map = {} |
|
242 | users_map = {} | |
243 | users_migrated = 0 |
|
243 | users_migrated = 0 | |
244 | MantisUser.find(:all).each do |user| |
|
244 | MantisUser.find(:all).each do |user| | |
245 |
|
|
245 | u = User.new :firstname => encode(user.firstname), | |
246 |
|
|
246 | :lastname => encode(user.lastname), | |
247 |
|
|
247 | :mail => user.email, | |
248 |
|
|
248 | :last_login_on => user.last_visit | |
249 |
|
|
249 | u.login = user.username | |
250 |
|
|
250 | u.password = 'mantis' | |
251 |
|
|
251 | u.status = User::STATUS_LOCKED if user.enabled != 1 | |
252 |
|
|
252 | u.admin = true if user.access_level == 90 | |
253 |
|
|
253 | next unless u.save! | |
254 |
|
|
254 | users_migrated += 1 | |
255 |
|
|
255 | users_map[user.id] = u.id | |
256 |
|
|
256 | print '.' | |
257 | end |
|
257 | end | |
258 | puts |
|
258 | puts | |
259 |
|
259 | |||
@@ -264,43 +264,43 task :migrate_from_mantis => :environment do | |||||
264 | versions_map = {} |
|
264 | versions_map = {} | |
265 | categories_map = {} |
|
265 | categories_map = {} | |
266 | MantisProject.find(:all).each do |project| |
|
266 | MantisProject.find(:all).each do |project| | |
267 |
|
|
267 | p = Project.new :name => encode(project.name), | |
268 | :description => encode(project.description) |
|
268 | :description => encode(project.description) | |
269 |
|
|
269 | p.identifier = project.identifier | |
270 |
|
|
270 | next unless p.save | |
271 |
|
|
271 | projects_map[project.id] = p.id | |
272 |
|
|
272 | p.enabled_module_names = ['issue_tracking', 'news', 'wiki'] | |
273 | p.trackers << TRACKER_BUG unless p.trackers.include?(TRACKER_BUG) |
|
273 | p.trackers << TRACKER_BUG unless p.trackers.include?(TRACKER_BUG) | |
274 | p.trackers << TRACKER_FEATURE unless p.trackers.include?(TRACKER_FEATURE) |
|
274 | p.trackers << TRACKER_FEATURE unless p.trackers.include?(TRACKER_FEATURE) | |
275 |
|
|
275 | print '.' | |
276 |
|
276 | |||
277 |
|
|
277 | # Project members | |
278 |
|
|
278 | project.members.each do |member| | |
279 | m = Member.new :user => User.find_by_id(users_map[member.user_id]), |
|
279 | m = Member.new :user => User.find_by_id(users_map[member.user_id]), | |
280 |
|
|
280 | :roles => [ROLE_MAPPING[member.access_level] || DEFAULT_ROLE] | |
281 |
|
|
281 | m.project = p | |
282 |
|
|
282 | m.save | |
283 |
|
|
283 | end | |
284 |
|
284 | |||
285 |
|
|
285 | # Project versions | |
286 |
|
|
286 | project.versions.each do |version| | |
287 | v = Version.new :name => encode(version.version), |
|
287 | v = Version.new :name => encode(version.version), | |
288 | :description => encode(version.description), |
|
288 | :description => encode(version.description), | |
289 | :effective_date => (version.date_order ? version.date_order.to_date : nil) |
|
289 | :effective_date => (version.date_order ? version.date_order.to_date : nil) | |
290 | v.project = p |
|
290 | v.project = p | |
291 | v.save |
|
291 | v.save | |
292 | versions_map[version.id] = v.id |
|
292 | versions_map[version.id] = v.id | |
293 |
|
|
293 | end | |
294 |
|
294 | |||
295 |
|
|
295 | # Project categories | |
296 |
|
|
296 | project.categories.each do |category| | |
297 | g = IssueCategory.new :name => category.category[0,30] |
|
297 | g = IssueCategory.new :name => category.category[0,30] | |
298 | g.project = p |
|
298 | g.project = p | |
299 | g.save |
|
299 | g.save | |
300 | categories_map[category.category] = g.id |
|
300 | categories_map[category.category] = g.id | |
301 |
|
|
301 | end | |
302 |
end |
|
302 | end | |
303 |
puts |
|
303 | puts | |
304 |
|
304 | |||
305 | # Bugs |
|
305 | # Bugs | |
306 | print "Migrating bugs" |
|
306 | print "Migrating bugs" | |
@@ -309,22 +309,22 task :migrate_from_mantis => :environment do | |||||
309 | keep_bug_ids = (Issue.count == 0) |
|
309 | keep_bug_ids = (Issue.count == 0) | |
310 | MantisBug.find_each(:batch_size => 200) do |bug| |
|
310 | MantisBug.find_each(:batch_size => 200) do |bug| | |
311 | next unless projects_map[bug.project_id] && users_map[bug.reporter_id] |
|
311 | next unless projects_map[bug.project_id] && users_map[bug.reporter_id] | |
312 |
|
|
312 | i = Issue.new :project_id => projects_map[bug.project_id], | |
313 | :subject => encode(bug.summary), |
|
313 | :subject => encode(bug.summary), | |
314 | :description => encode(bug.bug_text.full_description), |
|
314 | :description => encode(bug.bug_text.full_description), | |
315 | :priority => PRIORITY_MAPPING[bug.priority] || DEFAULT_PRIORITY, |
|
315 | :priority => PRIORITY_MAPPING[bug.priority] || DEFAULT_PRIORITY, | |
316 | :created_on => bug.date_submitted, |
|
316 | :created_on => bug.date_submitted, | |
317 | :updated_on => bug.last_updated |
|
317 | :updated_on => bug.last_updated | |
318 |
|
|
318 | i.author = User.find_by_id(users_map[bug.reporter_id]) | |
319 |
|
|
319 | i.category = IssueCategory.find_by_project_id_and_name(i.project_id, bug.category[0,30]) unless bug.category.blank? | |
320 |
|
|
320 | i.fixed_version = Version.find_by_project_id_and_name(i.project_id, bug.fixed_in_version) unless bug.fixed_in_version.blank? | |
321 |
|
|
321 | i.status = STATUS_MAPPING[bug.status] || DEFAULT_STATUS | |
322 |
|
|
322 | i.tracker = (bug.severity == 10 ? TRACKER_FEATURE : TRACKER_BUG) | |
323 |
|
|
323 | i.id = bug.id if keep_bug_ids | |
324 |
|
|
324 | next unless i.save | |
325 |
|
|
325 | issues_map[bug.id] = i.id | |
326 |
|
|
326 | print '.' | |
327 | STDOUT.flush |
|
327 | STDOUT.flush | |
328 |
|
328 | |||
329 | # Assignee |
|
329 | # Assignee | |
330 | # Redmine checks that the assignee is a project member |
|
330 | # Redmine checks that the assignee is a project member | |
@@ -332,17 +332,17 task :migrate_from_mantis => :environment do | |||||
332 | i.assigned_to = User.find_by_id(users_map[bug.handler_id]) |
|
332 | i.assigned_to = User.find_by_id(users_map[bug.handler_id]) | |
333 | i.save(:validate => false) |
|
333 | i.save(:validate => false) | |
334 | end |
|
334 | end | |
335 |
|
335 | |||
336 |
|
|
336 | # Bug notes | |
337 |
|
|
337 | bug.bug_notes.each do |note| | |
338 |
|
|
338 | next unless users_map[note.reporter_id] | |
339 | n = Journal.new :notes => encode(note.bug_note_text.note), |
|
339 | n = Journal.new :notes => encode(note.bug_note_text.note), | |
340 | :created_on => note.date_submitted |
|
340 | :created_on => note.date_submitted | |
341 | n.user = User.find_by_id(users_map[note.reporter_id]) |
|
341 | n.user = User.find_by_id(users_map[note.reporter_id]) | |
342 | n.journalized = i |
|
342 | n.journalized = i | |
343 | n.save |
|
343 | n.save | |
344 |
|
|
344 | end | |
345 |
|
345 | |||
346 | # Bug files |
|
346 | # Bug files | |
347 | bug.bug_files.each do |file| |
|
347 | bug.bug_files.each do |file| | |
348 | a = Attachment.new :created_on => file.date_added |
|
348 | a = Attachment.new :created_on => file.date_added | |
@@ -481,7 +481,7 task :migrate_from_mantis => :environment do | |||||
481 | :username => 'root', |
|
481 | :username => 'root', | |
482 | :password => '' } |
|
482 | :password => '' } | |
483 |
|
483 | |||
484 |
puts |
|
484 | puts | |
485 | puts "Please enter settings for your Mantis database" |
|
485 | puts "Please enter settings for your Mantis database" | |
486 | [:adapter, :host, :database, :username, :password].each do |param| |
|
486 | [:adapter, :host, :database, :username, :password].each do |param| | |
487 | print "#{param} [#{db_params[param]}]: " |
|
487 | print "#{param} [#{db_params[param]}]: " |
General Comments 0
You need to be logged in to leave comments.
Login now