#23610: Removing a null constraint can lead to race conditions with migrations
-------------------------------------+-------------------------------------
Reporter: Josh Smeaton | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.7
Severity: Normal | Resolution: wontfix
Keywords: migrations | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
FWIW I've been working on a third-party application that resolves this
problem by introducing a concept of pre- and post-deployment migrations.
We've been using it in production for a few months now.
It has a built-in notion of quorum which allows the following sequence of
operation to be taken across multiple instances (e.g. multiple k8s
clusters)
1. Run the `migrate --pre-deploy` command to alter the column to have it
`NULL SET DEFAULT 42`
2. Wait for the N clusters to have completed their application rollout
3. Run the `migrate` command to have it `NOT NULL` and `DROP DEFAULT`
I created [https://github.com/charettes/django-syzygy/issues/24 an issue]
to add support for this particular case as null constraint removal is not
explicitly tested but it should only be matter of adjusting the auto-
detector to have a `IntegerField(null=True) -> IntegerField(default=42)`
change generate an extra `PreAlterField` operation meant to run on
`migrate --pre-deploy`.
--
Ticket URL: <https://code.djangoproject.com/ticket/23610#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.235b6996f06b4f2003bc00a640eafa70%40djangoproject.com.