From 202bf69c2f69d9ee20ac3fd409116a8946dc0784 Mon Sep 17 00:00:00 2001 From: Andrew Gorcester Date: Wed, 19 Feb 2014 15:44:57 -0800 Subject: 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. --- django/db/migrations/operations/special.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'django') 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. -- cgit v1.3