Django 1.8 migrating data from local database to heroku database

267 views Asked by At

I first tried using heroku addons:add pgbackups but heroku docs say that it has been deprecated. The instead recommended using this command as specified here

PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser  mydb > mydb.dump

But this throws the following error-

'PGPASSWORD' is not recognized as an internal or external command,
 operable program or batch file.

I have already existing data on my local database and want to transfer those data into the heroku database. Any way to make this work or is there some other way?

1

There are 1 answers

2
cameron-f On

You could try fixtures

To create the JSON file from your local database:

python manage.py dumpdata > a_fixture_file.json

Take that file to the server. Be sure your server database has the same migrations. Then

python manage.py loaddata a_fixture_file.json