I want to push my local postgresql database to heroku, using heroku pg:push
command. The command looks like this: heroku pg:push mylocaldb DATABASE --app sushi
according to the heroku document: https://devcenter.heroku.com/articles/heroku-postgresql.
Here is my local database info:
Name: mysitedb
User: bill
Password: bill
The DATABASE_URL environment variable in my machine is set to: postgres://bill:bill@localhost/mysitedb
.
My app's name is secure-gorge-4090
. I tried heroku pg:push mysitedb DATABASE --app secure-gorge-4090
. The output was:
! Remote database is not empty.
! Please create a new database, or use `heroku pg:reset`
I was surprised that I have put nothing into my DATABASE. But I still ran heroku pg:reset DATABASE
to reset my DATABASE. After that, I tried heroku pg:push mysitedb DATABASE --app secure-gorge-4090
again but the output was still the same.
I tried heroku pg:push postgres://bill:bill@localhost:8000/mysitedb DATABASE --app secure-gorge-4090
. The output was:
! LOCAL_SOURCE_DATABASE is not a valid database name
I don't know how to use this command to move my local database to heroku. I need your help. Thanks!
I know this is a old discussion but I had the exact same problem. Though it's not quite as convenient, I managed to achieve this via pg:backups instead.
This is detailed pretty nicely on the heroku support site
Start by installing the free pgbackups addon:
Then backup the database using your local pg_dump utility (included in PostGreSQL distro)
Then put that dump file somewhere URL-addressible (e.g. Dropbox) and run the heroku import(make sure it's double quotes for Windows):
Are you actually typing in the token
DATABASE
in your commands, or is that a placeholder you're using for this question? From the docs you linked to:When you do
heroku config -a secure-gorge-4090
, you should see an entry forHEROKU_POSTGRESQL_[SOME COLOR NAME]
. Make sure you're using whatever that token is instead ofDATABASE
in your commands.Since you have a username and password on your local database, you also need to do the part mentioned about
PGUSER
andPGPASSWORD
. Here's the example from thepg:pull
docs:So you should do something like:
You need the following command
make sure that you have entered correct postgres username and password