Created
July 5, 2016 06:30
-
-
Save pelme/4b3dac475cd6b1dec4fd67d25d2e7cdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -* | |
from __future__ import print_function, division, absolute_import, unicode_literals | |
import hashlib | |
import inspect | |
def main(): | |
import django | |
django.setup() | |
from django.db.migrations.loader import MigrationLoader | |
loader = MigrationLoader(None) | |
disk_migrations = sorted(loader.disk_migrations.items()) | |
h = hashlib.sha1() | |
h.update(django.get_version()) | |
for (app_name, migration_name), migration_cls in disk_migrations: | |
h.update(app_name) | |
h.update(migration_name) | |
h.update(inspect.getsource(inspect.getmodule(migration_cls))) | |
print(h.hexdigest()) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment