Due to this change by heroku, I am not able to restore my Heroku Postgres backup.
Following errors are thrown while restoring:
pg_restore: error: could not execute query: ERROR: extension "pg_stat_statements" must be installed in schema "heroku_ext" Command was: CREATE EXTENSION IF NOT EXISTS "pg_stat_statements" WITH SCHEMA "public"; pg_restore: error: could not execute query: ERROR: extension "pg_stat_statements" does not exist Command was: COMMENT ON EXTENSION "pg_stat_statements" IS 'track planning and execution statistics of all SQL statements executed'; Command was: CREATE EXTENSION IF NOT EXISTS "postgis" WITH SCHEMA "public";
Any many such errors.
I contacted Heroku support, and they have provided the following step to try fix the issue manually.
Here are the steps in detail:
- Download a backup of your database.
- Convert the dump file to a .sql file with: pg_restore -f
- Modify the CREATE EXTENSION commands to use CREATE EXTENSION IF NOT EXISTS extension_name WITH SCHEMA heroku_ext. You can do this by using sed or a text editor of your choice.
- Restore the backup using pg_restore to Heroku Postgres from your app. The extensions in your production database will now be owned by the correct schema; future migrations, backups, and restores should proceed without needing to repeat this process.
I have modified the .sql file as per step3, but I am not able to figure hot how to convert this .sql file to a .dump file to be restored on the Heroku app.
I have tried heroku pg:psql --app <app> <sql_file> but it does not work and throws errors.
Can someone help me in importing this .sql file to Heroku?