The attached patch contains an implementation of a management command,
{{{optimizemigration}}}, that will help speed up this process.
{{{optimizemigration app_name migration_name}}} reads a single migration,
pass it through the optimizer, and then rewrite the result to disk. Unlike
{{{squashmigrations}}}, this ignores things like the squashed-ness of the
migration.
--
Ticket URL: <https://code.djangoproject.com/ticket/27844>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "optimizemigration.py" added.
Old description:
> Because the migration optimizer still has a bit of trouble with reducing
> operations, you often want to edit squashed migrations and re-run it
> through the optimizer.
>
> The attached patch contains an implementation of a management command,
> {{{optimizemigration}}}, that will help speed up this process.
>
> {{{optimizemigration app_name migration_name}}} reads a single migration,
> pass it through the optimizer, and then rewrite the result to disk.
> Unlike {{{squashmigrations}}}, this ignores things like the squashed-ness
> of the migration.
New description:
Because the migration optimizer still has a bit of trouble with reducing
operations, you often want to edit squashed migrations and re-run it
through the optimizer.
The attached patch contains an implementation of a management command,
{{{optimizemigration}}}, that will help speed up this process.
{{{optimizemigration app_name migration_name}}} reads a single migration,
pass it through the optimizer, and then rewrite the result to disk. Unlike
{{{squashmigrations}}}, this ignores things like the squashed-ness of the
migration.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/27844#comment:1>
* needs_docs: 0 => 1
* needs_tests: 0 => 1
* stage: Unreviewed => Accepted
Comment:
[https://groups.google.com/d/topic/django-
developers/YMbYXiZgrF0/discussion django-developers discussion from the
reporter]. Shai also [https://groups.google.com/d/topic/django-developers
/C1L-NhyQYG4/discussion proposed] a similar thing.
--
Ticket URL: <https://code.djangoproject.com/ticket/27844#comment:2>
* cc: David Wobrock (added)
* needs_docs: 1 => 0
* owner: nobody => David Wobrock
* needs_tests: 1 => 0
Comment:
Hi there,
Reviving this ticket, I think this command could be quite useful,
especially when you upgrade Django on older projects, and new migration
optimizations were added since.
I submitted a PR inspired by the attached patch.
[https://github.com/django/django/pull/15272 PR]
I made a quite specific choice for the logic of the command. By default,
it overwrites the named migration. But if some manual porting is required,
it will rather try to create a replacement migration. My thought was that,
if functions need manual porting, we don't want to lose the code by
overwriting the migration file.
Tell me what you think of this :)
--
Ticket URL: <https://code.djangoproject.com/ticket/27844#comment:3>
* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
* needs_docs: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/27844#comment:4>
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/27844#comment:5>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/27844#comment:6>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"7c318a8bdd66f8c5241864c9970dddb525d0ca4c" 7c318a8b]:
{{{
#!CommitTicketReference repository=""
revision="7c318a8bdd66f8c5241864c9970dddb525d0ca4c"
Fixed #27844 -- Added optimizemigration management command.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27844#comment:7>