我的迁移中有 RunPython
操作,例如其中一个迁移:
class DataMigration(migrations.Migration):
dependencies = [('app1', '0001_initial')]
operations = [
migrations.RunPython(create_data, delete_data, elidable=True),
]
此操作接受一个可选的elidable
参数,这在the Django docs 中有描述。 :
The optional elidable argument determines whether or not the operation will be removed (elided) when squashing migrations.
这个描述让我有点困惑。我的问题是:当带有 elidable=True
标志的迁移被压缩时会发生什么?
我想带有 elidable=True
的迁移会被简单地删除。并且必须采取一些手动步骤才能将省略的迁移逻辑添加到压缩的迁移中。
最佳答案
Squashing Migrations 的文档说
Squashing is the act of reducing an existing set of many migrations down to one (or sometimes a few) migrations which still represent the same changes.
因此不需要任何“手动步骤”,因为生成的迁移将具有与压缩前相同的效果。
关于Django 迁移 : what `elidable` argument is for?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57608192/