Skip to content

Instantly share code, notes, and snippets.

@jdunck
Created October 17, 2011 16:41
Show Gist options
  • Save jdunck/1293038 to your computer and use it in GitHub Desktop.
Save jdunck/1293038 to your computer and use it in GitHub Desktop.
fabfile task to spot dupe-numbered south migrations
# this is intended to be run as part of a fab-suite, i.e. fab git_push, which runs tests, all files committed, etc. before pushing.
def ensure_no_duped_migrations():
migration_dirs = local('find %s -type d -iname migrations' % ROOT_DIR,
True).split('\n')
for migration_dir in migration_dirs:
full_migration_dir = path.join(ROOT_DIR, migration_dir)
# FIXME: for GNU find, need regextype=posix-extended
dupe_checker = ("find -E %s -iregex '.*/[0-9]{4,}[^/]*\.py' -exec basename {} ';'| cut -d_ -f1 | sort | uniq -d" %
full_migration_dir)
any_match = local(dupe_checker, True)
if any_match:
abort("""The %s dir has same-numbered migrations. Fix this.
Don't just renumber, see http://south.aeracode.org/docs/tutorial/part5.html#team-workflow""" %
migration_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment