Skip to content

Instantly share code, notes, and snippets.

@kaizoku
Created January 8, 2019 06:25
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 kaizoku/834272cec7feb5df3d35f93472854677 to your computer and use it in GitHub Desktop.
Save kaizoku/834272cec7feb5df3d35f93472854677 to your computer and use it in GitHub Desktop.
rollback migrations to hawthorn
#!/bin/bash
shopt -s globstar
MIGRATIONS=$(git diff --name-only open-release/hawthorn.1 master **/migrations)
APPNAMES=$(
for MIGRATION in $MIGRATIONS
do
basename $(dirname $(dirname $MIGRATION))
done|sort|uniq
)
for APP in $APPNAMES
do
LAST_MIGRATION=$(git ls-tree -r open-release/hawthorn.1 --name-only|egrep $APP/migrations/'[0-9]+_'|tail -n1)
LAST_MIGRATION=$(basename $LAST_MIGRATION)
/edx/bin/{python,manage}.ecommerce migrate $APP ${LAST_MIGRATION//.py}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment