diff options
| author | Adam Johnson <me@adamj.eu> | 2019-11-23 11:08:45 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-05-28 11:42:53 +0200 |
| commit | fa58450a9ab8a1bdd2a5090b51b00078fd85ffa6 (patch) | |
| tree | 564cf0f25dda6c27ef94c57f276db42cf61abbd2 /docs | |
| parent | 5bd585a82dd963b3d8fdac2b37ff5276f71c5b27 (diff) | |
Fixed #31468 -- Allowed specifying migration filename in Operation.
This adds also suggested filename for many built-in operations.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/migration-operations.txt | 14 | ||||
| -rw-r--r-- | docs/releases/3.2.txt | 4 |
2 files changed, 17 insertions, 1 deletions
diff --git a/docs/ref/migration-operations.txt b/docs/ref/migration-operations.txt index a6b42bdc99..d1620cce8e 100644 --- a/docs/ref/migration-operations.txt +++ b/docs/ref/migration-operations.txt @@ -484,6 +484,16 @@ structure of an ``Operation`` looks like this:: # This is used to describe what the operation does in console output. return "Custom Operation" + @property + def migration_name_fragment(self): + # Optional. A filename part suitable for automatically naming a + # migration containing this operation, or None if not applicable. + return "custom_operation_%s_%s" % (self.arg1, self.arg2) + +.. versionadded:: 3.2 + + The ``migration_name_fragment`` property was added. + You can take this template and work from it, though we suggest looking at the built-in Django operations in ``django.db.migrations.operations`` - they cover a lot of the example usage of semi-internal aspects of the migration framework @@ -553,3 +563,7 @@ state changes, all it does is run one command:: def describe(self): return "Creates extension %s" % self.name + + @property + def migration_name_fragment(self): + return "create_extension_%s" % self.name diff --git a/docs/releases/3.2.txt b/docs/releases/3.2.txt index 1ba636c4a6..a869eb49cf 100644 --- a/docs/releases/3.2.txt +++ b/docs/releases/3.2.txt @@ -171,7 +171,9 @@ Management Commands Migrations ~~~~~~~~~~ -* ... +* The new ``Operation.migration_name_fragment`` property allows providing a + filename fragment that will be used to name a migration containing only that + operation. Models ~~~~~~ |
