Skip to content

Commit 3aac310

Browse files
committed
Add warning to docs about partioned models always using pgmakemigrations
1 parent 71236bc commit 3aac310

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

docs/source/table_partitioning.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,21 @@ Run the following command to automatically generate a migration:
6969
This will generate a migration that creates the partitioned table with a default partition.
7070

7171

72-
Adding/removing partitions manually
73-
-----------------------------------
72+
.. warning::
7473

75-
Postgres does not have support for automatically creating new partitions as needed. Therefore, one must manually add new partitions. Depending on the partitioning method you have chosen, the partition has to be created differently.
74+
Always use ``python manage.py pgmakemigrations`` for partitioned models.
7675

77-
Partitions are tables. Each partition must be given a unique name. :class:`~psqlextra.models.PostgresPartitionedModel` does not require you to create a model for each partition because you are not supposed to query partitions directly.
76+
The model must be created by the :class:`~psqlextra.migrations.operations.PostgresCreatePartitionedModel` operation.
7877

78+
Do not use the standard ``python manage.py makemigrations`` command for partitioned models. Django will issue a standard :class:`~django:django.db.migrations.operations.CreateModel` operation. Doing this will not create a partitioned table and all subsequent operations will fail.
7979

80-
Using migrations
81-
****************
8280

83-
Migrations for the creation and deletion of partitioned models can be handled automatically using the special `pgmakemigrations` command:
81+
Adding/removing partitions manually
82+
-----------------------------------
8483

85-
.. code-block:: bash
84+
Postgres does not have support for automatically creating new partitions as needed. Therefore, one must manually add new partitions. Depending on the partitioning method you have chosen, the partition has to be created differently.
8685

87-
python manage.py pgmakemigrations
86+
Partitions are tables. Each partition must be given a unique name. :class:`~psqlextra.models.PostgresPartitionedModel` does not require you to create a model for each partition because you are not supposed to query partitions directly.
8887

8988

9089
Adding a range partition

0 commit comments

Comments
 (0)