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 | |
| parent | c7e986fc9f4848bd757d4b9b70a40586d2cee9fb (diff) | |
Fixed #31700 -- Made makemigrations command display meaningful symbols for each operation.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/intro/tutorial02.txt | 4 | ||||
| -rw-r--r-- | docs/ref/contrib/gis/tutorial.txt | 2 | ||||
| -rw-r--r-- | docs/ref/migration-operations.txt | 42 | ||||
| -rw-r--r-- | docs/releases/5.1.txt | 9 | ||||
| -rw-r--r-- | docs/topics/migrations.txt | 2 |
5 files changed, 52 insertions, 7 deletions
diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index 6ba70ddc1c..d558a3eb1d 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -241,8 +241,8 @@ You should see something similar to the following: Migrations for 'polls': polls/migrations/0001_initial.py - - Create model Question - - Create model Choice + + Create model Question + + Create model Choice By running ``makemigrations``, you're telling Django that you've made some changes to your models (in this case, you've made new ones) and that 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 diff --git a/docs/releases/5.1.txt b/docs/releases/5.1.txt index 1f7d26d7b8..f8393303be 100644 --- a/docs/releases/5.1.txt +++ b/docs/releases/5.1.txt @@ -178,12 +178,17 @@ Logging Management Commands ~~~~~~~~~~~~~~~~~~~ -* ... +* :djadmin:`makemigrations` command now displays meaningful symbols for each + operation to highlight :class:`operation categories + <django.db.migrations.operations.base.OperationCategory>`. Migrations ~~~~~~~~~~ -* ... +* The new ``Operation.category`` attribute allows specifying an + :class:`operation category + <django.db.migrations.operations.base.OperationCategory>` used by the + :djadmin:`makemigrations` to display a meaningful symbol for the operation. Models ~~~~~~ diff --git a/docs/topics/migrations.txt b/docs/topics/migrations.txt index 9e339852b6..5fb5019c1e 100644 --- a/docs/topics/migrations.txt +++ b/docs/topics/migrations.txt @@ -118,7 +118,7 @@ field and remove a model - and then run :djadmin:`makemigrations`: $ python manage.py makemigrations Migrations for 'books': books/migrations/0003_auto.py: - - Alter field author on book + ~ Alter field author on book Your models will be scanned and compared to the versions currently contained in your migration files, and then a new set of migrations |
