Re: [Django] #35469: Squashing migrations from unique=True to unique=False to UniqueConstraint produces irreversible migration on Postgres

19 views
Skip to first unread message

Django

unread,
May 22, 2024, 7:58:00 AM5/22/24
to django-...@googlegroups.com
#35469: Squashing migrations from unique=True to unique=False to UniqueConstraint
produces irreversible migration on Postgres
-----------------------------+------------------------------------
Reporter: Jacob Walls | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Comment (by Jacob Walls):

Thanks for the link to #28646. It's related, but most of the discussion
there centers around the "boolean logic" cited in that ticket's OP. I
tried the various patches, and they don't fix my report because they just
shuffle the logic fathoming the booleans `db_index` and `unique` on
`old_field` and `new_fields`, whereas the problem here seems to be that
one of those values is wrong.

#26805 inspired me to check SlugField. I can't reproduce with SlugField,
leading me to wonder if it's something to do with `URLField`'s different
implementation of `deconstruct()`?

When using SlugField, and breaking on the comment "Added an index? ..." in
db/backends/postgresql/schema.py, I get:
{{{
(Pdb) new_field.db_index
True
}}}
versus with URLField:
{{{
(Pdb) new_field.db_index
False
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35469#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 22, 2024, 9:52:36 AM5/22/24
to django-...@googlegroups.com
#35469: Squashing migrations from unique=True to unique=False to UniqueConstraint
produces irreversible migration on Postgres
-----------------------------+------------------------------------
Reporter: Jacob Walls | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Comment (by Jacob Walls):

Sorry, still forming first impressions here, but just piping up to clarify
that my last comment mostly barks up the wrong tree: the field values for
`db_index` and whatnot look fine. And on a closer read of #28646, it
strikes me as mostly focused on SlugField, which *doesn't* have the
problem presented here. So I think having separate tickets makes sense.
--
Ticket URL: <https://code.djangoproject.com/ticket/35469#comment:5>

Django

unread,
May 23, 2024, 3:44:23 AM5/23/24
to django-...@googlegroups.com
#35469: Squashing migrations from unique=True to unique=False to UniqueConstraint
produces irreversible migration on Postgres
-----------------------------+------------------------------------
Reporter: Jacob Walls | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Comment (by Sarah Boyce):

Confirmed the patch wouldn't fix it and agree let's track this separately,
thank you for taking a look 👍
--
Ticket URL: <https://code.djangoproject.com/ticket/35469#comment:6>

Django

unread,
May 25, 2024, 3:20:54 PM5/25/24
to django-...@googlegroups.com
#35469: Squashing migrations from unique=True to unique=False to UniqueConstraint
produces irreversible migration on Postgres
-----------------------------+---------------------------------------
Reporter: Jacob Walls | Owner: Jacob Walls
Type: Bug | Status: assigned
Component: Migrations | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+---------------------------------------
Changes (by Jacob Walls):

* owner: nobody => Jacob Walls
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35469#comment:7>

Django

unread,
May 25, 2024, 6:07:36 PM5/25/24
to django-...@googlegroups.com
#35469: Squashing migrations from unique=True to unique=False to UniqueConstraint
produces irreversible migration on Postgres
-----------------------------+---------------------------------------
Reporter: Jacob Walls | Owner: Jacob Walls
Type: Bug | Status: assigned
Component: Migrations | Version: 4.2
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 Jacob Walls):

* has_patch: 0 => 1

Comment:

[https://github.com/django/django/pull/18199 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/35469#comment:8>

Django

unread,
May 27, 2024, 11:01:20 AM5/27/24
to django-...@googlegroups.com
#35469: Squashing migrations from unique=True to unique=False to UniqueConstraint
produces irreversible migration on Postgres
-----------------------------+---------------------------------------
Reporter: Jacob Walls | Owner: Jacob Walls
Type: Bug | Status: assigned
Component: Migrations | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------+---------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35469#comment:9>

Django

unread,
May 27, 2024, 2:02:33 PM5/27/24
to django-...@googlegroups.com
#35469: Squashing migrations from unique=True to unique=False to UniqueConstraint
produces irreversible migration on Postgres
-----------------------------+---------------------------------------
Reporter: Jacob Walls | Owner: Jacob Walls
Type: Bug | Status: assigned
Component: Migrations | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------+---------------------------------------
Changes (by Jacob Walls):

* has_patch: 1 => 0
* needs_tests: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35469#comment:10>

Django

unread,
May 27, 2024, 2:02:49 PM5/27/24
to django-...@googlegroups.com
#35469: Squashing migrations from unique=True to unique=False to UniqueConstraint
produces irreversible migration on Postgres
-----------------------------+---------------------------------------
Reporter: Jacob Walls | Owner: Jacob Walls
Type: Bug | Status: assigned
Component: Migrations | Version: 4.2
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 Jacob Walls):

* has_patch: 0 => 1
* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35469#comment:11>

Django

unread,
May 28, 2024, 3:51:25 AM5/28/24
to django-...@googlegroups.com
#35469: Squashing migrations from unique=True to unique=False to UniqueConstraint
produces irreversible migration on Postgres
-----------------------------+---------------------------------------------
Reporter: Jacob Walls | Owner: Jacob Walls
Type: Bug | Status: assigned
Component: Migrations | Version: 4.2
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 Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35469#comment:12>

Django

unread,
May 28, 2024, 6:44:18 AM5/28/24
to django-...@googlegroups.com
#35469: Squashing migrations from unique=True to unique=False to UniqueConstraint
produces irreversible migration on Postgres
-----------------------------+---------------------------------------------
Reporter: Jacob Walls | Owner: Jacob Walls
Type: Bug | Status: closed
Component: Migrations | Version: 4.2
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 Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"99f23eaabd8da653f046dc1d19f5008c030a4f79" 99f23ea]:
{{{#!CommitTicketReference repository=""
revision="99f23eaabd8da653f046dc1d19f5008c030a4f79"
Fixed #35469 -- Removed deferred SQL to create index removed by AlterField
operation.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35469#comment:13>

Django

unread,
Jun 14, 2024, 8:22:33 AM6/14/24
to django-...@googlegroups.com
#35469: Squashing migrations from unique=True to unique=False to UniqueConstraint
produces irreversible migration on Postgres
-----------------------------+---------------------------------------------
Reporter: Jacob Walls | Owner: Jacob Walls
Type: Bug | Status: closed
Component: Migrations | Version: 4.2
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
-----------------------------+---------------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"db349fc464ffcc1fbd426277d1ce1d239f1a061f" db349fc4]:
{{{#!CommitTicketReference repository=""
revision="db349fc464ffcc1fbd426277d1ce1d239f1a061f"
[5.1.x] Fixed #35469 -- Removed deferred SQL to create index removed by
AlterField operation.

Backport of 99f23eaabd8da653f046dc1d19f5008c030a4f79 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35469#comment:14>
Reply all
Reply to author
Forward
0 new messages