How to simplify migrations in Django 1.7?

Kit Fisto picture Kit Fisto · May 20, 2014 · Viewed 93.1k times · Source

There are already similar questions for South, but I have started my project with Django 1.7 and am not using South.

During development a lot of migrations have been created, however the software is not yet delievered and there exists no database that must be migrated. Therefore I would like to reset the migrations as if my current model was the original one and recreate all databases.

What is the recommended way to do that?

EDIT: As of Django 1.8 there is a new command named squashmigrations which more or less solves the problem described here.

Answer

kzorro picture kzorro · Nov 19, 2014

I got this. I just figured this out and it is good.

  • First, to clear migrations table:

    ./manage.py migrate --fake <app-name> zero
    
  • Remove app-name/migrations/ folder or contents.

  • Make the migrations:

    ./manage.py makemigrations <app-name>
    
  • Finally tidy up your migrations without making other database changes:

    ./manage.py migrate --fake <app-name>