Probably not a solution because it didn't fully work for me, but possibly a place to start.
Rather than use pg:copy
, I tried to break it into a few steps.
First, I did a dump from the source database:
pg_dump -O -f dumpfile.sql $(heroku config:get DATABASE_URL -a <my-app>
Next, I manually edited the file. I changed:
CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA public;
to
CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA heroku_ext;
and I replaced any references to public.citext
with heroku_ext.citext
.
Last, I loaded the edited dump file:
psql $(heroku config:get HEROKU_POSTGRESQL_COLOR_URL -a <my-app>) < dumpfile.sql
It didn't fail in the same way as pg:copy
but there were other errors that prevented my app from running properly. I haven't yet had the chance to dig deeper.
Update: Heroku support suggested this workaround to me that is somewhat similar but I've not had a chance to try it yet:
The best path forward is going to be moving those extensions into the heroku_ext schema.
To fix the pg:copy
upgrade method, you will need to correct the source system to be in the heroku_ext. To do this you will want to capture a backup, modify the backup file and restore using the modified backup file.
Because of the uniqueness around each customers' database, we are not able to automate these steps behind the scenes.
Steps for doing so
- Download Your Backup https://devcenter.heroku.com/articles/heroku-postgres-backups#downloading-your-backups
- Convert dump file to .sql file
pg_restore -f <output-file-name> <input-file-name>
- Modify the CREATE EXTENSION commands to use WITH SCHEMA heroku_ext. You may need to modify the dependencies suggested above.
- Restore the backup using pg_restore
- Take a new backup pg:backup:capture on the corrected database so the next restore comes from a corrected