Old description:
> From https://github.com/django/django/pull/16819#issuecomment-1529913703
>
> - RenameIndex can be reduced into CreateIndex
> - DropConstraint can be reduced into CreateConstraint
> - A question was raised whether constraints could be reduced into create
> model though some databases do not support deferrable constraints (eg
> MySQL)
> - It's worth going over the operations to see if there are any other
> potential reductions to add
New description:
From https://github.com/django/django/pull/16819#issuecomment-1529913703
- `RenameIndex` can be reduced into `AddIndex`
- `DropConstraint` can be reduced with `AddConstraint`
- A question was raised whether constraints could be reduced into create
model though some databases do not support deferrable constraints (eg
MySQL)
- It's worth going over the operations to see if there are any other
potential reductions to add
--
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => Akash Kumar Sen
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:3>
Comment (by David Sanders):
Hi Akash,
Please see this PR for context & "prior art":
https://github.com/django/django/pull/16819 👍
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:4>
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:5>
Comment (by Akash Kumar Sen):
Thanks for the review David. Updated the patch accordingly.
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:6>
* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:7>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"92f0017133c2d31fbd527bab7b08d4d49a582143" 92f0017]:
{{{
#!CommitTicketReference repository=""
revision="92f0017133c2d31fbd527bab7b08d4d49a582143"
Refs #34534 -- Reduced Add/RemoveConstraint and Add/RenameIndex operations
when optimizing migrations.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:8>
* has_patch: 1 => 0
* stage: Ready for checkin => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:9>
* owner: Akash Kumar Sen => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:10>
Comment (by Adam Johnson):
Thank you for reporting this David, making the PR Akash, and reviewing
Mariusz. 👏
I was just looking at a migration with consecutive add + remove operations
for the same constraints, wondering why they weren't optimized. Glad to
see they will be in the future.
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:11>
* cc: bcail (added)
Comment:
Should this ticket be closed, or is there something else that's supposed
to be done here?
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:12>
Replying to [comment:12 bcail]:
> Should this ticket be closed, or is there something else that's supposed
to be done here?
Two points remain unresolved:
> - A question was raised whether constraints could be reduced into
create model though some databases do not support deferrable constraints
(eg MySQL)
> - It's worth going over the operations to see if there are any other
potential reductions to add
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:13>
> A question was raised whether constraints could be reduced into create
model though some databases do not support deferrable constraints (eg
MySQL)
I opened [https://github.com/django/django/pull/17805 a PR] for this part.
Is that on the right track?
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:14>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:15>
* owner: (none) => bcail
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:16>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:17>
In [changeset:"8b7ddd1b621e1396cf87c08faf11937732f09dcd" 8b7ddd1]:
{{{#!CommitTicketReference repository=""
revision="8b7ddd1b621e1396cf87c08faf11937732f09dcd"
Refs #34534 -- Reduced constraint operations with Meta.constraints when
optimizing migrations.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:18>
* status: assigned => closed
* resolution: => fixed
--
Ticket URL: <https://code.djangoproject.com/ticket/34534#comment:19>