使用--fake后,如何重做django 1.8上的迁移 [英] How to redo a migration on django 1.8 after using --fake

查看:674
本文介绍了使用--fake后,如何重做django 1.8上的迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的迁移出了问题,我向模型添加了一个新的datetime域,然后我使用makemigrations和迁移。

Something went wrong on my migrations, I added a new datetimefield to a model then I used makemigrations and migrate.

python manage.py makemigrations
python manage.py migrate

但是之后,迁移得到了一个表已存在错误。我想我可以伪造这些迁移并重新开始,所以我做了一个

But after this the migrate got an "table already exists error". I supposed I could fake the migrations and start over, so I did

python manage.py makemigrations --fake core

Operations to perform:
  Apply all migrations: core
Running migrations:
  Rendering model states... DONE
  Applying core.0001_initial... FAKED
  Applying core.0002_auto_20150525_1331... FAKED
  Applying core.0003_auto_20150525_1348... FAKED
  Applying core.0004_processo_data_atualizacao... FAKED

但是我刚刚创建的新迁移也是伪造的(当然!)。

but the new migrate that I've just created was faked too (of course!).

在这样做之后,正确的方法可以重做迁移(在这种情况下是core.0004)?

How is the proper way to redo a migration (in this case the core.0004) after doing this?

推荐答案

状态到0003与 - 假的/ / code>(假设0003是你真正应用的最后一个迁移):

You should first set your current state to 0003 with --fake (assuming 0003 is the last migration you really have applied):

python manage.py migrate --fake core 0003

然后继续像往常一样:

python manage.py migrate core

相关文档: https:// docs。 djangoproject.com/en/dev/ref/django-admin/#migrate

这篇关于使用--fake后,如何重做django 1.8上的迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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