#26064: Move migration operation reduction logic to their respective class.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: charettes
Type: | Status: assigned
Cleanup/optimization |
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by shaib):
That looks very interesting, but has some issues that need working out.
The first is -- it seems obvious that the operation needs to be defined
out of the migration files. But intuitively, this is an operation that is
"only serving one migration" -- the idea that it would serve in a
different migration after a squashing operation will not be on anyone's
mind when it is written. As things are presented, I suspect it would be
hard to explain why you'd want to write the code of your data migration in
an operation class rather than a migration file.
The second (a problem we already have today, but perhaps this gives us an
opportunity to solve it) is interaction between user operations. If we go
this way, users will want to be able to handle these -- consider the
migration which adds the population to each country; our user will want to
replace the two (creation and add-population) by one operation, which
creates the countries with their population. But for that to make sense
(with the admonition not to change migrations which have already been
applied), the reduction rules cannot be defined on the earlier migration
-- they need to be defined either on the later one, or outside of both.
More generally -- I've seen data-creation migrations which have been much
more elaborate, creating complex structures with relations between models
etc. I suspect we won't be able to ask users to write such migrations with
all model and field names passed in as arguments and used via reflection.
Still, it may be possible to get from a "normal" `RunPython` function to
one closer in spirit to your `CreateInitialCountries` operation by more-
or-less automatic means (AST transformations).
So, there's a lot of promise here, but also a lot of work and thinking to
do.
--
Ticket URL: <https://code.djangoproject.com/ticket/26064#comment:3>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.5f4a9de98fe83fc0a22349a5e4ac4710%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.