1
0
mirror of https://github.com/django/django.git synced 2025-10-28 16:16:12 +00:00

A bit of an autodetector and a bit of a writer

This commit is contained in:
Andrew Godwin
2013-06-07 15:28:38 +01:00
parent 3c296382b8
commit 4492f06408
5 changed files with 280 additions and 0 deletions

View File

@@ -15,6 +15,24 @@ class Operation(object):
# Some operations are impossible to reverse, like deleting data.
reversible = True
def __new__(cls, *args, **kwargs):
# We capture the arguments to make returning them trivial
self = object.__new__(cls)
self._constructor_args = (args, kwargs)
return self
def deconstruct(self):
"""
Returns a 3-tuple of class import path (or just name if it lives
under django.db.migrations), positional arguments, and keyword
arguments.
"""
return (
self.__class__.__name__,
self._constructor_args[0],
self._constructor_args[1],
)
def state_forwards(self, app_label, state):
"""
Takes the state from the previous migration, and mutates it