0

I am creating a Django app on Heroku. While I am testing it locally, finally I am checking by uploading everything to heroku and seeing if it works for real on the remote server as well

To quickstart, I went to the admin panel and created a bunch of data to run the view functions on. When I am pushing the source code to heroku via git (git push heroku master), I also want to push up the database from local to heroku, so that I dont need to enter it again on the server side

How do I achieve this?

Thanks a lot

dowjones123
  • 3,695
  • 5
  • 40
  • 83

1 Answers1

2

Grab your the postgres string from your Heroku database using heroku config:get

Look for the Heroku Postgres url (example: HEROKU_POSTGRESQL_RED_URL: postgres://user3123:passkja83kd8@ec2-117-21-174-214.compute-1.amazonaws.com:6212/db982398).

Next, run this on your command line:

pg_dump --host=<host_name> --port=<port> --username=<username> --password --dbname=<dbname> > output.sql The terminal will ask for your password then run it and dump it into output.sql.

Then import it:

psql -d <heroku postgres string> -f output.sql

Note: in each place where you see <.....> in the above code, be sure to substitute your specific information. Thus you would put your username where it says <username>, and your heroku database url where it says <heroku postgres string>.

Similar answer here.

Community
  • 1
  • 1
Alex
  • 8,321
  • 1
  • 34
  • 30