annotate .svn/pristine/84/84aef8daed0663b1abb2c50b1715fa8c859e4a68.svn-base @ 1327:287f201c2802 redmine-2.2-integration

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