Skip to content

Instantly share code, notes, and snippets.

@andyzinsser
Created November 14, 2013 05:55
Show Gist options
  • Save andyzinsser/7462107 to your computer and use it in GitHub Desktop.
Save andyzinsser/7462107 to your computer and use it in GitHub Desktop.
Example of walking through app south migration history. While trying to solve some migration issues from renaming multiple models at once, I delete a few tables in an attempt to resolve my issues. That only caused more problems. Probably would have been better off to rename one model, then rename the other. Regardless, this got everything back u…
# Gets both apps with relating models back to square one.
python manage.py migrate APP_1 zero
python manage.py migrate APP_2 zero
# At this point, there were models in APP_1 initial migration that no longer existed.
# So I couldn't just run all the APP_1 migrations at once
# Step through history
python manage.py migrate APP_1 0001
python manage.py migrate APP_2 0001
python manage.py migrate APP_1 0002
python manage.py migrate APP_1 0003
# ... Repeat but increment the migration number until you start getting missing field errors from APP_2
# Get APP_2 models to create the fields that APP_1 is looking for
python manage.py migration APP_2 0002
python manage.py migration APP_2 0003
# ... Repeat but increment the migration number until you start getting missing field errors from APP_1
# Then just repeat that back and forth until all migration have been run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment