To fix a local Ambari/PostgreSQL upgrade:
Repair metadata information.
/var/lib/ambari-server/resources/upgrade/dml/Ambari-DML-Postgres-INSERT_METAINFO.sql with the following parameters: dbname = ambari metainfo_key = repo:/HDP/<version>/<os>/<repoid>:baseurl metainfo_value = <baseurl>
Run the fix script.
/var/lib/ambari-server/resources/upgrade/dml/Ambari-DML-Postgres-FIX_LOCAL_REPO.sql with the following parameters: dbname = ambari