[Django] #27844: Add a management command to run the optimizer on a single migration

46 views
Skip to first unread message

Django

unread,
Feb 15, 2017, 10:47:24 AM2/15/17
to django-...@googlegroups.com
#27844: Add a management command to run the optimizer on a single migration
-----------------------------------------------+--------------------------
Reporter: Raphael Gaschignard | Owner: nobody
Type: New feature | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------------+--------------------------
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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 15, 2017, 10:48:04 AM2/15/17
to django-...@googlegroups.com
#27844: Add a management command to run the optimizer on a single migration
-------------------------------------+-------------------------------------

Reporter: Raphael Gaschignard | Owner: nobody
Type: New feature | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Raphael Gaschignard):

* Attachment "optimizemigration.py" added.

Django

unread,
Feb 15, 2017, 10:48:45 AM2/15/17
to django-...@googlegroups.com
#27844: Add a management command to run the optimizer on a single migration
-------------------------------------+-------------------------------------

Reporter: Raphael Gaschignard | Owner: nobody
Type: New feature | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Raphael Gaschignard:

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>

Django

unread,
Feb 15, 2017, 1:08:26 PM2/15/17
to django-...@googlegroups.com
#27844: Add a management command to optimize a migration
-------------------------------------+------------------------------------

Reporter: Raphael Gaschignard | Owner: nobody
Type: New feature | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Tim Graham):

* 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>

Django

unread,
Jan 2, 2022, 3:43:43 AM1/2/22
to django-...@googlegroups.com
#27844: Add a management command to optimize a migration
-------------------------------------+-------------------------------------
Reporter: Raphael Gaschignard | Owner: David
| Wobrock

Type: New feature | Status: assigned
Component: Migrations | Version: dev

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
-------------------------------------+-------------------------------------
Changes (by David Wobrock):

* 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>

Django

unread,
Feb 17, 2022, 1:42:34 AM2/17/22
to django-...@googlegroups.com
#27844: Add a management command to optimize a migration
-------------------------------------+-------------------------------------
Reporter: Raphael Gaschignard | Owner: David
| Wobrock
Type: New feature | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


* needs_tests: 0 => 1

* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27844#comment:4>

Django

unread,
Feb 19, 2022, 4:08:41 AM2/19/22
to django-...@googlegroups.com
#27844: Add a management command to optimize a migration
-------------------------------------+-------------------------------------
Reporter: Raphael Gaschignard | Owner: David
| Wobrock
Type: New feature | Status: assigned
Component: Migrations | Version: dev
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
-------------------------------------+-------------------------------------
Changes (by David Wobrock):

* needs_better_patch: 1 => 0


* needs_tests: 1 => 0

* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/27844#comment:5>

Django

unread,
Feb 21, 2022, 3:07:50 PM2/21/22
to django-...@googlegroups.com
#27844: Add a management command to optimize a migration
-------------------------------------+-------------------------------------
Reporter: Raphael Gaschignard | Owner: David
| Wobrock
Type: New feature | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27844#comment:6>

Django

unread,
Feb 22, 2022, 5:13:18 AM2/22/22
to django-...@googlegroups.com
#27844: Add a management command to optimize a migration
-------------------------------------+-------------------------------------
Reporter: Raphael Gaschignard | Owner: David
| Wobrock
Type: New feature | Status: closed
Component: Migrations | Version: dev
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* 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>

Reply all
Reply to author
Forward
0 new messages