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

怎甘沉沦 提交于 2020-01-17 01:41:08

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/31802911/why-there-is-no-migrations-detected-but-i-just-created-new-migrations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!