[Django] #37151: Add support for squashing across AddIndex, AddConstraint, and AlterConstraint

2 views
Skip to first unread message

Django

unread,
5:45 AM (5 hours ago) 5:45 AM
to django-...@googlegroups.com
#37151: Add support for squashing across AddIndex, AddConstraint, and
AlterConstraint
-----------------------------------+---------------------------------------
Reporter: Markus Holtermann | Type: New feature
Status: new | Component: Migrations
Version: 6.0 | Severity: Normal
Keywords: migrations | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+---------------------------------------
The `AddIndex`, `AddConstraint`, and `AlterConstraint` migration
operations straight out reject squashing across them.

Let's take the following set of operations:

{{{
[
migrations.CreateModel("A", fields=[("id", models.BigAutoField())]),
migrations.AddIndex("b", models.Index(fields=["id"], name="b_idx")),
migrations.AddField("a", "name", models.IntegerField()),
]
}}}
I would expect to get the following 2 operations:
{{{
[
migrations.AddIndex("b", models.Index(fields=["id"], name="b_idx")),
migrations.CreateModel("A", fields=[("id", models.BigAutoField()),
("name", models.IntegerField())]),
]
}}}
Instead, I end up with the same set of operations.
--
Ticket URL: <https://code.djangoproject.com/ticket/37151>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
5:45 AM (5 hours ago) 5:45 AM
to django-...@googlegroups.com
#37151: Add support for squashing across AddIndex, AddConstraint, and
AlterConstraint
-------------------------------------+-------------------------------------
Reporter: Markus Holtermann | Owner: Markus
| Holtermann
Type: New feature | Status: assigned
Component: Migrations | Version: 6.0
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Markus Holtermann):

* owner: (none) => Markus Holtermann
* status: new => assigned

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

Django

unread,
8:31 AM (2 hours ago) 8:31 AM
to django-...@googlegroups.com
#37151: Add support for squashing across AddIndex, AddConstraint, and
AlterConstraint
-------------------------------------+-------------------------------------
Reporter: Markus Holtermann | Owner: Markus
| Holtermann
Type: New feature | Status: assigned
Component: Migrations | Version: 6.0
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* stage: Unreviewed => Accepted

Comment:

I'm surprised to see that when we added `IndexOperation` and friends we
didn't realize that `AlterTogetherOptionOperation` and friends were
subclassing `ModelOptionOperation` for its `.reduce` operation (which
make us of `references_model` to implement what you're after here).

This ticket seems to be about implementing model reference awareness but
we could also implement field reference awareness (`references_field`) not
that we have the machinery to extra field references from expressions (see
`Index.check` for example).
--
Ticket URL: <https://code.djangoproject.com/ticket/37151#comment:2>
Reply all
Reply to author
Forward
0 new messages