Running db:migrate gives "Duplicate column name 'fields_bits'"
Added by Jack Edwards over 11 years ago
I have spent the past few days trying to upgrade Redmine from version 2.2.3 to version 2.3 without success.
First, my environment info:
Debian Squeeze Phusion Passenger 4.0.10 Ruby 2.0.0-p247 (installed using RVM) MySQL 5.1.66 $ RAILS_ENV=production script/about /home/redmine/redmine/redmine-2.3/lib/SVG/Graph/Graph.rb:3: warning: class variable access from toplevel Environment: Redmine version 2.3.2.stable.12039 Ruby version 2.0.0-p247 (2013-06-27) [x86_64-linux] Rails version 3.2.13 Environment production Database adapter MySQL Redmine plugins: no plugin installed
I tried following various different tutorials but keep hitting problems with the db:migrate script. Recently though, I managed to get most things working again by creating a blank database, running db:migrate on that and then finally applying a database backup on top of it.
I can view tickets, modify them, etc. However, going to the Settings page for a project gives a 500 with the error log:
Completed 500 Internal Server Error in 13ms ActionView::Template::Error (undefined method `inherit_members' for #<Project:0x00000007374c20>): 17: <% end %> 18: 19: <% if @project.safe_attribute? 'inherit_members' %> 20: <p><%= f.check_box :inherit_members %></p> 21: <% end %> 22: 23: <%= wikitoolbar_for 'project_description' %> lib/redmine/views/labelled_form_builder.rb:31:in `check_box' app/views/projects/_form.html.erb:20:in `_app_views_projects__form_html_erb__978803551432315059_36460680' app/views/projects/_edit.html.erb:2:in `block in _app_views_projects__edit_html_erb__3370319587961497889_36405800' app/helpers/application_helper.rb:948:in `labelled_form_for' app/views/projects/_edit.html.erb:1:in `_app_views_projects__edit_html_erb__3370319587961497889_36405800' app/views/common/_tabs.html.erb:24:in `block in _app_views_common__tabs_html_erb__4185928721438183996_36233320' app/views/common/_tabs.html.erb:23:in `each' app/views/common/_tabs.html.erb:23:in `_app_views_common__tabs_html_erb__4185928721438183996_36233320' app/helpers/application_helper.rb:271:in `render_tabs' app/views/projects/settings.html.erb:3:in `_app_views_projects_settings_html_erb___2674290207882845525_36212360'
This ticket: http://www.redmine.org/issues/13757 recommends doing a db migrate in order to fix this. However, doing so gives me the same error I have been wrestling with for a while now:
== AddTrackersFieldsBits: migrating ========================================== -- add_column(:trackers, :fields_bits, :integer, {:default=>0}) rake aborted! An error has occurred, all later migrations canceled: Mysql::Error: Duplicate column name 'fields_bits': ALTER TABLE `trackers` ADD `fields_bits` int(11) DEFAULT 0/usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `block in execute' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:461:in `add_column' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:466:in `block in method_missing' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:438:in `block in say_with_time' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:438:in `say_with_time' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:458:in `method_missing' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:334:in `method_missing' /home/redmine/redmine/redmine-2.3/db/migrate/20120705074331_add_trackers_fields_bits.rb:3:in `up' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:370:in `up' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `block (2 levels) in migrate' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `block in migrate' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:389:in `migrate' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:528:in `migrate' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:720:in `block (2 levels) in migrate' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:777:in `call' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:777:in `ddl_transaction' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:719:in `block in migrate' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:700:in `each' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:700:in `migrate' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:570:in `up' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/migration.rb:551:in `migrate' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:193:in `block (2 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval' /usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>' Tasks: TOP => db:migrate
I started trying to modify the database migrate scripts so that they only add new table columns if they do not already exist. I gave up on this after realising how big a job this is. Surely I'm on completely the wrong tracks. Please help.
Thank you.
Replies (1)
RE: Running db:migrate gives "Duplicate column name 'fields_bits'" - Added by Jan Niggemann (redmine.org team member) over 11 years ago
What was the first error message you got when trying to upgrade?
I upgraded a similar environment (using, as usual, RedmineUpgrade) without problems from 2.1 to 2.3.2...
If I were you, I'd restore from backup and start anew. Once you get an error, post here and we'll walk you through...