summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-14 09:37:45 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-14 11:43:15 +0200
commit4a756cbc383bdefb683f03a0d40c0d0630ba3f60 (patch)
treeba583ca3ac3d10a891111b15e24d58f08f92e89c /django
parent4a263af64e10319f70205cd7d993fc86ef3d4468 (diff)
[3.0.x] Fixed #30870 -- Fixed showing that RunPython operations are irreversible by migrate --plan.
Thanks Hasan Ramezani for the initial patch and Kyle Dickerson for the report. Backport of 06d34aab7cfb1632a1538a243db81f24498525ff from master
Diffstat (limited to 'django')
-rw-r--r--django/core/management/commands/migrate.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/django/core/management/commands/migrate.py b/django/core/management/commands/migrate.py
index 37914e2622..5b964c41ae 100644
--- a/django/core/management/commands/migrate.py
+++ b/django/core/management/commands/migrate.py
@@ -343,21 +343,21 @@ class Command(BaseCommand):
def describe_operation(operation, backwards):
"""Return a string that describes a migration operation for --plan."""
prefix = ''
+ is_error = False
if hasattr(operation, 'code'):
code = operation.reverse_code if backwards else operation.code
- action = code.__doc__ if code else ''
+ action = (code.__doc__ or '') if code else None
elif hasattr(operation, 'sql'):
action = operation.reverse_sql if backwards else operation.sql
else:
action = ''
if backwards:
prefix = 'Undo '
- if action is None:
+ if action is not None:
+ action = str(action).replace('\n', '')
+ elif backwards:
action = 'IRREVERSIBLE'
is_error = True
- else:
- action = str(action).replace('\n', '')
- is_error = False
if action:
action = ' -> ' + action
truncated = Truncator(action)