Skip to content

Instantly share code, notes, and snippets.

@pelme
Created July 5, 2016 06:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pelme/4b3dac475cd6b1dec4fd67d25d2e7cdc to your computer and use it in GitHub Desktop.
Save pelme/4b3dac475cd6b1dec4fd67d25d2e7cdc to your computer and use it in GitHub Desktop.
# -*- 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