Anoop
Anoop

Reputation: 1435

How to update schema changes to heroku django app?

I have deployed one django app in heroku. Everything is working fine now. But I need to add one more field in to the existing table. I added schema changes to the models.py file. I tried the following command for enter in to the dbshell.

    heroku run python manage.py dbshell

but it shows the following error message.

Error: You appear not to have the 'psql' program installed or on your path.

How can I solve this issue?? How can I add the changes in to the database?? please help me.

Upvotes: 0

Views: 1815

Answers (3)

itsme
itsme

Reputation: 140

Use heroku pg:psql instead of manage.py dbshell..

Upvotes: 2

jennystanchak
jennystanchak

Reputation: 199

I had this same problem, and also found a clear answer lacking in the docs. As Heroku recommends, your production database should be the same as your development database, so you should be able to make all your changes locally.

To fix:

  1. Download the newest Postgress app, and follow the instructions to move it to the Applications folder

  2. Add the new bundle to your path by typing the following in your Terminal: PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH"

  3. Go back into your virtual environment and run python manage.py dbshell - you should be good!

Upvotes: 0

GordonsBeard
GordonsBeard

Reputation: 646

I am not 100% certain about heroku (read: I don't know about it) but the problem you're having sounds pretty typical: you want to modify a django database after it's been set. A little key note about syncdb: it will not alter existing tables.

In order to modify a table you're going to have to dump all the data, edit the model, and then fill in all that data again - what a pain!

There are however, other options:

The two more popular options are django-evolution and South, both have their own uses, pros/cons, and complexities. Rather than bore you (and steal someone else's hard work in the process) with the details of both, I'll just pass along a helpful question from SO:

Currently using Django "Evolution", is "South" better and worth switching?

(the short answer is going to be: use South. It's got a bit of a learning curve but it really will be the most robust/complete solution for changing django models (or migrating) after they've been set.

Upvotes: 1

Related Questions