Search code examples
mysqldjangodjango-southdata-integrity

If I run a migration with Django South and it crashes, is my database ever corrupted?


I'm playing around with Django South, and have been impressed by it's power, but in the process of doing some migrations, I've managed to do things that cause errors in the middle of migrations. Things like having a syntax error or run time exception in a data migration file, deciding I didn't want to actually do something and hitting ctrl-c during a migration and aborting prematurely, etc.

I'm using MySQL as a database backend. Do I need to worry about the integrity of my database when something goes wrong with South? Do transactions ensure that all problems are rolled back on error?


Solution

  • The database should rollback nicely:

    http://south.aeracode.org/docs/migrationstructure.html#transactions

    Anyway, can't you just check the db tables?

    A couple of notes:

    • You can print the existing migrations with

      manage.py migrate --list

      This also shows which migrations have been applied

    • You can also manually rollback to a previous migration using

      manage.py migrate <app_name> 0010

      where 10 is the last safe migration

    Hope this helps