Sunday, November 22, 2009

South for Django, or how to keep database up to date

South is a migration tool for Django.

There two ways to install South: system-wide or per-project. I choose the second way because I always know that it's works with the project.

  1. Get from repository.
    hg clone http://bitbucket.org/andrewgodwin/south/
    hg update -C 0.6.2 #this is stable version now
            
  2. copy south dir to project
  3. Add it to INSTALLED_APPS
  4. In order to create all system models
    ./manage syncdb 
            
  5. Further you should create necessary apps and its models (don't forget to add them to INSTALLED_APPS)
  6. To create initial migration for an application run this command
    ./manage.py startmigration <app name> --initial
            
  7. After you changed the model
    ./manage.py startmigration <app name>
            
    to create migration
  8. To migrate to current database state
    ./manage.py migrate [app]
            

These are the most often operations. More detailed info you get in official documentation.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.