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.
Utility functions for common tasks
Find reverse upgrades that must be run before final_target is installed
final_target – final target of the installation relative_path – path from final target to Django/South migrations
returns ID/number of the migration to run (if any)