Hi there, djangonauts!
I have a simple idea in mind that I want to discuss. As a preface would like to say that, in my opinion, zero-downtime migrations are almost impossible to support in universal way. For any realistic implementation, these migrations will be a mix of manually written python and sql.
Let’s use a simplified model: that any migration can be split into:
- non-destructive part, that can be rolled upon a running system right away
- destructive part that remains pending until all the deployment is finished
For example, deleting a field is completely a destructive operation:
operations = []
pending_ops = [
migrations.DeleteFieldl("Issue", "source"),
]
To apply the desired pending migrations one would use an API: /migrations/apply?no=001
Or, even better, we can have a page for this in the django admin that lists all pending migrations and where you can apply them. When a pending migration is applied, it saves this fact to the database.
One also can add pending_ops to an already applied migrations, by modifying the migration source.
Of course, when migrations are applied for an empty database (for example, in tests), pending_ops should be applied right after regular operations.
Tagging @charettes as the specialist in the field ![]()
And the others @KenWhitesell @carltongibson @andrewgodwin