I’m attempting to migrate a Rails app from Heroku, and I’ve followed the instructions without any issues up to the section about database migration. I ran the command laid out from the guide:
pg_dump: option requires an argument -- d
Try "pg_dump --help" for more information.
psql: option requires an argument -- d
Try "psql --help" for more information.
I have tried replacing the two variables with the actual database URL’s, but the $DATABASE_URL is an internal address, which makes me think I’m missing something.
Am I supposed to run the command from within my VM? Hope someone can help
Update: I attempted to run the command from within the app container with fly ssh console but got the following error:
$ pg_dump --no-owner -C -d $HEROKU_DATABASE_URL | psql -d $DATABASE_URL
pg_dump: server version: 14.4 (Ubuntu 14.4-1.pgdg20.04+1); pg_dump version: 11.17 (Debian 11.17-0+deb10u1)
pg_dump: aborting because of server version mismatch
This downloads the database to your project folder. Uploading to fly.io is another story and in fact that is what I’m trying to figure out.
I hadn’t read those instructions when I first posted, but it makes some sense to download and upload rather than trying to do in one step. When I deploy I’m getting errors about a database table not being seen, but I’ve got the rails app running in localhost also. It seems the fly deploy uploads the database too. I just started with this yesterday, so haven’t gotten very far and will separately post if I can’t figure it out.
Thank you so much @tj1 for leading me on the way. Here is a precise breakdown of what I did for it to work, with a lot of repetition from @tj1 's advice:
@tj1@dornby
Thanks for the guidance of the two masters
I also succeeded
But I have a new problem.
I use “pgadmin” or “tableplus” software to connect postgresql db.
An error occurs:
could not translate host name “dbname-db.internal” to address: nodename nor servname provided, or not known.
“host name” I have tried the following but failed:
top2.nearest.of.dbname-db.internal
dbname-db.internal
I have closed the fly proxy and connected again, but the same error occurs.
If I turn on fly proxy and use localhost:15432 to connect,
Can connect to db, but not production db.
I’m a beginner and would appreciate some guidance.
I have enabled “fly proxy”.
Follow your instructions to connect,
It can be successfully connected.
I tried to change the data in the db in TablePlus and save it,
Then “puts db data” on the Internet,
But it shows the old data (maintain the data of the original heroku db)
Obviously the data I changed in TablePlus was not updated synchronously,
Or what action is required to upload the database?
Also for anyone else following along here, you’ll need to add your heroku app name to that command DATABASE_URL=$(heroku config:get DATABASE_URL -a your-heroku-app-name).