Re: [Django] #33652: Skip ExclusionConstraint on non-PostgreSQL databases. (was: migrations: skip insertion of exclusion constraints when not using postgres)

5 views
Skip to first unread message

Django

unread,
Apr 25, 2022, 6:07:31 AM4/25/22
to django-...@googlegroups.com
#33652: Skip ExclusionConstraint on non-PostgreSQL databases.
-------------------------------------+-------------------------------------
Reporter: hottwaj | Owner: nobody
Type: New feature | Status: closed
Component: Migrations | Version: dev
Severity: Normal | Resolution: wontfix
Keywords: postgres exclusion | Triage Stage:
constraint | 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: => wontfix
* component: Database layer (models, ORM) => Migrations


Comment:

Thanks for this report. We strongly recommend that you use the same
database for testing and a real-life apps. There are many differences and
you may encounter unexpected issues by using a different backend for
testing. Therefore, we don't want to encourage users to do this by
automatically skipping PostgreSQL-specific features. If you really have to
do this you can skip PostgreSQL constraints/indexes in migration files,
e.g.
{{{#!python
class Migration(migrations.Migration):

dependencies = [
('test_33652', '0001_initial'),
]

if connection.vendor == 'postgresql':
operations = [
migrations.AddConstraint(
model_name='hotelreservation',
constraint=django.contrib.postgres.constraints.ExclusionConstraint(condition=models.Q(('cancelled',
False)), expressions=[('room', '=')],
name='exclude_overlapping_reservations'),
),
]
else:
operations = []
}}}

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

Reply all
Reply to author
Forward
0 new messages