Problem:
I know when upgrading we’re supposed to upgrade one minor version at a time. I was on 2.5 and at first set apt sources for 3.2. I realized my mistake and changed them to 3.0 but had already installed the packages. I did not realize that changing down to 3.0 and performing apt upgrade
would not downgrade the packages to what was now the latest version and it left the 3.2 packages in place. I then performed foreman-rake db:migrate
and foreman-rake db:seed
.
I suspect that is what’s caused my problem. Everything seems to be working fine except an ActiveRecord issue with the Settings. I am getting errors like:
NameError: uninitialized constant Setting::General
-
The single-table inheritance mechanism failed to locate the subclass: 'Setting::Provisioning'. This error is raised because the column 'category' is reserved for storing the class in case of inheritance.
.
This is happening both in foreman-rake db:seed
and if I try to change a setting in the web UI.
Expected outcome:
Some way to run the db migration step I presume I’ve missed in going from 2.5 straight to 3.2. I tried installing 3.0 and running db:migrate
but it didn’t want to (since the db was now 24 and it was wanting to do 20).
If it is vitally important that upgrades are done one minor version at a time then I would have thought db:migrate
would abort if it detected such a situation? Maybe such a feature would be help others in future.
Foreman and Proxy versions:
3.2.0
Foreman and Proxy plugin versions:
Name | Description | Author | Version |
---|---|---|---|
foreman_bootdisk | Plugin for Foreman that creates iPXE-based boot disks to provision hosts without the need for PXE infrastructure. | Dominic Cleal | 19.0.3 |
foreman_puppet | Allow assigning Puppet environments and classes to the Foreman Hosts. | Ondřej Ezr and Shira Maximov | 3.0.5 |
foreman_setup | Plugin for Foreman that helps set up provisioning. | Dominic Cleal | 8.0.1 |
Distribution and version:
Ubuntu 20.04
Other relevant data:
What I get when trying to run db:seed
:
# foreman-rake db:seed
rake aborted!
ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'Setting::General'. 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.7.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.7.0/gems/activerecord-6.0.3.7/lib/active_record/inheritance.rb:227:in `find_sti_class'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/inheritance.rb:215:in `discriminate_class_for_record'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/persistence.rb:257:in `instantiate'
/usr/share/foreman/vendor/ruby/2.7.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.7.0/gems/activerecord-6.0.3.7/lib/active_record/result.rb:62:in `block in each'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/result.rb:62:in `each'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/result.rb:62:in `each'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:58:in `map'
/usr/share/foreman/vendor/ruby/2.7.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.7.0/gems/activesupport-6.0.3.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:56:in `find_by_sql'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:821:in `block in exec_queries'
/usr/share/foreman/vendor/ruby/2.7.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.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:808:in `exec_queries'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:626:in `load'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:250:in `records'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/finder_methods.rb:499:in `find_take'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/finder_methods.rb:98:in `take'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/finder_methods.rb:81:in `find_by'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:21:in `find_by'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/core.rb:183:in `find_by'
/usr/share/foreman/app/services/setting_registry.rb:186:in `_find_or_new_db_record'
/usr/share/foreman/app/services/setting_registry.rb:67:in `[]='
/usr/share/foreman/app/models/setting.rb:93:in `[]='
/usr/share/foreman/lib/tasks/config.rake:175:in `block in <top (required)>'
/usr/share/foreman/vendor/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
Caused by:
NameError: uninitialized constant Setting::General
/usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:284:in `const_get'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:284:in `block in constantize'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:280:in `each'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:280:in `inject'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/inflector/methods.rb:280:in `constantize'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/inheritance.rb:229:in `find_sti_class'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/inheritance.rb:215:in `discriminate_class_for_record'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/persistence.rb:257:in `instantiate'
/usr/share/foreman/vendor/ruby/2.7.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.7.0/gems/activerecord-6.0.3.7/lib/active_record/result.rb:62:in `block in each'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/result.rb:62:in `each'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/result.rb:62:in `each'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:58:in `map'
/usr/share/foreman/vendor/ruby/2.7.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.7.0/gems/activesupport-6.0.3.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:56:in `find_by_sql'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:821:in `block in exec_queries'
/usr/share/foreman/vendor/ruby/2.7.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.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:808:in `exec_queries'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:626:in `load'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation.rb:250:in `records'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/finder_methods.rb:499:in `find_take'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/finder_methods.rb:98:in `take'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/finder_methods.rb:81:in `find_by'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:21:in `find_by'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/core.rb:183:in `find_by'
/usr/share/foreman/app/services/setting_registry.rb:186:in `_find_or_new_db_record'
/usr/share/foreman/app/services/setting_registry.rb:67:in `[]='
/usr/share/foreman/app/models/setting.rb:93:in `[]='
/usr/share/foreman/lib/tasks/config.rake:175:in `block in <top (required)>'
/usr/share/foreman/vendor/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:seed
(See full trace by running task with --trace)