mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #21039 -- Added AddIndexConcurrently/RemoveIndexConcurrently operations for PostgreSQL.
Thanks to Simon Charettes for review. Co-Authored-By: Daniel Tao <daniel.tao@gmail.com>
This commit is contained in:
parent
9a88e43aeb
commit
85ac838d9e
10 changed files with 275 additions and 11 deletions
|
@ -98,3 +98,33 @@ run the query ``CREATE EXTENSION IF NOT EXISTS hstore;``.
|
|||
.. class:: UnaccentExtension()
|
||||
|
||||
Installs the ``unaccent`` extension.
|
||||
|
||||
Index concurrent operations
|
||||
===========================
|
||||
|
||||
.. versionadded:: 3.0
|
||||
|
||||
PostgreSQL supports the ``CONCURRENTLY`` option to ``CREATE INDEX`` and
|
||||
``DROP INDEX`` statements to add and remove indexes without locking out writes.
|
||||
This option is useful for adding or removing an index in a live production
|
||||
database.
|
||||
|
||||
.. class:: AddIndexConcurrently(model_name, index)
|
||||
|
||||
Like :class:`~django.db.migrations.operations.AddIndex`, but creates an
|
||||
index with the ``CONCURRENTLY`` option. This has a few caveats to be aware
|
||||
of when using this option, see `the PostgreSQL documentation of building
|
||||
indexes concurrently <https://www.postgresql.org/docs/current/
|
||||
sql-createindex.html#SQL-CREATEINDEX-CONCURRENTLY>`_.
|
||||
|
||||
.. class:: RemoveIndexConcurrently(model_name, name)
|
||||
|
||||
Like :class:`~django.db.migrations.operations.RemoveIndex`, but removes the
|
||||
index with the ``CONCURRENTLY`` option. This has a few caveats to be aware
|
||||
of when using this option, see `the PostgreSQL documentation
|
||||
<https://www.postgresql.org/docs/current/sql-dropindex.html>`_.
|
||||
|
||||
.. note::
|
||||
|
||||
The ``CONCURRENTLY`` option is not supported inside a transaction (see
|
||||
:ref:`non-atomic migration <non-atomic-migrations>`).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue