mirror of
https://github.com/django/django.git
synced 2025-08-02 10:02:41 +00:00
Fixed #31468 -- Allowed specifying migration filename in Operation.
This adds also suggested filename for many built-in operations.
This commit is contained in:
parent
5bd585a82d
commit
fa58450a9a
10 changed files with 149 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue