Help migrating postgres from heroku rails app

I ran through this today and am at a point where there’s a few things I can share in this thread that might be useful. That said, I think I still have some more work to do in terms of documenting how to match the versions of Fly’s PG server to Heroku’s (both can change).

Note that I’m using the docs from Migrate from Heroku · Fly Docs (not Migrating from Heroku Postgres to Fly Postgres: A Complete Guide)

Migration command

I changed the migration to command to better match Heroku’s recommendations. The new command you should try running from the fly ssh console is:

pg_dump -Fc --no-acl --no-owner -d $HEROKU_DATABASE_URL | pg_restore --verbose --clean --no-acl --no-owner -d $DATABASE_URL

I don’t know if that will solve the version mismatch problem, but maybe? I found this command to be more reliable in terms of moving the data from Heroku into my Fly DB.

Matching versions

If your Heroku instance is running a really old version of PG, you might need to upgrade it to match Fly’s version. Docs at Upgrading the Version of a Heroku Postgres Database | Heroku Dev Center.

Fly launches v14 of Postgres via Fly Postgres · Fly Docs. In theory an older version of pg can be run as an app via a Dockerfile, but it would be more manual.

I still need to do more research on this topic since I’m not very familiar with it myself. Please chime in if you know more about dealing with pg version compatibility for dumps & restores!