Re: [Django] #33673: PostgreSQL removes constraints when removing columns. (was: Django silently removes constraints when removing columns, then arbitrarily choses to include them in migrations)

4 views
Skip to first unread message

Django

unread,
May 2, 2022, 3:59:20 AM5/2/22
to django-...@googlegroups.com
#33673: PostgreSQL removes constraints when removing columns.
----------------------------+--------------------------------------
Reporter: George | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => needsinfo


Comment:

Thanks for the report, however PostgreSQL silently drops constraints, not
Django itself. Unfortunately when you create migrations manually you must
be aware of database-specific behavior and handle them on your own in most
of cases. As far as I'm aware described use case (removing column to add
it immediately in the same migration) is really unusual and not worth
additional complexity and a performance regression for all users. Noticing
that constraint is missing would require inspecting db constraints which
is always quite expensive.

Is there any reason you cannot handle this automatically with
`AlterField()`?

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

Reply all
Reply to author
Forward
0 new messages