summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2013-05-30 17:56:26 +0100
committerAndrew Godwin <andrew@aeracode.org>2013-05-30 17:56:26 +0100
commitdfa7c5cade318ce113a95e12cae47c446604e993 (patch)
tree89f5cacd11e0a64500c80efa5c7444c7cb85e418
parent05929ee89bc51de772343d18d5a7bf2518d41333 (diff)
Allow retrieval of project state at start of migrations
-rw-r--r--django/db/migrations/graph.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/migrations/graph.py b/django/db/migrations/graph.py
index 8e2446ca99..620534bc22 100644
--- a/django/db/migrations/graph.py
+++ b/django/db/migrations/graph.py
@@ -120,11 +120,14 @@ class MigrationGraph(object):
def __str__(self):
return "Graph: %s nodes, %s edges" % (len(self.nodes), sum(len(x) for x in self.dependencies.values()))
- def project_state(self, node):
+ def project_state(self, node, at_end=True):
"""
Given a migration node, returns a complete ProjectState for it.
+ If at_end is False, returns the state before the migration has run.
"""
plan = self.forwards_plan(node)
+ if not at_end:
+ plan = plan[:-1]
project_state = ProjectState()
for node in plan:
project_state = self.nodes[node].mutate_state(project_state)