mirror of https://github.com/django/django.git
Allow retrieval of project state at start of migrations
This commit is contained in:
parent
05929ee89b
commit
dfa7c5cade
|
@ -120,11 +120,14 @@ class MigrationGraph(object):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Graph: %s nodes, %s edges" % (len(self.nodes), sum(len(x) for x in self.dependencies.values()))
|
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.
|
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)
|
plan = self.forwards_plan(node)
|
||||||
|
if not at_end:
|
||||||
|
plan = plan[:-1]
|
||||||
project_state = ProjectState()
|
project_state = ProjectState()
|
||||||
for node in plan:
|
for node in plan:
|
||||||
project_state = self.nodes[node].mutate_state(project_state)
|
project_state = self.nodes[node].mutate_state(project_state)
|
||||||
|
|
Loading…
Reference in New Issue