What is the recommended way to start southern migrations before migrating Django 1.7?

I have several projects with a large number of southern migrations, including those that contain a sufficient number of custom SQL that need to be run in a specific order. After upgrading to Django 1.7, this is a recommendation on how to convert a project to use south (from the Django documentation ):

If you already have pre-created migrations created using South, then the upgrade process for using django.db.migrations is quite simple:

  • Make sure all installations are fully updated with their migrations.
  • Remove the south with INSTALLED_APPS.
  • Delete all your (numbered) migration files, but not the directory or __init__.py - make sure you delete the .pyc files as well.
  • Run python manage.py makemigrations. Django should see empty migration directories and make new initial migrations in a new format.
  • Run python manage.py migrate. Django will see that tables for initial migrations already exist and mark them as applicable without starting them.

In short, "erase existing migrations, and Django takes care of the rest."

What is not mentioned here is what needs to be done when existing south migrations not only consist of model changes, but instead contain direct SQL, data migration, etc. that need to be run in order. In this case, the automatically generated Django migrations will skip a lot of things, since not all of these changes are obvious due to the introspection of the model file.

Ideally, you could use existing migrations using the South, and then migrate Django migrations. What could be the best way to do this? If this is not possible or highly discouraged, what is the best alternative?

+6
source share
1 answer

Perhaps this post may help you. Essentially you should:

  • Change the current migration directory from 'migrations' to 'south_migrations'
  • Update your settings with this line

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

+3
source

Source: https://habr.com/ru/post/974853/


All Articles