Project

General

Profile

Patch #18496 » migrate_mantis_1.2.17_to_redmine_2.5.3.patch

Patch file - Gergely Révész, 2014-11-28 15:00

View differences:

migrate_from_mantis.rake.working2 2014-11-28 14:14:47.161757970 +0100
20 20
require 'active_record'
21 21
require 'iconv' if RUBY_VERSION < '1.9'
22 22
require 'pp'
23
require 'date'
23 24

  
24 25
namespace :redmine do
25 26
task :migrate_from_mantis => :environment do
......
136 137
    end
137 138

  
138 139
    class MantisCategory < ActiveRecord::Base
139
      self.table_name = :mantis_project_category_table
140
      self.table_name = :mantis_category_table
140 141
    end
141 142

  
142 143
    class MantisProjectUser < ActiveRecord::Base
......
313 314
                      :subject => encode(bug.summary),
314 315
                      :description => encode(bug.bug_text.full_description),
315 316
                      :priority => PRIORITY_MAPPING[bug.priority] || DEFAULT_PRIORITY,
316
                      :created_on => bug.date_submitted,
317
                      :updated_on => bug.last_updated
317
                      :created_on => Time.at(bug.date_submitted).to_datetime,
318
                      :updated_on => Time.at(bug.last_updated).to_datetime
318 319
        i.author = User.find_by_id(users_map[bug.reporter_id])
319
        i.category = IssueCategory.find_by_project_id_and_name(i.project_id, bug.category[0,30]) unless bug.category.blank?
320
        i.category = IssueCategory.find_by_project_id_and_name(i.project_id, bug.category_id[0]) unless bug.category_id.blank?
320 321
        i.fixed_version = Version.find_by_project_id_and_name(i.project_id, bug.fixed_in_version) unless bug.fixed_in_version.blank?
321 322
        i.status = STATUS_MAPPING[bug.status] || DEFAULT_STATUS
322 323
        i.tracker = (bug.severity == 10 ? TRACKER_FEATURE : TRACKER_BUG)
......
337 338
        bug.bug_notes.each do |note|
338 339
          next unless users_map[note.reporter_id]
339 340
          n = Journal.new :notes => encode(note.bug_note_text.note),
340
                          :created_on => note.date_submitted
341
                          :created_on => Time.at(note.date_submitted).to_datetime
341 342
          n.user = User.find_by_id(users_map[note.reporter_id])
342 343
          n.journalized = i
343 344
          n.save
......
345 346

  
346 347
        # Bug files
347 348
        bug.bug_files.each do |file|
348
          a = Attachment.new :created_on => file.date_added
349
          a = Attachment.new
350
          a = Attachment.new :created_on => Time.at(file.date_added).to_datetime
349 351
          a.file = file
350 352
          a.author = User.first
351 353
          a.container = i
(1-1/2)