From f24cf51661af21cfe2d90d7cba6557c56778ef20 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 24 Apr 2019 12:58:49 +0200 Subject: [PATCH] [2.2.x] Fixed #30362 -- Noted partial indexes and constraints restrictions with abstract base classes. Thanks Carlton Gibson for the review. Backport of 5df3301aab9e1d1c386799263bef5cf013985c83 from master --- docs/ref/models/constraints.txt | 9 +++++++++ docs/ref/models/indexes.txt | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/docs/ref/models/constraints.txt b/docs/ref/models/constraints.txt index 698b89ff54..77b9ea9c3c 100644 --- a/docs/ref/models/constraints.txt +++ b/docs/ref/models/constraints.txt @@ -19,6 +19,15 @@ option. convention is to use ``from django.db import models`` and refer to the constraints as ``models.Constraint``. +.. admonition:: Constraints in abstract base classes + + You must always specify a unique name for the constraint. As such, you + cannot normally specify a constraint on an abstract base class, since the + :attr:`Meta.constraints ` option is + inherited by subclasses, with exactly the same values for the attributes + (including ``name``) each time. Instead, specify the ``constraints`` option + on subclasses directly, providing a unique name for each constraint. + ``CheckConstraint`` =================== diff --git a/docs/ref/models/indexes.txt b/docs/ref/models/indexes.txt index 16ba17efab..3631d4ea07 100644 --- a/docs/ref/models/indexes.txt +++ b/docs/ref/models/indexes.txt @@ -53,6 +53,16 @@ The name of the index. If ``name`` isn't provided Django will auto-generate a name. For compatibility with different databases, index names cannot be longer than 30 characters and shouldn't start with a number (0-9) or underscore (_). +.. admonition:: Partial indexes in abstract base classes + + You must always specify a unique name for an index. As such, you + cannot normally specify a partial index on an abstract base class, since + the :attr:`Meta.indexes ` option is + inherited by subclasses, with exactly the same values for the attributes + (including ``name``) each time. Instead, specify the ``indexes`` option + on subclasses directly, providing a unique name for each index. + + ``db_tablespace`` -----------------