6
votes

I have a few projects with lots of South migrations, including ones that contain a fair amount of custom SQL that need to be run in a specific order. After upgrading to Django 1.7, this is the recommendation on how to convert a project to use South (from the Django documentation):

If you already have pre-existing migrations created with South, then the upgrade process to use django.db.migrations is quite simple:

  • Ensure all installs are fully up-to-date with their migrations.
  • Remove 'south' from INSTALLED_APPS.
  • Delete all your (numbered) migration files, but not the directory or __init__.py - make sure you remove the .pyc files too.
  • Run python manage.py makemigrations. Django should see the empty migration directories and make new initial migrations in the new format.
  • Run python manage.py migrate. Django will see that the tables for the initial migrations already exist and mark them as applied without running them.

In short, "wipe your existing migrations and Django will take care of the rest".

What is not mentioned here is what to do when existing South migrations don't only consist of model changes, but instead contain direct SQL, data migrations, etc, that need to be run in order. In this case, the auto-generated Django migrations will miss a lot of things, since not all of these changes are obvious from introspecting a models file.

Ideally, one would be able to run the existing migrations using South, and then have Django migrations take over. What might be the best way to go about this? If this is not possible or very much not recommended, what is the best alternative?

1
You mean your migrations can't just be scrapped after you're sure they have been run on all installations? Are you using them for supplying a fresh installation with initial data or something else?Kos

1 Answers

3
votes

Maybe this post can help you. Essentially you have to:

  1. Change your current migration directory from 'migrations' to 'south_migrations'
  2. Update your settings with this line

    SOUTH_MIGRATION_MODULES = { 'your_app': 'your_project.your_app.south_migrations', }