Django 迁移 : what `elidable` argument is for?

标签 django python-3.x django-migrations

我的迁移中有 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/

相关文章:

python - 什么类型错误,__init__() 缺少 1 个必需的位置参数 : 'get_response' mean in python?

css - Django 不在 css 中显示图像

python - django.db.utils.IntegrityError : duplicate key value violates unique constraint "auth_permission_pkey" 错误

python - Celery 处理任务并修改模型字段

django - Celery 任务在从大型数据库中提取数据时中途失败

python - 如何将 Python 3 与 Google App Engine 本地开发服务器一起使用

python - 当级别设置为logging.DEBUG时,为什么log.debug()不记录日志?

python - 有没有办法在解包时将 splat-assign 分配为元组而不是列表?

python - django.db.utils.ProgrammingError : cannot cast type integer to date

django - 在 django 1.7+ 中,south.signals.ran_migration 的等价物是什么?