撤消或重置django中的伪造迁移

撤消或重置django中的伪造迁移

本文介绍了撤消或重置django中的伪造迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的基于django-1.8.2的项目中,我遇到了一些迁移问题,所以我运行命令

  python manage.py migrate --fake 

但是它伪造了这个命令所需的所有迁移。但现在, python manage.py migrate 命令没有做或应用任何迁移。我想撤销伪造的迁移,以便我可以将迁移应用到数据库。我想将现有的迁移应用到数据库。

解决方案

对于每个应用程序,您可以将迁移回到他们所在的位置在你伪造他们之前。

  python manage.py migrate --fake myapp 00XX_last_migration 

其中 00XX_last_migration 是您实际为您的应用程序运行的最后一次迁移 MyApp的



或者,如果您还没有实际运行该应用的迁移:

 code> python manage.py migrate  -  fake myapp zero 


In my project which is based on django-1.8.2 I was facing some problems with migrations so i ran command

python manage.py migrate --fake

But it faked all the migrations which this command is meant for. But now python manage.py migrate command is not doing or applying any migration. I want to undo the faked migrations so that I can apply the migrations to database. I want to apply the existing migrations to the database.

解决方案

For each app, you can fake the migrations back to where they were before you faked them.

python manage.py migrate --fake myapp 00XX_last_migration

where 00XX_last_migration is the last migration that you actually ran for your app myapp.

Or, if you haven't actually run any migrations for that app yet:

python manage.py migrate --fake myapp zero

这篇关于撤消或重置django中的伪造迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 05:06