Search code examples
djangopython-3.xdjango-migrations

Django migrations: what `elidable` argument is for?


I have RunPython operations in my migrations, for example one of the migrations:

class DataMigration(migrations.Migration):
    dependencies = [('app1', '0001_initial')]

    operations = [
        migrations.RunPython(create_data, delete_data, elidable=True),
    ]

This operation accpets an optional elidable argument, which is described in the Django docs:

The optional elidable argument determines whether or not the operation will be removed (elided) when squashing migrations.

This description is a little bit confusing for me. My question is: what happens, when migrations with elidable=True flag are squashed?

I guess that migrations with elidable=True would be simply deleted. And some manual steps would have to be taken in order to add the logic of elided migrations into the squashed one.


Solution

  • The documentation for Squashing Migrations says

    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.

    So there should not be any need for 'manual steps' as the resulting migrations will have the same effect as they did before squashing.