Opened 6 years ago
Last modified 5 years ago
#29824 closed New feature
Exclude using constraint — at Initial Version
Reported by: | Mads Jensen | Owned by: | Mads Jensen |
---|---|---|---|
Component: | contrib.postgres | Version: | dev |
Severity: | Normal | Keywords: | constraints postgres |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
A lot of work was done to add the check constraint to Django 2.2. On top of such a constraint, PostgreSQL has an exclusion constraint that works well on ranges, regardless if they're represented using two fields, or a single field using a range-type. Essentially, this constraint enforces a unique constraint for ranges, with a possibility for an additional check.
https://github.com/tbicr/django-pg-zero-downtime-migrations/ uses ALTER TABLE %(table)s VALIDATE CONSTRAINT
to restrict how long the table is locked for writing. I was contemplating to touch this subject in the patch.