4

I've just started using Heroku with Django and it seems great. However, when I change my existing models I'm not sure how to run those changes to the Heroku environment. The syncdb works just fine when adding all new database tables, but how should I modify existing tables?

I found out that Heroku provides psql access only to a dedicated database so that's out of the question. I haven't tried South but it seems like a solution.

So I guess I'm asking how to make database changes with Django and Heroku?

2 Answers 2

3

What you are asking for is called "schema migration" or even "schema evolution". Django has some documentation about it on the wiki.

Django's syncdb command does not support that. As a matter of fact, the documentation for syncdb is clear:

Creates the database tables for all apps in INSTALLED_APPS whose tables have not already been created

Rather, django proposes to use drop the tables manually and then to run syncdb again in the documentation of the deprecated reset command:

You can also use ALTER TABLE or DROP TABLE statements manually.

But fear not, there are many reusable apps to help you with proper schema migrations and hopefully you can pick the one that suits you best. Rather than elaborate in my answer, please let me link an article I wrote about Django schema migration which compares all current solutions.

Sign up to request clarification or add additional context in comments.

3 Comments

Yeah, the Django's syncdb helps you only to a certain point. But Nashvegas looks really promising! I like the idea of having both SQL and Python available for making the migration scripts. Let's just hope it works well with Heroku, as it probably should. Good enough as an answer, thanks @jpic!
@Janne You might also want to manually change the models using python mange.py inspectdb > models.py. Just make sure you're not in your models.py directory or it will be overwritten.
I had forgotten all about the inspectdb. In some cases it could be very useful. Thanks Edwin for reminding me about it.
0

South works great on Heroku.

2 Comments

Glad to see you read the poster's question, which mentions it.
I'm not sure if this was sarcasm or not... He said South seemed like a solution and I was just verifying that it works great on Heroku.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.