Search code examples
djangodjango-south

how to change the order of south migrations


I have around fifty migrations in my store app, some of them are schemamigration and some datamigration. Now i want to run 0039_add_column_is_worldwide before 0037_some_values_to_objects. So I changed there name 0037_add_column_is_worldwide and 0039_some_values_to_objects.

It works fine when i did syncdb for new db but while migrating for a new migration in existing db it gives this error.

raise exceptions.InconsistentMigrationHistory(problems) south.exceptions.InconsistentMigrationHistory: Inconsistent migration history The following options are available: --merge: will just attempt the migration ignoring any potential dependency conflicts.

I didn't want to lose my data, so is there anyway to change the order of these migrations?


Solution

  • Migration are stored in DB when ran, so if you already applied these migrations south is going to get lost. Your alternatives:

    • flush the migration table (will cause all migration to run again if you call migrate)
    • rollback these migrations (before renaming)
    • fake these migrations (migrate --fake, but the numbers may conflict with the one in DB anyway)

    Rollback seems the safest to me, just be sure everybody in your project do the same.

    If you are still in dev and you have no prod database, you can always restart from zero:

    • flush the south db
    • migrate --fake