Error importing DB from 1.20 backup to 1.23 install

Problem:
Importing a DB backup to a clean install fails
Expected outcome:
Successful import and system restored
Foreman and Proxy versions:
Original 1.20.2 restoring to 1.23
Foreman and Proxy plugin versions:

Distribution and version:
Centos 7
Other relevant data:

foreman-rake db:import_dump file=/tmp/foreman.1571264558.sql
Your backup is going to be imported from: /tmp/foreman.1571264558.sql
You can backup the old database ‘foreman’ by running:

  • foreman-rake db:dump destination=/mydir/dumps/foreman.sql RAILS_ENV=production
    This task will destroy your old database tables! Are you sure you want to continue? [y/N]
    y
    pg_restore: [archiver (db)] Error while PROCESSING TOC:
    pg_restore: [archiver (db)] Error from TOC entry 3812; 2606 17428 FK CONSTRAINT features_smart_proxies_smart_proxy_id_fk foreman
    pg_restore: [archiver (db)] could not execute query: ERROR: relation “public.features_smart_proxies” does not exist
    Command was: ALTER TABLE ONLY public.features_smart_proxies DROP CONSTRAINT features_smart_proxies_smart_proxy_id_fk;

pg_restore: [archiver (db)] Error from TOC entry 3811; 2606 17423 FK CONSTRAINT features_smart_proxies_feature_id_fk foreman
pg_restore: [archiver (db)] could not execute query: ERROR: relation “public.features_smart_proxies” does not exist
Command was: ALTER TABLE ONLY public.features_smart_proxies DROP CONSTRAINT features_smart_proxies_feature_id_fk;

Hello and welcome!

The database schema changes between different foreman versions. To get a 1.20 database on 1.23 you first need to restore it on a 1.20 install and upgrade that install all the way to 1.23 so that schema migrations are all executed.
Also note that 1.23.1 is expected in a few days and will include a fix to a couple of upgrade related issues (Bug #27854: upgrade to 1.21.3 fails with Validation failed: Provisioning templates is invalid - Foreman and Bug #28129: Parameters get converted from type string to boolean including the value - Foreman ) so you might want to wait for that release to come out before performing the upgrade.

Thanks @tbrisker
The import seems to have worked to 1.20.3 clean install.
I’ll hold off until 1.23.1 comes out before upgrading the full system.
Appreciate the reply.

Just writing back to you to let you know 1.23.1 is now available and you can start the upgrade process. It is recommended to go one version at a time, i.e. in your case 1.20.3->1.21.4->1.22.2->1.23.1. Also make sure to take note of the upgrade warnings for the various releases.