Python 如何从 Django 1.7 中的初始迁移迁移回来?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25606879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 23:22:22  来源:igfitidea点击:

How to migrate back from initial migration in Django 1.7?

pythondjangodjango-1.7django-migrations

提问by Seppo Ervi?l?

I created a new app with some models and now I noticed that some of the models are poorly thought out. As I haven't committed the code the sensible thing would be to migrate the database to last good state and redo the migration with better models. In this case the last good state is database where the new app doesn't exist.

我用一些模型创建了一个新应用程序,现在我注意到有些模型没有经过深思熟虑。由于我还没有提交代码,明智的做法是将数据库迁移到最后的良好状态并使用更好的模型重做迁移。在这种情况下,最后一个好的状态是新应用程序不存在的数据库。

How can I migrate back from initial migration in Django 1.7?

如何从 Django 1.7 中的初始迁移迁移回来?

In Southone could do:

South一个可以做:

python manage.py migrate <app> zero

Which would clear <app>from migration history and drop all tables of <app>.

<app>将从迁移历史中清除并删除<app>.

How to do this with Django 1.7 migrations?

如何使用 Django 1.7 迁移来做到这一点?

采纳答案by ChillarAnand

You can do the same with Django 1.7+ also:

你也可以用 Django 1.7+ 做同样的事情:

python manage.py migrate <app> zero

This clears <app>from migration history and drops all tables of <app>

<app>将从迁移历史中清除并删除所有表<app>

See django docsfor more info.

有关更多信息,请参阅django 文档

回答by jsh

you can also use the version number:

您还可以使用版本号:

python manage.py migrate <app> 0002

Source: https://docs.djangoproject.com/en/1.7/ref/django-admin/#django-admin-migrate

来源:https: //docs.djangoproject.com/en/1.7/ref/django-admin/#django-admin-migrate