South is “a tool to provide consistent, easy-to-use and database-agnostic migrations for Django applications.” However, as South’s website says, since Django 1.7 now has its own migrations tool South has been deprecated. I personally think the new Django migrations are a little bit better.
However we still use South at FiveStars and I thought other people who still use South might appreciate these notes.
See list of migrations (asterisks means already applied)
$ ./manage.py migrate --list [app name]
Apply latest migrations
$ ./manage.py migrate [app name]
Fake migration
$ ./manage.py migrate [app name] [version #] --fake
Migrate backwards
$ ./manage.py migrate [app name] [version #]
Migrate back to zero state, i.e. nothing
$ ./manage.py migrate [app name] zero
Create first migration
$ ./manage.py schemamigration [app name] --initial
Create subsequent migrations
$ ./manage.py schemamigration [app name] —-auto
Create empty schema migration
$ ./manage.py schemamigration [app name] —-empty [migration name]
Create data migration
$ ./manage.py datamigration [app name] [migration name]
Review migration history
select * from south_migrationhistory order by applied;
Redo migrations that have been hand edited
Sometimes you will find someone followed the bad practice of hand editing a migration after it has been committed. For example they’ll add another column. Because you have already run the migration you may not notice this until many migrations later when something breaks because of this missing column.
To fix this:
- Fake migration backwards to the edited migration
- Migrate back one before the edited migration
- Migrate forward one for the edited migration
- Fake migrate forwards the rest until you get to your current state
- Migrate the migration that previously was giving problems