Upgrade from 2.4.1 to 2.5.1

Problem:
db migration fail when upgrading from 2.4.1 to 2.5.1

Expected outcome:
upgrade success

Foreman and Proxy versions:
2.4.1 -> 2.5.1

Foreman and Proxy plugin versions:
ruby-foreman-hooks 0.3.17-1
ruby-puppetdb-foreman 5.0.0-1

Distribution and version:
Debian 10

Other relevant data:
foreman-rake db:migrate
API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
rake aborted!
ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: ‘Setting::Bootdisk’. This error is raised because the column ‘category’ is reserved for storing the class in case of inheritance. Please rename this column if you didn’t intend it to be used for storing the inheritance class or overwrite Setting.inheritance_column to use another column for that information.
/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/inheritance.rb:234:in rescue in find_sti_class' /usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/inheritance.rb:227:in find_sti_class’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/inheritance.rb:215:in discriminate_class_for_record' /usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/persistence.rb:257:in instantiate’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:58:in block (2 levels) in find_by_sql' /usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/result.rb:62:in block in each’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/result.rb:62:in each' /usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/result.rb:62:in each’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:58:in map' /usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:58:in block in find_by_sql’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/notifications/instrumenter.rb:24:in instrument' /usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:56:in find_by_sql’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:821:in block in exec_queries' /usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:839:in skip_query_cache_if_necessary’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:808:in exec_queries' /usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:626:in load’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:250:in records' /usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/relation/delegation.rb:87:in each’
/usr/share/foreman/app/services/setting_registry.rb:69:in load_values' /usr/share/foreman/config/initializers/foreman.rb:31:in <top (required)>’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in load' /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in block in load’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in load_dependency' /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in load’
/usr/share/foreman/config/initializers/0_print_time_spent.rb:38:in block in load' /usr/share/foreman/config/initializers/0_print_time_spent.rb:17:in benchmark’
/usr/share/foreman/config/initializers/0_print_time_spent.rb:38:in load' /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/engine.rb:666:in block in load_config_initializer’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/notifications.rb:182:in instrument' /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/engine.rb:665:in load_config_initializer’
/usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/engine.rb:625:in block (2 levels) in <class:Engine>' /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/engine.rb:624:in each’
/usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/engine.rb:624:in block in <class:Engine>' /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:32:in instance_exec’
/usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:32:in run' /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:61:in block in run_initializers’
/usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:50:in each' /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:50:in tsort_each_child’
/usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:60:in run_initializers' /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/application.rb:363:in initialize!’
/usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/railtie.rb:190:in public_send' /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/railtie.rb:190:in method_missing’
/usr/share/foreman/config/environment.rb:5:in <top (required)>' /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in require’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in block in require' /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in load_dependency’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in require' /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/application.rb:339:in require_environment!’
/usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.7/lib/rails/application.rb:523:in `block in run_tasks_blocks’

Caused by:
NameError: uninitialized constant Setting::Bootdisk
/usr/share/foreman/vendor/ruby/2.5.0/gems/foreman_hooks-0.3.17/lib/foreman_hooks/as_dependencies_hook.rb:4:in load_missing_constant' /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:284:in const_get’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:284:in block in constantize' /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:280:in each’
/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:280:in inject' /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:280:in constantize’

Most likely you used to have bootdisk plugin installed and it’s no longer present. Either install it again or you’ll have to manually clean up your database. Try apt install ruby-foreman-bootdisk and try running migrations again.

Thank you Marek, here is what I did to fix it :

  • Remove provisionning templates of Kind “Bootdisk” in foreman UI.
  • In Postgres : delete from settings where category=‘Setting::Bootdisk’;
2 Likes