annotate lib/tasks/migrate_from_mantis.rake @ 881:fade849e02c5 feature_73

Close obsolete branch feature_73
author Chris Cannam
date Fri, 25 Mar 2011 15:48:36 +0000
parents 94944d00e43c
children 8661b858af72
rev   line source
Chris@0 1 # redMine - project management software
Chris@0 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@0 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@0 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@0 18 desc 'Mantis migration script'
Chris@0 19
Chris@0 20 require 'active_record'
Chris@0 21 require 'iconv'
Chris@0 22 require 'pp'
Chris@0 23
Chris@0 24 namespace :redmine do
Chris@0 25 task :migrate_from_mantis => :environment do
Chris@0 26
Chris@0 27 module MantisMigrate
Chris@0 28
Chris@0 29 DEFAULT_STATUS = IssueStatus.default
Chris@0 30 assigned_status = IssueStatus.find_by_position(2)
Chris@0 31 resolved_status = IssueStatus.find_by_position(3)
Chris@0 32 feedback_status = IssueStatus.find_by_position(4)
Chris@0 33 closed_status = IssueStatus.find :first, :conditions => { :is_closed => true }
Chris@0 34 STATUS_MAPPING = {10 => DEFAULT_STATUS, # new
Chris@0 35 20 => feedback_status, # feedback
Chris@0 36 30 => DEFAULT_STATUS, # acknowledged
Chris@0 37 40 => DEFAULT_STATUS, # confirmed
Chris@0 38 50 => assigned_status, # assigned
Chris@0 39 80 => resolved_status, # resolved
Chris@0 40 90 => closed_status # closed
Chris@0 41 }
Chris@0 42
Chris@0 43 priorities = IssuePriority.all
Chris@0 44 DEFAULT_PRIORITY = priorities[2]
Chris@0 45 PRIORITY_MAPPING = {10 => priorities[1], # none
Chris@0 46 20 => priorities[1], # low
Chris@0 47 30 => priorities[2], # normal
Chris@0 48 40 => priorities[3], # high
Chris@0 49 50 => priorities[4], # urgent
Chris@0 50 60 => priorities[5] # immediate
Chris@0 51 }
Chris@0 52
Chris@0 53 TRACKER_BUG = Tracker.find_by_position(1)
Chris@0 54 TRACKER_FEATURE = Tracker.find_by_position(2)
Chris@0 55
Chris@0 56 roles = Role.find(:all, :conditions => {:builtin => 0}, :order => 'position ASC')
Chris@0 57 manager_role = roles[0]
Chris@0 58 developer_role = roles[1]
Chris@0 59 DEFAULT_ROLE = roles.last
Chris@0 60 ROLE_MAPPING = {10 => DEFAULT_ROLE, # viewer
Chris@0 61 25 => DEFAULT_ROLE, # reporter
Chris@0 62 40 => DEFAULT_ROLE, # updater
Chris@0 63 55 => developer_role, # developer
Chris@0 64 70 => manager_role, # manager
Chris@0 65 90 => manager_role # administrator
Chris@0 66 }
Chris@0 67
Chris@0 68 CUSTOM_FIELD_TYPE_MAPPING = {0 => 'string', # String
Chris@0 69 1 => 'int', # Numeric
Chris@0 70 2 => 'int', # Float
Chris@0 71 3 => 'list', # Enumeration
Chris@0 72 4 => 'string', # Email
Chris@0 73 5 => 'bool', # Checkbox
Chris@0 74 6 => 'list', # List
Chris@0 75 7 => 'list', # Multiselection list
Chris@0 76 8 => 'date', # Date
Chris@0 77 }
Chris@0 78
Chris@0 79 RELATION_TYPE_MAPPING = {1 => IssueRelation::TYPE_RELATES, # related to
Chris@0 80 2 => IssueRelation::TYPE_RELATES, # parent of
Chris@0 81 3 => IssueRelation::TYPE_RELATES, # child of
Chris@0 82 0 => IssueRelation::TYPE_DUPLICATES, # duplicate of
Chris@0 83 4 => IssueRelation::TYPE_DUPLICATES # has duplicate
Chris@0 84 }
Chris@0 85
Chris@0 86 class MantisUser < ActiveRecord::Base
Chris@0 87 set_table_name :mantis_user_table
Chris@0 88
Chris@0 89 def firstname
Chris@0 90 @firstname = realname.blank? ? username : realname.split.first[0..29]
Chris@0 91 @firstname.gsub!(/[^\w\s\'\-]/i, '')
Chris@0 92 @firstname
Chris@0 93 end
Chris@0 94
Chris@0 95 def lastname
Chris@0 96 @lastname = realname.blank? ? '-' : realname.split[1..-1].join(' ')[0..29]
Chris@0 97 @lastname.gsub!(/[^\w\s\'\-]/i, '')
Chris@0 98 @lastname = '-' if @lastname.blank?
Chris@0 99 @lastname
Chris@0 100 end
Chris@0 101
Chris@0 102 def email
Chris@0 103 if read_attribute(:email).match(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i) &&
Chris@0 104 !User.find_by_mail(read_attribute(:email))
Chris@0 105 @email = read_attribute(:email)
Chris@0 106 else
Chris@0 107 @email = "#{username}@foo.bar"
Chris@0 108 end
Chris@0 109 end
Chris@0 110
Chris@0 111 def username
Chris@0 112 read_attribute(:username)[0..29].gsub(/[^a-zA-Z0-9_\-@\.]/, '-')
Chris@0 113 end
Chris@0 114 end
Chris@0 115
Chris@0 116 class MantisProject < ActiveRecord::Base
Chris@0 117 set_table_name :mantis_project_table
Chris@0 118 has_many :versions, :class_name => "MantisVersion", :foreign_key => :project_id
Chris@0 119 has_many :categories, :class_name => "MantisCategory", :foreign_key => :project_id
Chris@0 120 has_many :news, :class_name => "MantisNews", :foreign_key => :project_id
Chris@0 121 has_many :members, :class_name => "MantisProjectUser", :foreign_key => :project_id
Chris@0 122
Chris@0 123 def identifier
chris@37 124 read_attribute(:name).gsub(/[^a-z0-9\-]+/, '-').slice(0, Project::IDENTIFIER_MAX_LENGTH)
Chris@0 125 end
Chris@0 126 end
Chris@0 127
Chris@0 128 class MantisVersion < ActiveRecord::Base
Chris@0 129 set_table_name :mantis_project_version_table
Chris@0 130
Chris@0 131 def version
Chris@0 132 read_attribute(:version)[0..29]
Chris@0 133 end
Chris@0 134
Chris@0 135 def description
Chris@0 136 read_attribute(:description)[0..254]
Chris@0 137 end
Chris@0 138 end
Chris@0 139
Chris@0 140 class MantisCategory < ActiveRecord::Base
Chris@0 141 set_table_name :mantis_project_category_table
Chris@0 142 end
Chris@0 143
Chris@0 144 class MantisProjectUser < ActiveRecord::Base
Chris@0 145 set_table_name :mantis_project_user_list_table
Chris@0 146 end
Chris@0 147
Chris@0 148 class MantisBug < ActiveRecord::Base
Chris@0 149 set_table_name :mantis_bug_table
Chris@0 150 belongs_to :bug_text, :class_name => "MantisBugText", :foreign_key => :bug_text_id
Chris@0 151 has_many :bug_notes, :class_name => "MantisBugNote", :foreign_key => :bug_id
Chris@0 152 has_many :bug_files, :class_name => "MantisBugFile", :foreign_key => :bug_id
Chris@0 153 has_many :bug_monitors, :class_name => "MantisBugMonitor", :foreign_key => :bug_id
Chris@0 154 end
Chris@0 155
Chris@0 156 class MantisBugText < ActiveRecord::Base
Chris@0 157 set_table_name :mantis_bug_text_table
Chris@0 158
Chris@0 159 # Adds Mantis steps_to_reproduce and additional_information fields
Chris@0 160 # to description if any
Chris@0 161 def full_description
Chris@0 162 full_description = description
Chris@0 163 full_description += "\n\n*Steps to reproduce:*\n\n#{steps_to_reproduce}" unless steps_to_reproduce.blank?
Chris@0 164 full_description += "\n\n*Additional information:*\n\n#{additional_information}" unless additional_information.blank?
Chris@0 165 full_description
Chris@0 166 end
Chris@0 167 end
Chris@0 168
Chris@0 169 class MantisBugNote < ActiveRecord::Base
Chris@0 170 set_table_name :mantis_bugnote_table
Chris@0 171 belongs_to :bug, :class_name => "MantisBug", :foreign_key => :bug_id
Chris@0 172 belongs_to :bug_note_text, :class_name => "MantisBugNoteText", :foreign_key => :bugnote_text_id
Chris@0 173 end
Chris@0 174
Chris@0 175 class MantisBugNoteText < ActiveRecord::Base
Chris@0 176 set_table_name :mantis_bugnote_text_table
Chris@0 177 end
Chris@0 178
Chris@0 179 class MantisBugFile < ActiveRecord::Base
Chris@0 180 set_table_name :mantis_bug_file_table
Chris@0 181
Chris@0 182 def size
Chris@0 183 filesize
Chris@0 184 end
Chris@0 185
Chris@0 186 def original_filename
Chris@0 187 MantisMigrate.encode(filename)
Chris@0 188 end
Chris@0 189
Chris@0 190 def content_type
Chris@0 191 file_type
Chris@0 192 end
Chris@0 193
Chris@0 194 def read(*args)
Chris@0 195 if @read_finished
Chris@0 196 nil
Chris@0 197 else
Chris@0 198 @read_finished = true
Chris@0 199 content
Chris@0 200 end
Chris@0 201 end
Chris@0 202 end
Chris@0 203
Chris@0 204 class MantisBugRelationship < ActiveRecord::Base
Chris@0 205 set_table_name :mantis_bug_relationship_table
Chris@0 206 end
Chris@0 207
Chris@0 208 class MantisBugMonitor < ActiveRecord::Base
Chris@0 209 set_table_name :mantis_bug_monitor_table
Chris@0 210 end
Chris@0 211
Chris@0 212 class MantisNews < ActiveRecord::Base
Chris@0 213 set_table_name :mantis_news_table
Chris@0 214 end
Chris@0 215
Chris@0 216 class MantisCustomField < ActiveRecord::Base
Chris@0 217 set_table_name :mantis_custom_field_table
Chris@0 218 set_inheritance_column :none
Chris@0 219 has_many :values, :class_name => "MantisCustomFieldString", :foreign_key => :field_id
Chris@0 220 has_many :projects, :class_name => "MantisCustomFieldProject", :foreign_key => :field_id
Chris@0 221
Chris@0 222 def format
Chris@0 223 read_attribute :type
Chris@0 224 end
Chris@0 225
Chris@0 226 def name
Chris@0 227 read_attribute(:name)[0..29].gsub(/[^\w\s\'\-]/, '-')
Chris@0 228 end
Chris@0 229 end
Chris@0 230
Chris@0 231 class MantisCustomFieldProject < ActiveRecord::Base
Chris@0 232 set_table_name :mantis_custom_field_project_table
Chris@0 233 end
Chris@0 234
Chris@0 235 class MantisCustomFieldString < ActiveRecord::Base
Chris@0 236 set_table_name :mantis_custom_field_string_table
Chris@0 237 end
Chris@0 238
Chris@0 239
Chris@0 240 def self.migrate
Chris@0 241
Chris@0 242 # Users
Chris@0 243 print "Migrating users"
Chris@0 244 User.delete_all "login <> 'admin'"
Chris@0 245 users_map = {}
Chris@0 246 users_migrated = 0
Chris@0 247 MantisUser.find(:all).each do |user|
Chris@0 248 u = User.new :firstname => encode(user.firstname),
Chris@0 249 :lastname => encode(user.lastname),
Chris@0 250 :mail => user.email,
Chris@0 251 :last_login_on => user.last_visit
Chris@0 252 u.login = user.username
Chris@0 253 u.password = 'mantis'
Chris@0 254 u.status = User::STATUS_LOCKED if user.enabled != 1
Chris@0 255 u.admin = true if user.access_level == 90
Chris@0 256 next unless u.save!
Chris@0 257 users_migrated += 1
Chris@0 258 users_map[user.id] = u.id
Chris@0 259 print '.'
Chris@0 260 end
Chris@0 261 puts
Chris@0 262
Chris@0 263 # Projects
Chris@0 264 print "Migrating projects"
Chris@0 265 Project.destroy_all
Chris@0 266 projects_map = {}
Chris@0 267 versions_map = {}
Chris@0 268 categories_map = {}
Chris@0 269 MantisProject.find(:all).each do |project|
Chris@0 270 p = Project.new :name => encode(project.name),
Chris@0 271 :description => encode(project.description)
Chris@0 272 p.identifier = project.identifier
Chris@0 273 next unless p.save
Chris@0 274 projects_map[project.id] = p.id
Chris@0 275 p.enabled_module_names = ['issue_tracking', 'news', 'wiki']
Chris@0 276 p.trackers << TRACKER_BUG
Chris@0 277 p.trackers << TRACKER_FEATURE
Chris@0 278 print '.'
Chris@0 279
Chris@0 280 # Project members
Chris@0 281 project.members.each do |member|
Chris@0 282 m = Member.new :user => User.find_by_id(users_map[member.user_id]),
Chris@0 283 :roles => [ROLE_MAPPING[member.access_level] || DEFAULT_ROLE]
Chris@0 284 m.project = p
Chris@0 285 m.save
Chris@0 286 end
Chris@0 287
Chris@0 288 # Project versions
Chris@0 289 project.versions.each do |version|
Chris@0 290 v = Version.new :name => encode(version.version),
Chris@0 291 :description => encode(version.description),
Chris@0 292 :effective_date => version.date_order.to_date
Chris@0 293 v.project = p
Chris@0 294 v.save
Chris@0 295 versions_map[version.id] = v.id
Chris@0 296 end
Chris@0 297
Chris@0 298 # Project categories
Chris@0 299 project.categories.each do |category|
Chris@0 300 g = IssueCategory.new :name => category.category[0,30]
Chris@0 301 g.project = p
Chris@0 302 g.save
Chris@0 303 categories_map[category.category] = g.id
Chris@0 304 end
Chris@0 305 end
Chris@0 306 puts
Chris@0 307
Chris@0 308 # Bugs
Chris@0 309 print "Migrating bugs"
Chris@0 310 Issue.destroy_all
Chris@0 311 issues_map = {}
Chris@0 312 keep_bug_ids = (Issue.count == 0)
Chris@0 313 MantisBug.find_each(:batch_size => 200) do |bug|
Chris@0 314 next unless projects_map[bug.project_id] && users_map[bug.reporter_id]
Chris@0 315 i = Issue.new :project_id => projects_map[bug.project_id],
Chris@0 316 :subject => encode(bug.summary),
Chris@0 317 :description => encode(bug.bug_text.full_description),
Chris@0 318 :priority => PRIORITY_MAPPING[bug.priority] || DEFAULT_PRIORITY,
Chris@0 319 :created_on => bug.date_submitted,
Chris@0 320 :updated_on => bug.last_updated
Chris@0 321 i.author = User.find_by_id(users_map[bug.reporter_id])
Chris@0 322 i.category = IssueCategory.find_by_project_id_and_name(i.project_id, bug.category[0,30]) unless bug.category.blank?
Chris@0 323 i.fixed_version = Version.find_by_project_id_and_name(i.project_id, bug.fixed_in_version) unless bug.fixed_in_version.blank?
Chris@0 324 i.status = STATUS_MAPPING[bug.status] || DEFAULT_STATUS
Chris@0 325 i.tracker = (bug.severity == 10 ? TRACKER_FEATURE : TRACKER_BUG)
Chris@0 326 i.id = bug.id if keep_bug_ids
Chris@0 327 next unless i.save
Chris@0 328 issues_map[bug.id] = i.id
Chris@0 329 print '.'
Chris@0 330 STDOUT.flush
Chris@0 331
Chris@0 332 # Assignee
Chris@0 333 # Redmine checks that the assignee is a project member
Chris@0 334 if (bug.handler_id && users_map[bug.handler_id])
Chris@0 335 i.assigned_to = User.find_by_id(users_map[bug.handler_id])
Chris@0 336 i.save_with_validation(false)
Chris@0 337 end
Chris@0 338
Chris@0 339 # Bug notes
Chris@0 340 bug.bug_notes.each do |note|
Chris@0 341 next unless users_map[note.reporter_id]
Chris@0 342 n = Journal.new :notes => encode(note.bug_note_text.note),
Chris@0 343 :created_on => note.date_submitted
Chris@0 344 n.user = User.find_by_id(users_map[note.reporter_id])
Chris@0 345 n.journalized = i
Chris@0 346 n.save
Chris@0 347 end
Chris@0 348
Chris@0 349 # Bug files
Chris@0 350 bug.bug_files.each do |file|
Chris@0 351 a = Attachment.new :created_on => file.date_added
Chris@0 352 a.file = file
Chris@0 353 a.author = User.find :first
Chris@0 354 a.container = i
Chris@0 355 a.save
Chris@0 356 end
Chris@0 357
Chris@0 358 # Bug monitors
Chris@0 359 bug.bug_monitors.each do |monitor|
Chris@0 360 next unless users_map[monitor.user_id]
Chris@0 361 i.add_watcher(User.find_by_id(users_map[monitor.user_id]))
Chris@0 362 end
Chris@0 363 end
Chris@0 364
Chris@0 365 # update issue id sequence if needed (postgresql)
Chris@0 366 Issue.connection.reset_pk_sequence!(Issue.table_name) if Issue.connection.respond_to?('reset_pk_sequence!')
Chris@0 367 puts
Chris@0 368
Chris@0 369 # Bug relationships
Chris@0 370 print "Migrating bug relations"
Chris@0 371 MantisBugRelationship.find(:all).each do |relation|
Chris@0 372 next unless issues_map[relation.source_bug_id] && issues_map[relation.destination_bug_id]
Chris@0 373 r = IssueRelation.new :relation_type => RELATION_TYPE_MAPPING[relation.relationship_type]
Chris@0 374 r.issue_from = Issue.find_by_id(issues_map[relation.source_bug_id])
Chris@0 375 r.issue_to = Issue.find_by_id(issues_map[relation.destination_bug_id])
Chris@0 376 pp r unless r.save
Chris@0 377 print '.'
Chris@0 378 STDOUT.flush
Chris@0 379 end
Chris@0 380 puts
Chris@0 381
Chris@0 382 # News
Chris@0 383 print "Migrating news"
Chris@0 384 News.destroy_all
Chris@0 385 MantisNews.find(:all, :conditions => 'project_id > 0').each do |news|
Chris@0 386 next unless projects_map[news.project_id]
Chris@0 387 n = News.new :project_id => projects_map[news.project_id],
Chris@0 388 :title => encode(news.headline[0..59]),
Chris@0 389 :description => encode(news.body),
Chris@0 390 :created_on => news.date_posted
Chris@0 391 n.author = User.find_by_id(users_map[news.poster_id])
Chris@0 392 n.save
Chris@0 393 print '.'
Chris@0 394 STDOUT.flush
Chris@0 395 end
Chris@0 396 puts
Chris@0 397
Chris@0 398 # Custom fields
Chris@0 399 print "Migrating custom fields"
Chris@0 400 IssueCustomField.destroy_all
Chris@0 401 MantisCustomField.find(:all).each do |field|
Chris@0 402 f = IssueCustomField.new :name => field.name[0..29],
Chris@0 403 :field_format => CUSTOM_FIELD_TYPE_MAPPING[field.format],
Chris@0 404 :min_length => field.length_min,
Chris@0 405 :max_length => field.length_max,
Chris@0 406 :regexp => field.valid_regexp,
Chris@0 407 :possible_values => field.possible_values.split('|'),
Chris@0 408 :is_required => field.require_report?
Chris@0 409 next unless f.save
Chris@0 410 print '.'
Chris@0 411 STDOUT.flush
Chris@0 412 # Trackers association
Chris@0 413 f.trackers = Tracker.find :all
Chris@0 414
Chris@0 415 # Projects association
Chris@0 416 field.projects.each do |project|
Chris@0 417 f.projects << Project.find_by_id(projects_map[project.project_id]) if projects_map[project.project_id]
Chris@0 418 end
Chris@0 419
Chris@0 420 # Values
Chris@0 421 field.values.each do |value|
Chris@0 422 v = CustomValue.new :custom_field_id => f.id,
Chris@0 423 :value => value.value
Chris@0 424 v.customized = Issue.find_by_id(issues_map[value.bug_id]) if issues_map[value.bug_id]
Chris@0 425 v.save
Chris@0 426 end unless f.new_record?
Chris@0 427 end
Chris@0 428 puts
Chris@0 429
Chris@0 430 puts
Chris@0 431 puts "Users: #{users_migrated}/#{MantisUser.count}"
Chris@0 432 puts "Projects: #{Project.count}/#{MantisProject.count}"
Chris@0 433 puts "Memberships: #{Member.count}/#{MantisProjectUser.count}"
Chris@0 434 puts "Versions: #{Version.count}/#{MantisVersion.count}"
Chris@0 435 puts "Categories: #{IssueCategory.count}/#{MantisCategory.count}"
Chris@0 436 puts "Bugs: #{Issue.count}/#{MantisBug.count}"
Chris@0 437 puts "Bug notes: #{Journal.count}/#{MantisBugNote.count}"
Chris@0 438 puts "Bug files: #{Attachment.count}/#{MantisBugFile.count}"
Chris@0 439 puts "Bug relations: #{IssueRelation.count}/#{MantisBugRelationship.count}"
Chris@0 440 puts "Bug monitors: #{Watcher.count}/#{MantisBugMonitor.count}"
Chris@0 441 puts "News: #{News.count}/#{MantisNews.count}"
Chris@0 442 puts "Custom fields: #{IssueCustomField.count}/#{MantisCustomField.count}"
Chris@0 443 end
Chris@0 444
Chris@0 445 def self.encoding(charset)
Chris@0 446 @ic = Iconv.new('UTF-8', charset)
Chris@0 447 rescue Iconv::InvalidEncoding
Chris@0 448 return false
Chris@0 449 end
Chris@0 450
Chris@0 451 def self.establish_connection(params)
Chris@0 452 constants.each do |const|
Chris@0 453 klass = const_get(const)
Chris@0 454 next unless klass.respond_to? 'establish_connection'
Chris@0 455 klass.establish_connection params
Chris@0 456 end
Chris@0 457 end
Chris@0 458
Chris@0 459 def self.encode(text)
Chris@0 460 @ic.iconv text
Chris@0 461 rescue
Chris@0 462 text
Chris@0 463 end
Chris@0 464 end
Chris@0 465
Chris@0 466 puts
Chris@0 467 if Redmine::DefaultData::Loader.no_data?
Chris@0 468 puts "Redmine configuration need to be loaded before importing data."
Chris@0 469 puts "Please, run this first:"
Chris@0 470 puts
Chris@0 471 puts " rake redmine:load_default_data RAILS_ENV=\"#{ENV['RAILS_ENV']}\""
Chris@0 472 exit
Chris@0 473 end
Chris@0 474
Chris@0 475 puts "WARNING: Your Redmine data will be deleted during this process."
Chris@0 476 print "Are you sure you want to continue ? [y/N] "
Chris@0 477 STDOUT.flush
Chris@0 478 break unless STDIN.gets.match(/^y$/i)
Chris@0 479
Chris@0 480 # Default Mantis database settings
Chris@0 481 db_params = {:adapter => 'mysql',
Chris@0 482 :database => 'bugtracker',
Chris@0 483 :host => 'localhost',
Chris@0 484 :username => 'root',
Chris@0 485 :password => '' }
Chris@0 486
Chris@0 487 puts
Chris@0 488 puts "Please enter settings for your Mantis database"
Chris@0 489 [:adapter, :host, :database, :username, :password].each do |param|
Chris@0 490 print "#{param} [#{db_params[param]}]: "
Chris@0 491 value = STDIN.gets.chomp!
Chris@0 492 db_params[param] = value unless value.blank?
Chris@0 493 end
Chris@0 494
Chris@0 495 while true
Chris@0 496 print "encoding [UTF-8]: "
Chris@0 497 STDOUT.flush
Chris@0 498 encoding = STDIN.gets.chomp!
Chris@0 499 encoding = 'UTF-8' if encoding.blank?
Chris@0 500 break if MantisMigrate.encoding encoding
Chris@0 501 puts "Invalid encoding!"
Chris@0 502 end
Chris@0 503 puts
Chris@0 504
Chris@0 505 # Make sure bugs can refer bugs in other projects
Chris@0 506 Setting.cross_project_issue_relations = 1 if Setting.respond_to? 'cross_project_issue_relations'
Chris@0 507
Chris@0 508 # Turn off email notifications
Chris@0 509 Setting.notified_events = []
Chris@0 510
Chris@0 511 MantisMigrate.establish_connection db_params
Chris@0 512 MantisMigrate.migrate
Chris@0 513 end
Chris@0 514 end