Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to migrate from redmine 1.0 to redmine 2.3 and am getting errors when running db:migrate.

sudo rake db:migrate RAILS_ENV=production --trace

(in /opt/redmine-2.3)
/var/lib/gems/1.8/gems/rake-10.0.4/lib/rake/file_utils.rb:9: warning: already initialized constant RUBY
/var/lib/gems/1.8/gems/rake-10.0.4/lib/rake/file_utils.rb:86: warning: already initialized constant LN_SUPPORTED
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
==  BuildProjectsTree: migrating ==============================================
rake aborted!
An error has occurred, all later migrations canceled:

undefined method `inherit_members_changed?' for #<Project:0x7f82e2dad038>
/var/lib/gems/1.8/gems/activemodel-3.2.13/lib/active_model/attribute_methods.rb:407:in `method_missing'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/attribute_methods.rb:149:in `method_missing'
/opt/redmine-2.3/app/models/project.rb:85:in `_callback_after_748'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:460:in `_run__1269722363__save__4__callbacks'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `send'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `send'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/callbacks.rb:264:in `create_or_update'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/persistence.rb:104:in `save!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/validations.rb:56:in `save!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:264:in `save!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:313:in `with_transaction_returning_status'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:208:in `transaction'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:264:in `save!'
/opt/redmine-2.3/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:185:in `rebuild!'
/opt/redmine-2.3/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:192:in `call'
/opt/redmine-2.3/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:192:in `rebuild!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/relation/delegation.rb:6:in `each'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/relation/delegation.rb:6:in `__send__'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/relation/delegation.rb:6:in `each'
/opt/redmine-2.3/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:189:in `rebuild!'
/opt/redmine-2.3/app/models/project.rb:416:in `rebuild_tree!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:208:in `transaction'
/opt/redmine-2.3/app/models/project.rb:414:in `rebuild_tree!'
/opt/redmine-2.3/db/migrate/105_build_projects_tree.rb:3:in `up'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:370:in `up'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `send'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:389:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:528:in `__send__'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:528:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:720:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:777:in `call'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:777:in `ddl_transaction'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:719:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:700:in `each'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:700:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:570:in `up'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:551:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:193
/usr/lib/ruby/1.8/rake.rb:636:in `call'
/usr/lib/ruby/1.8/rake.rb:636:in `execute'
/usr/lib/ruby/1.8/rake.rb:631:in `each'
/usr/lib/ruby/1.8/rake.rb:631:in `execute'
/usr/lib/ruby/1.8/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/rake.rb:583:in `invoke'
/usr/lib/ruby/1.8/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/1.8/rake.rb:2029:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2029:in `each'
/usr/lib/ruby/1.8/rake.rb:2029:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:2023:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2001:in `run'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1998:in `run'
/usr/bin/rake:28

Problem seems to be that project.inherit_members_changed? doesn't exist, but is called on line 85 of project.rb

after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}

Does anyone know what the source of this problem is?

::UPDATE::

I've now tried upgrading to ruby 1.9.3 and get the same error.

rake db:migrate RAILS_ENV=production
==  BuildProjectsTree: migrating ==============================================
rake aborted!
An error has occurred, all later migrations canceled:

