'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 1:[1]
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.
Solution 2:[2]
Short Answer
You're right!
The only thing done when squashing an elidable manual migration is just deletion. i.e. such migrations are simply ignored in the process of squashing.
Long Answer
Actually, the idiom squashing is generally referred to as a group of tasks done in order to compress/lighten a series of objects into a lighter one; deletion is just one member of this group.
In the Git ecosystem, for example, squashing is referred to as making a fresh light commit out of a set of consecutive commits, perhaps through deleting some and merging the others.
But in your case, the only task that is suitable for an elidable manual migration is deletion, surprisingly. So here squashing is just a more general/standard word in place of deletion. i.e. squashing an elidable manual migration is simply deleting it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tony |
| Solution 2 | Emran BatmanGhelich |
