ralli / migrate_from_bugzilla

bugzilla to redmine migration rake task
15 stars 14 forks source link

Validation failed: Tracker is not included in the list #21

Open mithrandir1 opened 10 years ago

mithrandir1 commented 10 years ago

Hello!

Both bugzilla and redmine are using mysql databases, the script aborts at the issue migration:

Migrating profiles ................................................... Migrating products.................................... Migrating relationship product/profile Migrating issues rake aborted! Validation failed: Tracker is not included in the list /var/lib/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/validations.rb:56:in save!' /var/lib/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/attribute_methods/dirty.rb:33:insave!' /var/lib/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:264:in block in save!' /var/lib/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:313:inblock in with_transaction_returning_status' /var/lib/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in transaction' /var/lib/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:208:intransaction' /var/lib/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:311:in with_transaction_returning_status' /var/lib/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:264:insave!' /opt/redmine/lib/tasks/migrate_from_bugzilla.rake:403:in block in migrate_issues' /opt/redmine/lib/tasks/migrate_from_bugzilla.rake:371:ineach' /opt/redmine/lib/tasks/migrate_from_bugzilla.rake:371:in migrate_issues' /opt/redmine/lib/tasks/migrate_from_bugzilla.rake:574:inmodule:BugzillaMigrate' /opt/redmine/lib/tasks/migrate_from_bugzilla.rake:46:in block (2 levels) in <top (required)>' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:236:incall' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:236:in block in execute' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:231:ineach' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:231:in execute' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:175:inblock in invoke_with_call_chain' /usr/lib/ruby/2.1.0/monitor.rb:211:in mon_synchronize' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:168:ininvoke_with_call_chain' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:161:in invoke' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:149:ininvoke_task' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:106:in block (2 levels) in top_level' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:106:ineach' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:106:in block in top_level' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:115:inrun_with_threads' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:100:in top_level' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:78:inblock in run' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:165:in standard_exception_handling' /var/lib/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:75:inrun' /var/lib/gems/2.1.0/gems/rake-10.1.1/bin/rake:33:in <top (required)>' /usr/local/bin/rake:23:inload' /usr/local/bin/rake:23:in `

' Tasks: TOP => redmine:migrate_from_bugzilla

After some research I found the cause of the problem. You have to assign the tracker "Bug" to the newly created project, so I added the line 316:

    BugzillaProduct.find_each do |product|
      project = Project.new
      project.name = product.name
      project.description = product.description
      project.identifier = "#{product.name.downcase.gsub(/[^a-z0-9]+/, '-')[0..10]}-#{product.id}"
      project.is_public = false
      project.trackers << TRACKER_BUG unless project.trackers.include?(TRACKER_BUG)
      project.save!

Then the migration worked like a charm.