Does Django's south (migration tool) work for innodb?

后端 未结 4 1049
余生分开走
余生分开走 2021-01-01 04:39
$ py manage.py  migrate turkey
Running migrations for turkey:
 - Migrating forwards to 0001_initial.
 > turkey:0001_initial
 ! Error found during real run of migr         


        
4条回答
  •  鱼传尺愫
    2021-01-01 05:24

    You could try adding to your first migration:

    if db.backend_name == 'mysql':
        db.execute('SET foreign_key_checks=0')
    

    This will disable the foreign key check constraints.

    You don't have to set it back to 1 since it's a session variable.

    By the way, it doesn't work if you set to 0 at the beggining and back to 1 at the end of your migration method, because south generates SQL with them, but executes it when they return.

提交回复
热议问题