Project

General

Profile

rake aborted!

Added by Rafi Greenberg over 14 years ago

Trying to upgrade from 0.9.5 to 1.0.0 RC. Database migration fails.

[root@localhost redmine-1.0.0]# rake db:migrate RAILS_ENV=production --trace
(in /srv/redmine-1.0.0)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  AddRolePosition: migrating ================================================
-- add_column(:roles, :position, :integer, {:default=>1})
rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: Duplicate column name 'position': ALTER TABLE `roles` ADD `position` int(11) DEFAULT 1
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:219:in `log'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:323:in `execute'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:195:in `add_column'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `send'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `method_missing'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:348:in `method_missing'
./db/migrate//020_add_role_position.rb:3:in `up_without_benchmarks'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `send'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `migrate'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:365:in `__send__'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:365:in `migrate'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:486:in `migrate'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:562:in `call'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:562:in `ddl_transaction'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:485:in `migrate'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:472:in `each'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:472:in `migrate'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:400:in `up'
/srv/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:383:in `migrate'
/srv/redmine-1.0.0/vendor/rails/railties/lib/tasks/databases.rake:116
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:238:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
[root@localhost redmine-1.0.0]# mysql -V
mysql  Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (i386) using readline 5.1

[root@localhost redmine-1.0.0]# /opt/ruby-enterprise/bin/rails -v
Rails 2.3.8

[root@localhost redmine-1.0.0]# /opt/ruby-enterprise/bin/ruby -v
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2010.01

Replies (16)

RE: rake aborted! - Added by Rafi Greenberg over 14 years ago

Well, I just realized that I hadn't run the plugin migrations. So I ran:

# rake db:migrate:upgrade_plugin_migrations RAILS_ENV=production

And now I'm getting an endless

Inserting new version 123705 for plugin redmine_licensing..
Inserting new version 123706 for plugin redmine_licensing..
Inserting new version 123707 for plugin redmine_licensing..
Inserting new version 123708 for plugin redmine_licensing..
Inserting new version 123709 for plugin redmine_licensing..
Inserting new version 123710 for plugin redmine_licensing..
Inserting new version 123711 for plugin redmine_licensing..
Inserting new version 123712 for plugin redmine_licensing..

Ad infinitum...

What is going on here???

RE: rake aborted! - Added by Rafi Greenberg over 14 years ago

Inserting new version 244806 for plugin redmine_licensing..
Inserting new version 244807 for plugin redmine_licensing..
Inserting new version 244808 for plugin redmine_licensing..
Inserting new version 244809 for plugin redmine_licensing..
Inserting new version 244810 for plugin redmine_licensing..
Inserting new version 244811 for plugin redmine_licensing..
Inserting new version 244812 for plugin redmine_licensing..
Inserting new version 244813 for plugin redmine_licensing..
Inserting new version 244814 for plugin redmine_licensing..
Inserting new version 244815 for plugin redmine_licensing..
Inserting new version 244816 for plugin redmine_licensing..

still going...

RE: rake aborted! - Added by Rafi Greenberg over 14 years ago

Inserting new version 373234 for plugin redmine_licensing..
Inserting new version 373235 for plugin redmine_licensing..
Inserting new version 373236 for plugin redmine_licensing..
Inserting new version 373237 for plugin redmine_licensing..
Inserting new version 373238 for plugin redmine_licensing..
Inserting new version 373239 for plugin redmine_licensing..

I'm about to cancel this. Can someone please help?

RE: rake aborted! - Added by Rafi Greenberg over 14 years ago

Can anyone advise on either of these issues?

Thanks!

RE: rake aborted! - Added by Felix Schäfer over 14 years ago

That AddRolePosition migration (the first db:migrate tries to apply) should already have been there in 0.9.5 as it is migration 20, hence your 0.9.5 database seems to have been corrupt to begin with. I'd suggest trying the upgrade again from your backup, if the problem persists, we probably will need a copy of your DB to be able to diagnose the problem.

Regarding the plugin migration, the cause is probably the same, but contact the plugin author to make him aware of the problem.

RE: rake aborted! - Added by Rafi Greenberg over 14 years ago

How can I send you my database without anything private/propietary? Can I leave out certain tables and only send you the tables you need to diagnose the issue?

Thanks

RE: rake aborted! - Added by Felix Schäfer over 14 years ago

Please send me the schema of the DB before and after the upgrade, as well as the contents of the schema_migrations table from before and after upgrade too.

RE: rake aborted! - Added by Felix Schäfer over 14 years ago

And by send me, I mean attach them to your post here, sorry.

RE: rake aborted! - Added by Rafi Greenberg over 14 years ago

Thanks for your help with this Felix.
Since the upgrade was unsuccessful, I'm just posting the current state of the database.
I believe we've had issues upgrading for some time now, and the last time I think I installed to a fresh database then imported the old one. I would prefer to not have to keep doing that.
Anyway, let me know what you find out.

Thanks again!

schema_migrations.csv (616 Bytes) schema_migrations.csv schema_migrations table contents
redmine_scc.sql (34.9 KB) redmine_scc.sql database schema structure

RE: rake aborted! - Added by Felix Schäfer over 14 years ago

Your schema_migrations table doesn't include information about what your core db schema is at all! This causes the db:migration task to start from the very beginning and borking on already existing stuff.

One way you could try to fix this (and make sure you have backups, this is more guessing than 100%-sure knowledge) is to insert the number of the last successful migration. In your working redmine, have a look at db/migrate/, there are a lot of ruby files describing the different db changes. Locate the file with the highest leading number and insert this number (from the redmine svn, it should be 20100221100219, make sure to double-check it) in a new row in the schema_migrations table. From there, try the upgrade again, and I might sound insistent, but make sure you have backups!

RE: rake aborted! - Added by Rafi Greenberg over 14 years ago

I tried adding the number 20100221100219 (which was the highest number in my current installation) to the schema_migrations table, but got the same error as before.

I feel like we're on the right track though. What else needs to be in the schema_migrations table?

RE: rake aborted! - Added by Felix Schäfer over 14 years ago

Mmh, I was under the impression the db:migrate task would only check for the highest migration number, but it seems you will need to somehow collect all the migration numbers and insert them into the table.

RE: rake aborted! - Added by Rafi Greenberg over 14 years ago

I just tried this, and the db:migrate gave no output (success?). Then I tried to run:

db:migrate:upgrade_plugin_migrations RAILS_ENV=production

and I got the same

Inserting new version 1 for plugin redmine_licensing..
Inserting new version 2 for plugin redmine_licensing..
Inserting new version 3 for plugin redmine_licensing..
Inserting new version 4 for plugin redmine_licensing..
...

ad infinitum. Now what to try?

RE: rake aborted! - Added by Felix Schäfer over 14 years ago

You could try adding the migrations of the plugin to the schema_migrations table too, but I don't know the plugin, so I can't really tell you. I fear you'll have to contact the plugin's author for more help.

RE: rake aborted! - Added by Takashi Oguma over 14 years ago

Hi Rafi,

I experienced the same problem.
I fixed the issue by deleting an unnecessary entry (in your case, probably 'redmine_licensing' row has a quite large number in the 'version' column) from 'plugin_migration' table.

RE: rake aborted! - Added by Avram Eisner about 14 years ago

Thank you Takashi!
I had the same problem with the harvest plugin (the number in the version column had like 8 digits!)

    (1-16/16)