Django 1.8运行特定的迁移 [英] Django 1.8 Run a specific migration
本文介绍了Django 1.8运行特定的迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在django 1.8中,有一种方法可以运行特定的迁移,并且仅运行该迁移。
In django 1.8 is there a way to run a specific migration and that migration only.
不仅适用于一个应用程序,还适用于该应用程序迁移目录中的特定文件。
Not for one app only but a specific file in that apps migrations directory.
原始编辑:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/vagrant/virtualenvs/aku/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/vagrant/virtualenvs/aku/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/vagrant/virtualenvs/aku/lib/python3.4/site-packages/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/vagrant/virtualenvs/aku/lib/python3.4/site-packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/home/vagrant/virtualenvs/aku/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 146, in handle
plan = executor.migration_plan(targets)
File "/home/vagrant/virtualenvs/aku/lib/python3.4/site-packages/django/db/migrations/executor.py", line 50, in migration_plan
self.loader.graph.node_map[target].children
KeyError: ('wagtailcore', '0001_initial')
稍作搜索并找到此 https://code.djangoproject.com/ticket/24225#no1
推荐答案
您可以告诉Django进行特定迁移
You can tell Django to move to a specific migration
./manage.py migrate myapp 0005_migration_to_run
但是Django会每次迁移运行(或返回)您进行的迁移
But Django will run every migration up to (or back to) the migration you've chosen.
您可以尝试伪造 ,先迁移
You could try faking to the migration before
./manage.py migrate --fake myapp 0004_previous_migration
./manage.py migrate myapp 0005_migration_to_run
然后,您可能想要伪造您开始的迁移。
You might then want to fake to the migration you started at.
这篇关于Django 1.8运行特定的迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文