Skip to content

Instantly share code, notes, and snippets.

@jdunck
Created April 12, 2015 21:44
Show Gist options
  • Save jdunck/c707a9f5017fdfb4631a to your computer and use it in GitHub Desktop.
Save jdunck/c707a9f5017fdfb4631a to your computer and use it in GitHub Desktop.
Migrating to django 1.7 migrations
Scenario:
You have a long-running branch to upgrade your existing codebase to django 1.7.
You've previously used south, and your existing deployment includes schema changes since the
base of the django-1.7 upgrade branch.
You need to re-create django (core) migrations periodically since you can't merge
south migrations into core migrations.
(Assumes commands are run from root of project and that apps are top-level directories Adjust pathing if that is not the case.)
# delete all *.pyc and all non .py other than __init__.py in all migration directories:
find . -type f -ipath '*/migrations/*' \( -iname '*.pyc' -o \( -not -iname '__init__.py' \) \) -delete
# make migrations directories and packages so that `manage.py makemigrations`
# will activate from that app
find . -type d -maxdepth 1 | xargs -I{} mkdir {}/migrations
find . -type d -maxdepth 1 | xargs -I{} touch {}/migrations/__init__.py
# inspects your project and adds all marked apps.
python manage.py makemigrations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment