澄清django syncdb --all选项 [英] Clarification on django syncdb --all option
问题描述
我正在尝试了解什么是 ./ manage.py syncdb --all
?我最近有一个数据库问题,我可以通过运行这个命令来修复,但我不完全确定它在幕后做了什么。我明白syncdb为没有迁移到南方的已安装应用程序创建表,而忽略了南移动控制的那些应用程序的表,除非指定了--all选项,但是我被实际发生的情况和何时使用而感到困惑它。我无法在 django-admin docs 而手册页只对这个选项说了这个。 - 所有使syncdb适用于所有应用程序,甚至可以迁移到所有应用程序上。
I am trying to understand what exactly ./manage.py syncdb --all
does? I recently had a database issue that I was able to fix by running this command but I am not exactly sure what it does behind the scenes. I understand that syncdb creates the tables for the installed apps that aren't being migrated with south and that those that are under south migration control are overlooked unless the --all option is specified but I am confused by what actually happens and when to use it. I am unable to find anything about the option on the django-admin docs and the man pages only say this about the option.
--all Makes syncdb work on all apps, even migrated ones. Be
careful!
为什么我需要小心?这究竟在做什么?是完全删除数据库并重新开始,我认为这将导致我丢失数据库中存储的所有数据(对吗?),还是在这里发生的其他事情?我正在使用Django 1.6,如果这有所作为。
Why do I need to be careful? What exactly is this doing? Is it completely deleting the database and starting over, which I assume would cause me to lose all of my data stored in the database (right?), or is something else happening here? I am using Django 1.6 if that makes a difference.
推荐答案
当您安装南方时,它会用自己的Django替代Django的syncdb命令。它是 syncdb的南方版本,它具有 - all
选项,但不推荐:
When you install south, it replaces Django's syncdb command with its own. It is the south version of syncdb that has the --all
option, but its not recommended:
如果要在所有应用程序上运行syncdb,请使用
- all
,但要警告;这将使您的数据库模式和迁移失去同步。如果这样做,您可能可以通过以下方式进行修复:
If you want to run syncdb on all of the apps, then use
--all
, but be warned; this will put your database schema and migrations out of sync. If you do this, you might be able to fix it with:
syncdb命令不会删除表。您需要小心,因为您不希望数据库模式和迁移失去同步。
The syncdb command never deletes tables. You need to be careful because you don't want the database schema and migrations to get out of sync.
这篇关于澄清django syncdb --all选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!