Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
def handle(self, *app_labels, **options):
# Generate a migrations manifest with latest migration on each app
super(Command, self).handle(*app_labels, **options)
loader = MigrationLoader(None, ignore_no_migrations=True)
apps = sorted(loader.migrated_apps)
graph = loader.graph
with open('latest_migrations.manifest', 'w') as f:
for app_name in apps:
leaf_nodes = graph.leaf_nodes(app_name)
if len(leaf_nodes) != 1:
raise Exception('App {} has multiple leaf migrations!'.format(app_name))
f.write('{}: {}\n'.format(app_name, leaf_nodes[0][1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment