diff options
| author | Amir Karimi <amk9978@gmail.com> | 2023-09-16 05:41:22 +0330 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-01-17 14:00:02 +0100 |
| commit | 27a3eee72170f1eb994a213db985f42c6cf5f994 (patch) | |
| tree | d3522cf986d3ce3c1147063c5dbd1805c95843fa /docs/ref | |
| parent | c7e986fc9f4848bd757d4b9b70a40586d2cee9fb (diff) | |
Fixed #31700 -- Made makemigrations command display meaningful symbols for each operation.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/contrib/gis/tutorial.txt | 2 | ||||
| -rw-r--r-- | docs/ref/migration-operations.txt | 42 |
2 files changed, 42 insertions, 2 deletions
diff --git a/docs/ref/contrib/gis/tutorial.txt b/docs/ref/contrib/gis/tutorial.txt index eb62df56a8..53c961561c 100644 --- a/docs/ref/contrib/gis/tutorial.txt +++ b/docs/ref/contrib/gis/tutorial.txt @@ -241,7 +241,7 @@ create a database migration: $ python manage.py makemigrations Migrations for 'world': world/migrations/0001_initial.py: - - Create model WorldBorder + + Create model WorldBorder Let's look at the SQL that will generate the table for the ``WorldBorder`` model: diff --git a/docs/ref/migration-operations.txt b/docs/ref/migration-operations.txt index e8d8630851..3c39d27873 100644 --- a/docs/ref/migration-operations.txt +++ b/docs/ref/migration-operations.txt @@ -475,6 +475,42 @@ operations. For an example using ``SeparateDatabaseAndState``, see :ref:`changing-a-manytomanyfield-to-use-a-through-model`. +Operation category +================== + +.. versionadded:: 5.1 + +.. currentmodule:: django.db.migrations.operations.base + +.. class:: OperationCategory + + Categories of migration operation used by the :djadmin:`makemigrations` + command to display meaningful symbols. + + .. attribute:: ADDITION + + *Symbol*: ``+`` + + .. attribute:: REMOVAL + + *Symbol*: ``-`` + + .. attribute:: ALTERATION + + *Symbol*: ``~`` + + .. attribute:: PYTHON + + *Symbol*: ``p`` + + .. attribute:: SQL + + *Symbol*: ``s`` + + .. attribute:: MIXED + + *Symbol*: ``?`` + .. _writing-your-own-migration-operation: Writing your own @@ -495,6 +531,10 @@ structure of an ``Operation`` looks like this:: # If this is False, Django will refuse to reverse past this operation. reversible = False + # This categorizes the operation. The corresponding symbol will be + # display by the makemigrations command. + category = OperationCategory.ADDITION + def __init__(self, arg1, arg2): # Operations are usually instantiated with arguments in migration # files. Store the values of them on self for later use. @@ -516,7 +556,7 @@ structure of an ``Operation`` looks like this:: pass def describe(self): - # This is used to describe what the operation does in console output. + # This is used to describe what the operation does. return "Custom Operation" @property |
