South Rollbacks =============== .. note:: fussy-southrollback should likely be considered a proof-of-concept or a bit of sample code. Your own migrations will likely require system specific modifications that would make using this script as-is an unreasonable choice. If your firmware uses the South migration mechanism for Django, then you will likely need to be able to support running reverse migrations when the customer installs an older firmware. Because of how the migrations are stored, you will need to run the rollback migrations while the *old* firmware is installed. You can support this by adding a call to fussy-southrollback to your ``.pre-install`` script. It will: * scan the relative path (-p argument) for migrations * do a textual compare on the sorted lists of migrations * find the set of identical items * IFF the new migrations are *not* a superset of the current migrations * will perform a django-admin.py migrate --noinput app migration * where migration is the last common migration among the pair of migrations .. note:: You *must* not rename a migration if you are using this code. .. code-block::bash $ export DJANGO_SETTINGS_MODULE=myfirmware.settings $ source /opt/firmware/current/env/bin/activate $ fussy-southrollback --final_target=/opt/firmware/2012-04-14T20.38.23 \ -d django-admin.py -p lib/python2.7/site-packages/myfirmware/myapp/migrations \ -a myapp Module: fussy.southrollback --------------------------- .. automodule:: fussy.southrollback :members: