Skip to content

Instantly share code, notes, and snippets.

@rvause
Forked from alvinchow86/migration_manifest.py
Last active June 13, 2019 18:21
Show Gist options
  • Save rvause/0658e8ad65b3eb436498f9d17d69db50 to your computer and use it in GitHub Desktop.
Save rvause/0658e8ad65b3eb436498f9d17d69db50 to your computer and use it in GitHub Desktop.
django-tips-blog-migration-manifest
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)
with open("latest_migrations.manifest", 'w') as f:
f.write("\n".join(sorted(f"{a}: {m}" for a, m in loader.graph.leaf_nodes())))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment