Friday, April 18, 2014

How to reverse both Django South migrations and source code?...

Django Users,

I'm having a problem reversing a Django South migration while also
reverting my source code to an an older version.  Any help?

Details:

My algorithm for doing a release is essentially:
1.  Update the source files
2.  % python manage.py migrate --all

This works great when moving forward.  Step 1 creates new migration
files.  Step 2 looks in the "south_migrationhistory" DB table to see
which migration files have not yet been run, and runs them.  Simple!

Not so great when moving backwards.  For example, when moving from
release 5 back to release 3.  Step 1 deletes the migration files for
releases 4 and 5, leaving only those for releases 1-3.  Step 2 looks
in the "south_migrationhistory" DB table, and decides to reverse
some of the migrations that have already been run, but the migration
files are already gone.  So it complains about GhostMigrations.

I have a few ideas about how to deal with this, but it must be a common
problem.  What do you folks do?

Thanks!
--Fred
Fred Stluka -- mailto:fred@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

No comments:

Post a Comment