Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
if [ -z $1 ]; then
echo "Usage: $0 app_label"
exit 1
app=$1 # this is the name of the app where we want to update the last migration
# get the list of known migrations for the app
migrations=(`./ migrate -l $app | awk '{print $2}' | tail -2`)
if [ ${#migrations[@]} == 1 ]; then
# there is just one migration in the list
# here we are updating the initial migration
current_migration=${migrations[0]} # should be 0001_initial
# there is more than one migration in the list
# get the previous one to go back to
# and the current one to update
# go back to the previous migration
./ migrate $app $previous_migration
# remove the current, outdated migration
rm $app/migrations/${current_migration}.*
# create a new migration
./ makemigrations $app
# migrate the DB to the new migration
./ migrate $app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.