Django迁移中的--fake-initial
和--fake
有什么区别?使用假迁移有什么危险?有人知道吗非常感谢大家。
我正在使用Django 1.10
最佳答案
好吧,文档对此很清楚
--fake-initial
Allows Django to skip an app’s initial migration if all database tables with the names of all models created by all CreateModel operations in that migration already exist. This option is intended for use when first running migrations against a database that preexisted the use of migrations. This option does not, however, check for matching database schema beyond matching table names
您是在问风险,好在这里
only safe to use if you are confident that your existing schema matches what is recorded in your initial migration.
- 假
Tells Django to mark the migrations as having been applied or unapplied, but without actually running the SQL to change your database schema.
This is intended for advanced users to manipulate the current migration state directly if they’re manually applying changes;
风险再次清晰地突出显示
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.
这个答案不仅对Django 1.8+版本有效,对其他版本也有效。
编辑2018年11月:有时我在这里和其他地方看到答案,建议您删除数据仓库。那几乎从来都不是正确的事情。如果删除数据库,则会丢失所有数据。
关于django - --fake-initial与--fake在Django迁移中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42695629/