Error during migration from 2.5 to 2.6 : Mysql2::Error: Duplicate entry

Added by Anonymous over 4 years ago

Hi

I try to upgrade Redmine from 2.5 to 2.6 on a CentOs 7 server. I get the following error :

bundle exec rake db:migrate RAILS_ENV=production --trace
  • Invoke db:migrate (first_time)
  • Invoke environment (first_time)
  • Execute environment
  • Invoke db:load_config (first_time)
  • Execute db:load_config
  • Execute db:migrate
    InsertBuiltinGroups: migrating ==========================================
    rake aborted!
    StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Duplicate entry '0' for key 'PRIMARY': INSERT INTO `users` (`admin`, `auth_source_id`, `created_on`, `firstname`, `hashed_password`, `identity_url`, `language`, `last_login_on`, `lastname`, `login`, `mail`, `mail_notification`, `must_change_passwd`, `passwd_changed_on`, `salt`, `status`, `type`, `updated_on`) VALUES (0, NULL, '2014-11-17 10:55:11', '', '', NULL, '', NULL, 'Non member users', '', '', '', 0, NULL, NULL, 1, 'GroupNonMember', '2014-11-17 10:55:11')/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `block in execute'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/usr/local/share/gems/gems/activesupport-3.2.20/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/connection_adapters/mysql2_adapter.rb:213:in `execute'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/connection_adapters/mysql2_adapter.rb:236:in `exec_insert'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/relation.rb:66:in `insert'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/persistence.rb:367:in `create'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/timestamp.rb:58:in `create'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/callbacks.rb:268:in `block in create'
/usr/local/share/gems/gems/activesupport-3.2.20/lib/active_support/callbacks.rb:414:in `_run__715463877909706621__create__905197470387182340__callbacks'
/usr/local/share/gems/gems/activesupport-3.2.20/lib/active_support/callbacks.rb:405:in `__run_callback'
/usr/local/share/gems/gems/activesupport-3.2.20/lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
/usr/local/share/gems/gems/activesupport-3.2.20/lib/active_support/callbacks.rb:81:in `run_callbacks'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/callbacks.rb:268:in `create'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/persistence.rb:348:in `create_or_update'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/callbacks.rb:264:in `block in create_or_update'
/usr/local/share/gems/gems/activesupport-3.2.20/lib/active_support/callbacks.rb:414:in `_run__715463877909706621__save__905197470387182340__callbacks'
/usr/local/share/gems/gems/activesupport-3.2.20/lib/active_support/callbacks.rb:405:in `__run_callback'
/usr/local/share/gems/gems/activesupport-3.2.20/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
/usr/local/share/gems/gems/activesupport-3.2.20/lib/active_support/callbacks.rb:81:in `run_callbacks'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/callbacks.rb:264:in `create_or_update'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/persistence.rb:84:in `save'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/validations.rb:50:in `save'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/attribute_methods/dirty.rb:22:in `save'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/transactions.rb:259:in `block (2 levels) in save'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/transactions.rb:208:in `transaction'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/transactions.rb:259:in `block in save'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/transactions.rb:258:in `save'
/var/www/html/redmine-2.6/db/migrate/20140920094058_insert_builtin_groups.rb:13:in `up'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:410:in `block (2 levels) in migrate'
/usr/share/ruby/benchmark.rb:281:in `measure'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:410:in `block in migrate'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:389:in `migrate'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:528:in `migrate'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:777:in `call'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:777:in `ddl_transaction'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:719:in `block in migrate'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:700:in `each'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:700:in `migrate'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:570:in `up'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/migration.rb:551:in `migrate'
/usr/local/share/gems/gems/activerecord-3.2.20/lib/active_record/railties/databases.rake:193:in `block (2 levels) in <top (required)>'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/share/ruby/monitor.rb:211:in `mon_synchronize'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/share/gems/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/usr/local/share/gems/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate

Maria DB version : 5.5.37
Rails 3.2.20

  1. RAILS_ENV=production script/about

sh: darcs : commande introuvable
sh: hg : commande introuvable
sh: cvs : commande introuvable
sh: bzr : commande introuvable
Environment:
Redmine version 2.6.0.stable.13591
Ruby version 2.0.0-p353 (2013-11-22) [x86_64-linux]
Rails version 3.2.20
Environment production
Database adapter Mysql2
SCM:
Subversion 1.7.14
Git 1.8.3.1
Filesystem
Redmine plugins:
no plugin installed

The Redmine 2.5 instance works well.

I've done the following steps from RedmineUpgrade :

1. Download the release in either tar.gz or zip format and uncompress the new program archive in a new directory.

2. Copy your database settings-file config/database.yml into the new config directory. If you're running Redmine >= 1.4 with mysql and ruby1.9, change the database adapter to `mysql2`.

3a. Copy your base configuration settings-file config/configuration.yml into the new config directory.

4. Copy the files directory content into your new installation (this directory contains all your uploaded files).

5. Copy the folders of your custom plugins from your plugins directory (or vendor/plugins directory if upgrading from a 1.x version) into new installation plugins directory. Make sure that you copy only plugins that are were not initially bundled with your previous Redmine setup.

6. Install the required gems by running:

bundle install --without development test

7. Run the following command from your new Redmine root directory:

bundle exec rake generate_secret_token

Thanks for your help !

Replies (2)

RE: Error during migration from 2.5 to 2.6 : Mysql2::Error: Duplicate entry - Added by Alex Wilhelmy over 4 years ago

Strange that the migration wants to insert another entry with ID 0. As I understand you updated redmine code but you are still pointing to the same database and now trying to migrate it? Maybe set up another database as a copy and use this for testing the migration?

cheers

Alex

RE: Error during migration from 2.5 to 2.6 : Mysql2::Error: Duplicate entry - Added by Anonymous over 4 years ago

Yes, I followed the RedmineUpgrade wiki page.

I try with a copy of the running database but same error.

Thanks

(1-2/2)