summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
authorAndrew Gorcester <andrew.gorcester@gmail.com>2014-02-19 15:44:57 -0800
committerBaptiste Mispelon <bmispelon@gmail.com>2014-02-23 09:30:02 +0100
commit202bf69c2f69d9ee20ac3fd409116a8946dc0784 (patch)
tree288eebf79d7982677fa230d349db7639b8dccdcb /django/db
parentb8874084868080baff29ac3453d20a845fd1568c (diff)
Fixed #22095 -- Enabled backward migrations for RunPython operations
Added reversible property to RunPython so that migrations will not refuse to reverse migrations including RunPython operations, so long as reverse_code is set in the RunPython constructor. Included tests to check the reversible property on RunPython and the similar RunSQL.
Diffstat (limited to 'django/db')
-rw-r--r--django/db/migrations/operations/special.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/migrations/operations/special.py b/django/db/migrations/operations/special.py
index 714a6d59f9..40ae1f85b7 100644
--- a/django/db/migrations/operations/special.py
+++ b/django/db/migrations/operations/special.py
@@ -103,7 +103,6 @@ class RunPython(Operation):
"""
reduces_to_sql = False
- reversible = False
def __init__(self, code, reverse_code=None):
# Forwards code
@@ -118,6 +117,10 @@ class RunPython(Operation):
raise ValueError("RunPython must be supplied with callable arguments")
self.reverse_code = reverse_code
+ @property
+ def reversible(self):
+ return self.reverse_code is not None
+
def state_forwards(self, app_label, state):
# RunPython objects have no state effect. To add some, combine this
# with SeparateDatabaseAndState.