fragen stichworte

Redmine db: Migrationsmethode nicht gefunden

Ich versuche, von Redmin 1.0 auf Redmin 2.3 zu migrieren und erhalte Fehler beim Ausführen von 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

Das Problem scheint zu sein, dass project.inherit_members_changed? ist nicht vorhanden, wird aber in Zeile 85 von project.rb

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

Weiß jemand, was die Ursache dieses Problems ist?

:: UPDATE ::

Ich habe jetzt versucht, auf Ruby 1.9.3 zu aktualisieren und die gleiche Fehlermeldung zu erhalten.

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>

Könnte es eine Rake-Version sein?

Ich habe auch die Bundle-Installation ausgeführt und alle benötigten Edelsteine ​​installiert.

antworten

Dein Rubin ist zu alt. Redmine wird Ihnen täuschenderweise sagen, dass die neueste Version von Redmine mit Ruby 1.8.7 funktioniert, aber ich habe ungefähr zwei Stunden für diese Lüge verloren. Redmine arbeitet an CentOS 6.4 mit Ruby 1.9.3p385. Versuchen Sie, auf diese Version zu aktualisieren, und Sie werden wahrscheinlich Ihren Rake-Befehl ausführen können. Aktualisiere Ruby so:

http://www.ruby-lang.org/en/downloads/ (siehe den Abschnitt "Third Party Tools/RVM").

Ich habe oben beide Lösungen ausprobiert und die Option zum Bearbeiten der Datenbank war die einzige, die funktionierte. Das Upgrade auf Ruby 2.1 hat nichts geändert. Ich kann jedoch kommentieren, dass ich die Befehle zum Löschen des Index nicht benötigte. Abhängig von der Anzahl der fehlgeschlagenen Migrationen musste ich manchmal die Mitgliederrollentabellen löschen. Die letzte und wiederholbarste Lösung, die ich hatte, bestand darin, die Datenbank während der Migration nicht manuell zu bearbeiten, sondern die Migrationsdateien selbst so zu bearbeiten, dass das Feld "birthit_members" an der richtigen Stelle entfernt und an der richtigen Stelle wieder hinzugefügt wurde. Die zwei zu bearbeitenden Dateien sind:

  • db/migrate/20130202090625_add_projects_inherit_members.rb
    • Erfordert das Hinzufügen der Zeile remove_column :projects, :inherit_members, bevor die Spalte projects hinzugefügt wird
  • db/migrate/105_build_projects_tree.rb
    • Vor Project.rebuid_tree muss add_column :projects, :inherit_members, :boolean, :default => false, :null => false hinzugefügt werden!

Nach diesen beiden Änderungen kann ein vollständiger Upgrade-Vorgang in einem Durchgang durchgeführt werden, ohne dass eine MySQL-Shell geöffnet wird (mit Ausnahme der ursprünglichen Befehle create database, user und permissions).

Ich hatte genau den gleichen Fehler auf Centos 6.2 mit Ruby 1.9.3-p392 versucht, von 0.8.x auf 2.3.0 zu aktualisieren. Ruby und Juwel in den neuesten Versionen. Ich tat dies.

Ändern Sie die Datenbank. Sie müssen die Indizes möglicherweise nicht löschen, was ich wegen des halb aktualisierten Status getan habe.

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


Dieser wird in der Spalte, die er ursprünglich beschwert hat, nicht existieren wie in der Elternfrage "ERROR: Spalte" inherit_members "der Beziehung" projects "existiert bereits."
Entfernen Sie die Spalte und migrieren Sie erneut:

alter table projects drop column inherit_members;

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

Wird ohne Fehler abgeschlossen.