fraoustin / redmine_indicator

13 stars 8 forks source link

Installation: NoMethodError: undefined method `Migration' for ActiveRecord:Module #4

Closed mangelozzi closed 4 years ago

mangelozzi commented 4 years ago

Using Redmine 4.1 (Rails 5.2)

1. Following Installation Instructions:

redmine@vps-live:~/redmine-4.1.0/plugins$ rake redmine:plugins:migrate NAME=redmine_indicator
(in /home/redmine/redmine-4.1.0)
rake aborted!
ActiveRecord::AdapterNotSpecified: 'development' database is not configured. Available: ["production"]
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/connection_specification.rb:260:in `resolve_symbol_connection'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/connection_specification.rb:241:in `resolve_connection'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/connection_specification.rb:143:in `resolve'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/connection_handling.rb:57:in `establish_connection'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/railtie.rb:136:in `block (2 levels) in <class:Railtie>'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:71:in `instance_eval'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:43:in `block in on_load'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:42:in `each'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:42:in `on_load'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/railtie.rb:132:in `block in <class:Railtie>'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/railties-5.2.4.1/lib/rails/initializable.rb:32:in `instance_exec'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/railties-5.2.4.1/lib/rails/initializable.rb:32:in `run'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/railties-5.2.4.1/lib/rails/initializable.rb:61:in `block in run_initializers'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/railties-5.2.4.1/lib/rails/initializable.rb:60:in `run_initializers'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/railties-5.2.4.1/lib/rails/application.rb:361:in `initialize!'
/home/redmine/redmine-4.1.0/config/environment.rb:16:in `<top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/railties-5.2.4.1/lib/rails/application.rb:337:in `require_environment!'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/railties-5.2.4.1/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
/home/redmine/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => redmine:plugins:migrate => environment
(See full trace by running task with --trace)

2. Add RAILS_ENV=production

redmine@vps-live:~/redmine-4.1.0/plugins$ rake redmine:plugins:migrate NAME=redmine_indicator RAILS_ENV=production
(in /home/redmine/redmine-4.1.0)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class IndicatorCustomFields < ActiveRecord::Migration[4.2]
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:528:in `inherited'
/home/redmine/redmine-4.1.0/plugins/redmine_indicator/db/migrate/20191221_indicator_custom_fields.rb:1:in `<top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:986:in `load_migration'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:982:in `migration'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:977:in `disable_ddl_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1350:in `use_transaction?'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1342:in `ddl_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1262:in `each'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1210:in `block in migrate'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1210:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:510:in `up'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1011:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:542:in `migrate_plugin'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:483:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:494:in `migrate'
/home/redmine/redmine-4.1.0/lib/tasks/redmine.rake:135:in `block (3 levels) in <top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
/home/redmine/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'

Caused by:
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class IndicatorCustomFields < ActiveRecord::Migration[4.2]
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:528:in `inherited'
/home/redmine/redmine-4.1.0/plugins/redmine_indicator/db/migrate/20191221_indicator_custom_fields.rb:1:in `<top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:986:in `load_migration'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:982:in `migration'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:977:in `disable_ddl_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1350:in `use_transaction?'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1342:in `ddl_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1262:in `each'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1210:in `block in migrate'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1210:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:510:in `up'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1011:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:542:in `migrate_plugin'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:483:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:494:in `migrate'
/home/redmine/redmine-4.1.0/lib/tasks/redmine.rake:135:in `block (3 levels) in <top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
/home/redmine/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => redmine:plugins:migrate
(See full trace by running task with --trace)

3. Trying Fix from Issue #3

grep -nR "class IndicatorCustomFields" .
./db/migrate/20191221_indicator_custom_fields.rb:1:class IndicatorCustomFields < ActiveRecord::Migration
vim  ./db/migrate/20191221_indicator_custom_fields.rb

Change line to:

class IndicatorCustomFields < ActiveRecord::Migration [5.2]

Then tried again:

redmine@vps-live:~/redmine-4.1.0/plugins$ rake redmine:plugins:migrate NAME=redmine_indicator RAILS_ENV=production
(in /home/redmine/redmine-4.1.0)
rake aborted!
NoMethodError: undefined method `Migration' for ActiveRecord:Module
/home/redmine/redmine-4.1.0/plugins/redmine_indicator/db/migrate/20191221_indicator_custom_fields.rb:1:in `<top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:986:in `load_migration'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:982:in `migration'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:977:in `disable_ddl_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1350:in `use_transaction?'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1297:in `rescue in execute_migration_in_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1285:in `execute_migration_in_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1262:in `each'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1210:in `block in migrate'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1210:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:510:in `up'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1011:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:542:in `migrate_plugin'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:483:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:494:in `migrate'
/home/redmine/redmine-4.1.0/lib/tasks/redmine.rake:135:in `block (3 levels) in <top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
/home/redmine/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'

Caused by:
NoMethodError: undefined method `Migration' for ActiveRecord:Module
/home/redmine/redmine-4.1.0/plugins/redmine_indicator/db/migrate/20191221_indicator_custom_fields.rb:1:in `<top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:986:in `load_migration'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:982:in `migration'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:977:in `disable_ddl_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1350:in `use_transaction?'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1342:in `ddl_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1262:in `each'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1210:in `block in migrate'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1210:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:510:in `up'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1011:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:542:in `migrate_plugin'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:483:in `migrate'
/home/redmine/redmine-4.1.0/lib/redmine/plugin.rb:494:in `migrate'
/home/redmine/redmine-4.1.0/lib/tasks/redmine.rake:135:in `block (3 levels) in <top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/home/redmine/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
/home/redmine/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => redmine:plugins:migrate
(See full trace by running task with --trace)

Also tried:

RAILS_ENV=production bundle exec rake redmine:plugins:migrate NAME=redmine_indicator

But get the same NoMethodError: undefined methodMigration' for ActiveRecord:Module` error as before.

Jonixxz commented 4 years ago

Michel, I think you are misplacing the Judgment proves so : class IndicatorCustomFields < ActiveRecord::Migration[5.2] don't leave space between, migration and the version.

mangelozzi commented 4 years ago

You are right! Without a space it works! In Issue 3 (the fix I followed it incorrectly shows a space): https://github.com/fraoustin/redmine_indicator/issues/3#issuecomment-586459244

fraoustin commented 4 years ago

Hi do you know a solution for this problem of compatibility between version? I searched but id don't found

mangelozzi commented 4 years ago

Sorry I don't know ruby or rails, I normally code in python.

fraoustin commented 4 years ago

as me ...

fraoustin commented 4 years ago

I find a solution version 0.2.11