为什么没有检测到迁移,但是我只是创建了新迁移? [英] Why there is no migrations detected but I just created new migrations?

查看:108
本文介绍了为什么没有检测到迁移,但是我只是创建了新迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的工作流程,通过 makemigrations migration ,一切看起来都很好。但是,我想从模型开始,所以我:

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 django应用程序目录中的所有迁移文件;

  2. 删除数据库中的所有相关表;

  3. makemigrations生成新的迁移文件;

但是当我想将其迁移到数据库中时,会说没有要应用的迁移。我认为迁移背后的机制是模型->迁移->数据库更改,如果我删除后两个,它应该再次遍历。

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

Django == 1.8.2

已关闭是名为 django-migrations 的表,该表跟踪所有更改并删除相关记录,然后进行迁移。

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!

推荐答案

还有另一个表django_migrations可以跟踪每个应用程序已运行的迁移。您必须将其重置,以便django知道您已经重新开始。

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 migration< app> --fake zero

这篇关于为什么没有检测到迁移,但是我只是创建了新迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