Project

General

Profile

Upgrade Redmine 2.5.2-devel to Redmine 3.2 => db:migrate FAILS

Added by Martin Chalot over 7 years ago

Hello,
I am trying to upgrade redmine version 2.5.2-devel to 3.2-stable. For not destroying my database in production i've installed the version 2.5.2-stable of redmine in my server test. Everything is working correctly (except mail I haven't configured).
In this version (2.5.2-devel) there is two things different from 2.5.2-stable :
- demandes_st_load_test : i don't know what kind of table it is
- is_public field is added that doesn't exist in the table of the version 2.5.2-stable (table queries)

I dump the sql file from the production and imported it in the database of my test server.
Then i downloaded the version of redmine 3.2-stable, I configured it etc.. But when I try this command line :

bundle exec rake db:migrate RAILS_ENV=production

It fails saying this :
bundle exec rake db:migrate RAILS_ENV=production
20130602092539 CreateQueriesRoles: migrating =============================
-- create_table(:queries_roles, {:id=>false})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Table 'queries_roles' already exists: CREATE TABLE `queries_roles` (`query_id` int(11) NOT NULL, `role_id` int(11) NOT NULL) ENGINE=InnoDB
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `_query'
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `block in query'
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `handle_interrupt'
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `query'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `block in execute'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
/var/lib/gems/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `execute'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/mysql2_adapter.rb:231:in `execute'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:222:in `create_table'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:474:in `create_table'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:665:in `block in method_missing'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:634:in `block in say_with_time'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:634:in `say_with_time'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:654:in `method_missing'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:416:in `method_missing'
/usr/share/redmine3/db/migrate/20130602092539_create_queries_roles.rb:3:in `up'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:571:in `up'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:611:in `exec_migration'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:591:in `block in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:590:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:768:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:1046:in `ddl_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:959:in `block in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in `each'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:823:in `up'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:801:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/var/lib/gems/2.1.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/ruby_executable_hooks2.1:15:in `eval'
/usr/local/bin/ruby_executable_hooks2.1:15:in `<main>'
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'queries_roles' already exists: CREATE TABLE `queries_roles` (`query_id` int(11) NOT NULL, `role_id` int(11) NOT NULL) ENGINE=InnoDB
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `_query'
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `block in query'
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `handle_interrupt'
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `query'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `block in execute'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
/var/lib/gems/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `execute'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/mysql2_adapter.rb:231:in `execute'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:222:in `create_table'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:474:in `create_table'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:665:in `block in method_missing'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:634:in `block in say_with_time'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:634:in `say_with_time'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:654:in `method_missing'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:416:in `method_missing'
/usr/share/redmine3/db/migrate/20130602092539_create_queries_roles.rb:3:in `up'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:571:in `up'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:611:in `exec_migration'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:591:in `block in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:590:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:768:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:1046:in `ddl_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:959:in `block in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in `each'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:823:in `up'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:801:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/var/lib/gems/2.1.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/ruby_executable_hooks2.1:15:in `eval'
/usr/local/bin/ruby_executable_hooks2.1:15:in `<main>'
Mysql2::Error: Table 'queries_roles' already exists
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `_query'
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `block in query'
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `handle_interrupt'
/var/lib/gems/2.1.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `query'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `block in execute'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
/var/lib/gems/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `execute'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/mysql2_adapter.rb:231:in `execute'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:222:in `create_table'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:474:in `create_table'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:665:in `block in method_missing'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:634:in `block in say_with_time'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:634:in `say_with_time'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:654:in `method_missing'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:416:in `method_missing'
/usr/share/redmine3/db/migrate/20130602092539_create_queries_roles.rb:3:in `up'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:571:in `up'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:611:in `exec_migration'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:591:in `block in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:590:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:768:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:1046:in `ddl_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:959:in `block in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in `each'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:823:in `up'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:801:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/var/lib/gems/2.1.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/ruby_executable_hooks2.1:15:in `eval'
/usr/local/bin/ruby_executable_hooks2.1:15:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

I have also tried to create a fresh new database and the command line is working, but when i try to import the data of the database of course there is a lot of rename field and it fails.
I've been trying for quite a while now and i don't get it. Do you know where the problem is ?

Thanks,
Best Regards,
Martin C.


Replies (3)

RE: Upgrade Redmine 2.5.2-devel to Redmine 3.2 => db:migrate FAILS - Added by Anonymous over 7 years ago

Hi!

Have a look at: http://www.redmine.org/boards/1/topics/50637?r=50784#message-50784

"Table exists" is a consequence of RoR trying to do object relational mapping during upgrade but table exists from import already due to a plugin from source DB-image. In rare cases a table created previously from a plugin can collide with a new table introduced by the target redmine version.

During my upgrade I openede phpmysql, inspected colliding tables for contents and dropped them. Then restarted db-migrate and so on. So iteratively you eliminate error after error.

Cheers

Immanuel.

RE: Upgrade Redmine 2.5.2-devel to Redmine 3.2 => db:migrate FAILS - Added by Martin Chalot over 7 years ago

Thanks for your reply. Things is my tables are not empty. I have a lot of row inside them so I can't allow to delete them to recreate them. The only way i succeed to install the new version of redmine was to create a new database. Use db:migrate that create the new schema with correct database, then dump the "data only" from the former database and insert it by correcting the difference between the version I had and the current version I'm installing.
The only problem i found doing so was that I had to retype the email by hand because in the new version of redmine they use a new table for user's email.

By any chance do you think it could have any others problems that I didn't notice yet in the way I migrated to the new version ? (Right now all seems to work correctly, there wasn't much différences in the database between the version 2.5 to 3.2)

RE: Upgrade Redmine 2.5.2-devel to Redmine 3.2 => db:migrate FAILS - Added by Roberto Tavares about 6 years ago

I have similar issue trying to migrate from 2.6 to 3.4. Even dropping the table, the same error occurs. The message 'Table 'queries_roles' already exists' apears.
I dropped this table and confirmed with a SQL 'Show tables like 'quer%'; (shows only the 'queries' table).
I restarted Redmine and try the upgrade again and same error.

Someone solved this?

Thanks

    (1-3/3)