mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
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.
This commit is contained in:
committed by
Baptiste Mispelon
parent
b887408486
commit
202bf69c2f
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user