Problem: foreman-rake db:migrate fails with error “PG::UndefinedColumn: ERROR: column “evr” does not exist”
Expected outcome: upgrade successful
Foreman and Proxy versions:
Foreman 3.14
Katello 4.16
Foreman and Proxy plugin versions:
Distribution and version:
Other relevant data:
This Foreman server was recently upgraded from RHEL 8 to RHEL 9 along with Foreman upgrade from 3.12 to 3.14 by following the official documentation. One additional step I had to do when upgrading from 3.13 to 3.14 was to remove “evr” from PGSQL DB with “drop extension evr cascade” to make the upgrade work. Now when upgrading to new version of Katello package, the foreman-installer and foreman-rake db:migrate fails.
Error that appears with foreman-rake db:migrate is the following:
# foreman-rake db:migrate --trace --verbose
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Invoke plugin:refresh_migrations (first_time)
** Invoke environment
** Execute plugin:refresh_migrations
** Execute db:migrate
== 20250714190050 AddMissingRpmsEvrIndex: migrating ===========================
-- index_exists?(:katello_rpms, [:name, :arch, :evr])
-> 0.0119s
-- add_index(:katello_rpms, [:name, :arch, :evr])
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedColumn: ERROR: column "evr" does not exist
The rest of the error is too long and omitted.
Is there a way to restore or reinstall the “evr” back into the DB, so that I can resolve this issue?
Hi @JasenkoC ,
Do you recall why you needed to drop the EVR extension manually? The cascading removal likely dropped a bunch of things in the DB that are needed for package applicability calculations.
To fix it you can try re-running this migration, which is part of the migration away from needing the postgresql-evr RPM installed on the system: Blaming katello/db/migrate/20240924161240_katello_recreate_evr_constructs.rb at master · Katello/katello · GitHub
foreman-rake db:migrate:redo VERSION=20240924161240
I think you’ll need to first hack out these lines from the migration katello/db/migrate/20240924161240_katello_recreate_evr_constructs.rb at 21b4d5c61d2b7e364ce9d8b0b49c07639c368205 · Katello/katello · GitHub
1 Like
This actually worked! Thanks a lot!
I had to remove a couple of orphaned evr functions like “isalphanum” and “digit” manually, and that did the trick.
I don’t remember the exact reason, but it was failing in foreman-installer, probably at the same “db:migrate” step due to evr issues, so I removed it which fixed everything until this katello 4.16.3 package update came along.
Thanks again!
1 Like
Nice, glad to hear it worked. You might want to keep an eye on errata applicability data if you use it, just to be sure everything is where it should be. But, if the katello_rpms evr index migration ran successfully, you should be okay.
1 Like
We don’t actively use it, but the errata and its details seems to be intact. Applicability also seems to work. Everything else seems to be in place as well. Luckily all of the db tasks in foreman-installer worked flawlessly after the fix. Thank you again for your quick help with this.
1 Like