Undo or reset the faked migrations in django

巧了我就是萌 提交于 2020-01-01 10:09:46

问题


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.


回答1:


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



回答2:


From the docs:

be warned that using --fake runs the risk of putting the migration state table into a state where manual recovery will be needed to make migrations run correctly.

So I suggest you to simply remove faked migrations from django_migrations table.



来源:https://stackoverflow.com/questions/31731211/undo-or-reset-the-faked-migrations-in-django

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