Monday, November 5, 2012

Quick guide to using django South migrations

Using django django South migrations at a basic level is fairly easy (for wasn't really had to bang my head for a while until i decided to write this guide).

First make sure you install south and add to your apps in

"South is an intelligent schema and data migrations for Django projects." 

So after you have created your app and added some fields, you decided to add a new field.

First you have to make sure that your app is already converted to south, if not just run:

./ convert_to_south app
Then everytime you make a change in your models just:

./ schemamigration app --auto
./ migrate app

To undo the migration or change a field just

python migrate profiles 0025

 - Soft matched migration 0025 to 0025_auto__add_field_locumprofile_one_line_description.
Running migrations for profiles:
 - Migrating backwards to just after 0025_auto__add_field_locumprofile_one_line_description.
 < profiles:0026_auto__add_field_locumprofile_plc_accepted_terms

then delete the migration file 0026

change the model

Thats it,  simple!!