Search code examples
djangodata-migration

Why there is no migrations detected but I just created new migrations?


This is my workflow, everything seems nice and tidy with makemigrations and migrate. However, I want to start over with my models, so I:

  1. rm -rf all the migrations file in the django app directory;
  2. drop all the related tables in the database;
  3. makemigrations results in new migration files;

But when I want to migrate it into database, it is said No migrations to apply. I think the mechanism behind migrations is that models -> migrations -> database changes, if I drop the latter two it should go over again. Unfortunately it is not.

Django == 1.8.2

CLOSED There is a table called django-migrations tracking all the changes and delete related records and then I could make migrations. Thx to those who helped!


Solution

  • There's another table that keeps track of which migrations have been ran for each app, django_migrations. You'll have to reset that in order for django to know you have started over.

    if you changed the database already then try running

    python manage.py migrate <app> --fake zero