1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Refs #27236 -- Removed Meta.index_together per deprecation timeline.

This commit is contained in:
Mariusz Felisiak
2023-09-12 05:56:16 +02:00
parent 00e1879610
commit 2abf417c81
25 changed files with 41 additions and 1308 deletions

View File

@@ -345,21 +345,23 @@ Models
``<field name>`` from model ``<model>``.
* **models.E007**: Field ``<field name>`` has column name ``<column name>``
that is used by another field.
* **models.E008**: ``index_together`` must be a list or tuple.
* **models.E008**: ``index_together`` must be a list or tuple. *This check
appeared before Django 5.1.*
* **models.E009**: All ``index_together`` elements must be lists or tuples.
*This check appeared before Django 5.1.*
* **models.E010**: ``unique_together`` must be a list or tuple.
* **models.E011**: All ``unique_together`` elements must be lists or tuples.
* **models.E012**: ``constraints/indexes/index_together/unique_together``
refers to the nonexistent field ``<field name>``.
* **models.E013**: ``constraints/indexes/index_together/unique_together``
refers to a ``ManyToManyField`` ``<field name>``, but ``ManyToManyField``\s
are not supported for that option.
* **models.E012**: ``constraints/indexes/unique_together`` refers to the
nonexistent field ``<field name>``.
* **models.E013**: ``constraints/indexes/unique_together`` refers to a
``ManyToManyField`` ``<field name>``, but ``ManyToManyField``\s are not
supported for that option.
* **models.E014**: ``ordering`` must be a tuple or list (even if you want to
order by only one field).
* **models.E015**: ``ordering`` refers to the nonexistent field, related field,
or lookup ``<field name>``.
* **models.E016**: ``constraints/indexes/index_together/unique_together``
refers to field ``<field_name>`` which is not local to model ``<model>``.
* **models.E016**: ``constraints/indexes/unique_together`` refers to field
``<field_name>`` which is not local to model ``<model>``.
* **models.E017**: Proxy model ``<model>`` contains model fields.
* **models.E018**: Autogenerated column name too long for field ``<field>``.
Maximum length is ``<maximum length>`` for database ``<alias>``.

View File

@@ -247,7 +247,7 @@ Removes the index named ``name`` from the model with ``model_name``.
Renames an index in the database table for the model with ``model_name``.
Exactly one of ``old_name`` and ``old_fields`` can be provided. ``old_fields``
is an iterable of the strings, often corresponding to fields of
:attr:`~django.db.models.Options.index_together`.
``index_together`` (pre-Django 5.1 option).
On databases that don't support an index renaming statement (SQLite and MariaDB
< 10.5.2), the operation will drop and recreate the index, which can be

View File

@@ -451,29 +451,6 @@ not be looking at your Django code. For example::
The ``ValidationError`` raised during model validation when the constraint
is violated has the ``unique_together`` error code.
``index_together``
------------------
.. attribute:: Options.index_together
Sets of field names that, taken together, are indexed::
index_together = [
["pub_date", "deadline"],
]
This list of fields will be indexed together (i.e. the appropriate
``CREATE INDEX`` statement will be issued.)
For convenience, ``index_together`` can be a single list when dealing with a single
set of fields::
index_together = ["pub_date", "deadline"]
.. deprecated:: 4.2
Use the :attr:`~Options.indexes` option instead.
``constraints``
---------------

View File

@@ -114,9 +114,8 @@ the new value.
.. method:: BaseDatabaseSchemaEditor.alter_index_together(model, old_index_together, new_index_together)
Changes a model's :attr:`~django.db.models.Options.index_together` value; this
will add or remove indexes from the model's table until they match the new
value.
Changes a model's ``index_together`` value; this will add or remove indexes
from the model's table until they match the new value.
``alter_db_table()``
--------------------

View File

@@ -59,8 +59,8 @@ creating database indexes. Indexes are added to models using the
The :class:`~django.db.models.Index` class creates a b-tree index, as if you
used :attr:`~django.db.models.Field.db_index` on the model field or
:attr:`~django.db.models.Options.index_together` on the model ``Meta`` class.
It can be subclassed to support different index types, such as
``index_together`` on the model ``Meta`` class. It can be subclassed to support
different index types, such as
:class:`~django.contrib.postgres.indexes.GinIndex`. It also allows defining the
order (ASC/DESC) for the columns of the index.

View File

@@ -329,8 +329,7 @@ Django 1.5 also includes several smaller improvements worth noting:
session data in a non-default cache.
* Multi-column indexes can now be created on models. Read the
:attr:`~django.db.models.Options.index_together` documentation for more
information.
``index_together`` documentation for more information.
* During Django's logging configuration verbose Deprecation warnings are
enabled and warnings are captured into the logging system. Logged warnings

View File

@@ -778,8 +778,8 @@ Models
an error (before that, it would either result in a database error or
incorrect data).
* You can use a single list for :attr:`~django.db.models.Options.index_together`
(rather than a list of lists) when specifying a single set of fields.
* You can use a single list for ``index_together`` (rather than a list of
lists) when specifying a single set of fields.
* Custom intermediate models having more than one foreign key to any of the
models participating in a many-to-many relationship are now permitted,

View File

@@ -317,7 +317,7 @@ Migrations
* The new :class:`~django.db.migrations.operations.RenameIndex` operation
allows renaming indexes defined in the
:attr:`Meta.indexes <django.db.models.Options.indexes>` or
:attr:`~django.db.models.Options.index_together` options.
``index_together`` options.
* The migrations autodetector now generates
:class:`~django.db.migrations.operations.RenameIndex` operations instead of
@@ -327,7 +327,7 @@ Migrations
* The migrations autodetector now generates
:class:`~django.db.migrations.operations.RenameIndex` operations instead of
``AlterIndexTogether`` and ``AddIndex``, when moving indexes defined in the
:attr:`Meta.index_together <django.db.models.Options.index_together>` to the
``Meta.index_together`` to the
:attr:`Meta.indexes <django.db.models.Options.indexes>`.
Models

View File

@@ -477,9 +477,8 @@ Features deprecated in 4.2
``index_together`` option is deprecated in favor of ``indexes``
---------------------------------------------------------------
The :attr:`Meta.index_together <django.db.models.Options.index_together>`
option is deprecated in favor of the :attr:`~django.db.models.Options.indexes`
option.
The ``Meta.index_together`` option is deprecated in favor of the
:attr:`~django.db.models.Options.indexes` option.
Migrating existing ``index_together`` should be handled as a migration. For
example::

View File

@@ -252,3 +252,5 @@ See :ref:`deprecated-features-4.2` for details on these changes, including how
to remove usage of these features.
* The ``BaseUserManager.make_random_password()`` method is removed.
* The model's ``Meta.index_together`` option is removed.