[Django] #21323: Allow migrations.Operation to control their output.

7 views
Skip to first unread message

Django

unread,
Oct 24, 2013, 1:49:25 PM10/24/13
to django-...@googlegroups.com
#21323: Allow migrations.Operation to control their output.
--------------------------------------+--------------------
Reporter: loic84 | Owner:
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
Currently `MigrationWriter` controls the output of migrations and to do so
it renders the various operations with a generic format.

The problem is operations such as `CreateModel` end up writing all the
fields on a single line, which makes the migration file difficult to
review.

I propose that `Operations` should control their own output.

I had a go at this in https://github.com/django/django/pull/1681.

--
Ticket URL: <https://code.djangoproject.com/ticket/21323>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 24, 2013, 5:33:13 PM10/24/13
to django-...@googlegroups.com
#21323: Allow migrations.Operation to control their output.
--------------------------------------+------------------------------------

Reporter: loic84 | Owner:
Type: Cleanup/optimization | Status: new
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
--------------------------------------+------------------------------------
Changes (by timo):

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/21323#comment:1>

Django

unread,
Nov 26, 2013, 3:50:00 PM11/26/13
to django-...@googlegroups.com
#21323: Allow migrations.Operation to control their output.
--------------------------------------+------------------------------------

Reporter: loic84 | Owner:
Type: Cleanup/optimization | Status: new
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 andrewgodwin):

Me and loic84 discussed this on IRC a while back; I'm not a fan of how
this currently looks (it makes the operations very hard to read and is
confusing logic with presentation in a way) but it's a nice idea in
principle.

--
Ticket URL: <https://code.djangoproject.com/ticket/21323#comment:2>

Django

unread,
Nov 27, 2013, 12:27:09 AM11/27/13
to django-...@googlegroups.com
#21323: Allow migrations.Operation to control their output.
--------------------------------------+------------------------------------

Reporter: loic84 | Owner:
Type: Cleanup/optimization | Status: new
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 loic84):

I've cleaned up the code a bit by introducing a `MigrationFormatter`
class, but ultimately there isn't so much we can do; presentational logic
in Python is quite verbose. Also the way the serializer is implemented
requires formatting as we go, fixing that would require a significant
refactor.

If we move to a better template system with white spaces handling
(Jinja2), `CreateModel.serialize()` could be shrunk significantly.

IMO being able to review the output of `CreateModel` is sufficiently
critical to justify an imperfect `CreateModel.serialize()` method.

--
Ticket URL: <https://code.djangoproject.com/ticket/21323#comment:3>

Django

unread,
Nov 29, 2013, 10:26:37 AM11/29/13
to django-...@googlegroups.com
#21323: Allow migrations.Operation to control their output.
--------------------------------------+------------------------------------

Reporter: loic84 | Owner:
Type: Cleanup/optimization | Status: new
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 loic84):

I've reworked the code in a way that doesn't affect the `Operation`
classes anymore, the changes are now contained in `migrations/writer.py`.

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

Django

unread,
Jan 19, 2014, 12:30:39 PM1/19/14
to django-...@googlegroups.com
#21323: Allow migrations.Operation to control their output.
-------------------------------------+-------------------------------------
Reporter: loic84 | Owner: Loic
Type: | Bistuer <loic.bistuer@…>
Cleanup/optimization | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: fixed

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 Loic Bistuer <loic.bistuer@…>):

* owner: => Loic Bistuer <loic.bistuer@…>
* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"374faa472150e2e1fb70224a764b82d3d51994f7"]:
{{{
#!CommitTicketReference repository=""
revision="374faa472150e2e1fb70224a764b82d3d51994f7"
Fixed #21323 -- Improved readability of serialized Operation.
}}}

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

Django

unread,
Jan 19, 2014, 12:30:40 PM1/19/14
to django-...@googlegroups.com
#21323: Allow migrations.Operation to control their output.
-------------------------------------+-------------------------------------
Reporter: loic84 | Owner: Loic
Type: | Bistuer <loic.bistuer@…>
Cleanup/optimization | Status: closed
Component: Migrations | Version: master

Severity: Normal | Resolution: fixed
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 Andrew Godwin <andrew@…>):

In [changeset:"e8d4aed3b97493a050f69dca1f6562991d5c511b"]:
{{{
#!CommitTicketReference repository=""
revision="e8d4aed3b97493a050f69dca1f6562991d5c511b"
Merge pull request #1681 from loic/migrations.format

Fixed #21323 -- Improved readability of serialized Operation.
}}}

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

Reply all
Reply to author
Forward
0 new messages