Search code examples
databasedjangodjango-south

Consolidating Django South Migrations


In the initial stages of my project I'm making a lot of changes to the models and thus I've ended up with a lot of south migrations being generated for my apps. Is it possible to consolidate them in any way before going to my production server to perform the migrations so I don't have like a million migrations for each app? And if so, how would I go about doing that?


Solution

  • You could always delete the existing migrations and create a new "initial" migration.

    To do this, you will need to:

    1. Remove the migration files for you app (remove the folder altogether)
    2. Run ./manage.py convert_to_south myapp

    This will leave you with a single migration corresponding to your app's state current state.


    Alternatively, you can always pack your latest migrations together:

    1. Remove the migration files that you want to merge (only if they are the latest onces)
    2. Run ./manage.py schemamigration myapp

    This will create a new migration that will correspond to the migrations you removed.


    Both of these will likely mess up your development DB.