Created on Sept. 6, 2012, 12:37 p.m. by Hevok & updated by Hevok on May 2, 2013, 5:26 p.m.

South enables schema and data migration of a django-backend database []. Migrations should be version-controlled [].

Adding South

In order to add South to Django project, development & production do the following []: :: $ ./ snycdb $ ./ convert_to_south myproject.myapp $ ./ schemamigration myproject.myapp --auto # Change models $ ./ migrate myproject.myapp # Alternatively to get a fresh Django database with existing South migrations

sync all tables and perform fake migration []: :: $ ./ syncdb --all $ ./ migrate --fake

If required south can be resetted [;!topic/south-users/PxEskcnkibc[1-25];!msg/south-users/iIQT8ZWs2cI/GQ4kONoT5Q4J[1-25.


South's DB Content reflects the state of the DB, while migration files reflect the state of the source code.

The schemamigration --auto commadn created migration files from the, but it is possible to tweak them if necessary. If they were tweaked then the changes need to be saved somewhere.

The migrate command compares migration files with DB Content. Thus if mgration files are moved with the source code to the serer, where there are previous souht DB Content it will apply precisley all the migrations needed to bring the DB in sync with the source code.

Migrate through the history

To go back in forward in the south migration history simply define the migration to move: ::

$ ./ migrate <appname> 0005

Renaming a Django App

South allows to rename a django app, through some manual steps are required [].

A step-by-step example of renaming django app, managed by South migration history is described here:

Moving a Model from one App to another

Moving models between apps is straightforward

$ ./ schemamigration specific create_cat --auto
$ ./ schemamigraiion common drop_cat --auto

Listing Migrations

To list all migrations without actually running them execute this: ::

./ migrate --list

Tags: tutorial, schema migration, database
Parent: Web Framework

Update entry (Admin) | See changes

Comment on This Data Unit