undefined method `inherit_members_changed?' for #<Project:0x00000004b36d80>

Could it be a rake version issue?

I ran bundle install too and installed all the needed gems.

share|improve this question
    
Which version of Ruby? –  Joel E Salas Apr 10 '13 at 19:54
    
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux] –  Scone Apr 11 '13 at 5:15

3 Answers 3

up vote 3 down vote accepted

Your Ruby is too old. Redmine will deceitfully tell you that the latest version of Redmine works with Ruby 1.8.7, but I lost about two hours to this lie. I have Redmine working on CentOS 6.4 with ruby 1.9.3p385. Try updating to that version and you'll probably be able to run your rake command. Update Ruby thusly:

http://www.ruby-lang.org/en/downloads/ (check out the Third Party Tools/RVM section).

share|improve this answer
    
No love. ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] –  Scone Apr 12 '13 at 3:44
    
Try doing a gem update –  Joel E Salas Apr 12 '13 at 4:52
    
Upgrading ruby fixed the issue. I did apt-get purge ruby and then reinstalled ruby 1.9.3. Migration worked. –  Scone Apr 12 '13 at 19:06

I had the exact same error on Centos 6.2 with Ruby 1.9.3-p392 trying to upgrade to 2.3.0 from 0.8.x. Ruby and gem at latest versions. I did this.

Change the database. You may not have to drop the indexes, I did because of the half upgraded state.

alter table projects add column inherit_members boolean default false;
update projects set inherit_members = false;

drop index changesets_repos_scmid;
drop index index_attachments_on_author_id;
drop index index_attachments_on_container_id_and_container_type;
drop index index_attachments_on_created_on;
drop index index_auth_sources_on_id_and_type;
drop index index_boards_on_last_message_id;
drop index index_changesets_on_committed_on;
drop index index_changesets_on_repository_id;
drop index index_changesets_on_user_id;
drop index index_comments_on_author_id;
drop index index_comments_on_commented_id_and_commented_type;
drop index index_custom_fields_on_id_and_type;
drop index index_custom_fields_projects_on_custom_field_id_and_project_id;
drop index index_custom_fields_trackers_on_custom_field_id_and_tracker_id;
drop index index_custom_values_on_custom_field_id;
drop index index_documents_on_category_id;
drop index index_documents_on_created_on;
drop index index_issue_categories_on_assigned_to_id;
drop index index_issue_relations_on_issue_from_id;
drop index index_issue_relations_on_issue_from_id_and_issue_to_id;
drop index index_issue_relations_on_issue_to_id;
drop index index_issues_on_assigned_to_id;
drop index index_issues_on_author_id;
drop index index_issues_on_category_id;
drop index index_issues_on_created_on;
drop index index_issues_on_fixed_version_id;
drop index index_issues_on_priority_id
drop index index_issues_on_priority_id;
drop index index_issues_on_status_id;
drop index index_issues_on_tracker_id;
drop index index_issue_statuses_on_is_closed;
drop index index_issue_statuses_on_is_default;
drop index index_issue_statuses_on_position;
drop index index_journals_on_created_on;
drop index index_journals_on_journalized_id;
drop index index_journals_on_user_id;
drop index index_members_on_project_id;
drop index index_members_on_user_id;
drop index index_members_on_user_id_and_project_id;
drop index index_messages_on_author_id;
drop index index_messages_on_created_on;
drop index index_messages_on_last_reply_id;
drop index index_news_on_author_id;
drop index index_news_on_created_on;
drop index index_queries_on_project_id;
drop index index_queries_on_user_id;
drop index index_repositories_on_project_id;
drop index index_settings_on_name;
drop index index_time_entries_on_activity_id;
drop index index_time_entries_on_created_on;
drop index index_time_entries_on_user_id;
drop index index_tokens_on_user_id;
drop index index_user_preferences_on_user_id;
drop index index_users_on_auth_source_id;
drop index index_users_on_id_and_type;
drop index index_users_on_type;
drop index index_watchers_on_user_id;
drop index index_watchers_on_watchable_id_and_watchable_type;
drop index index_wiki_contents_on_author_id;
drop index index_wiki_content_versions_on_updated_on;
drop index index_wiki_pages_on_parent_id;
drop index index_wiki_pages_on_wiki_id;
drop index index_wiki_redirects_on_wiki_id;
drop index index_workflows_on_new_status_id;
drop index index_workflows_on_old_status_id;
drop index index_workflows_on_role_id;
drop index projects_trackers_unique;
drop index tokens_value;
drop index watchers_user_id_type;

cd /usr/local/redmine
rake tmp:cache:clear
rake tmp:sessions:clear
rake generate_secret_token
rake --trace db:migrate RAILS_ENV=production


That one will fail on the column that it originally complained about not existing as in the parent question.
"ERROR: column "inherit_members" of relation "projects" already exists"
Remove the column and migrate again:

alter table projects drop column inherit_members;

cd /usr/local/redmine
rake --trace db:migrate RAILS_ENV=production

Completes without error.

share|improve this answer

I tried both solutions above, and the option to edit the database was the only one that worked. Upgrading to Ruby 2.1 did not change anything. However, I can comment that I did not need the 'drop index' commands, and, depending on how many failed migrations I had, I sometimes needed to drop the member roles tables. The final, most repeatable solution I had was to not manually edit the database during the migration but instead I edited the migration files themselves so that the inherit_members field was removed at the right point and added back again at the right point. The two files to edit are:

  • db/migrate/20130202090625_add_projects_inherit_members.rb
    • Requires addition of the line remove_column :projects, :inherit_members before adding the projects column
  • db/migrate/105_build_projects_tree.rb
    • Requires addition of add_column :projects, :inherit_members, :boolean, :default => false, :null => false before Project.rebuid_tree!

After these two changes, a complete upgrade process can be done in one go without opening a mysql shell (except for the initial create database, user and permissions commands, of course).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.