Skip to content

Commit

Permalink
Fixed #30362 -- Noted partial indexes and constraints restrictions wi…
Browse files Browse the repository at this point in the history
…th abstract base classes.
  • Loading branch information
felixxm committed Apr 24, 2019
1 parent 7aa7f84 commit 9677e93
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/ref/models/constraints.txt
Expand Up @@ -19,6 +19,16 @@ option.
convention is to use ``from django.db import models`` and refer to the
constraints as ``models.<Foo>Constraint``.

.. admonition:: Constraints in abstract base classes

You must always specify a unique name for the constraint. This would
normally cause a problem in abstract base classes, since the
:attr:`Meta.constraints <django.db.models.Options.constraints>` option on
this class are included into each of the child classes, with exactly the
same values for the attributes (including ``name``) each time. To work
around this problem, ``constraints`` option should be specified for each of
the child classes with unique names for constraints.

``CheckConstraint``
===================

Expand Down
11 changes: 11 additions & 0 deletions docs/ref/models/indexes.txt
Expand Up @@ -49,6 +49,17 @@ 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 the index. This would normally
cause a problem for partial indexes in abstract base classes, since
``name`` is required and the
:attr:`Meta.indexes <django.db.models.Options.indexes>` option on this
class are included into each of the child classes, with exactly the same
values for the attributes (including ``name``) each time. To work around
this problem, ``indexes`` option should be specified for each of the child
classes with unique names for indexes.

``db_tablespace``
-----------------

Expand Down

0 comments on commit 9677e93

Please sign in to comment.