Does Django use south (migration tool) for innodb?

$ py manage.py  migrate turkey
Running migrations for turkey:
 - Migrating forwards to 0001_initial.
 > turkey:0001_initial
 ! Error found during real run of migration! Aborting.

 ! Since you have a database that does not support running
 ! schema-altering statements in transactions, we have had 
 ! to leave it in an interim state between migrations.

! You *might* be able to recover with:   = DROP TABLE `turkey_demorecs` CASCADE; []

 ! The South developers regret this has happened, and would
 ! like to gently persuade you to consider a slightly
 ! easier-to-deal-with DBMS.
 ! NOTE: The error which caused the migration to fail is further up.

For some reason, I get this when I try. But my other settings are in MyISAM.

Why doesn't he work at Innodb?

+5
source share
4 answers

InnoDB has foreign key restrictions that ensure that you do not violate the database model when performing the migration. (see http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html )

MyISAM does not have built-in support for restrictions (although it seems that you can implement this if you decide to do http://dev.mysql.com/tech-resources/articles/mysql-enforcing-foreign-keys.html )

MyISAM FK, . InnoDB , , .

+4

. https://code.djangoproject.com/wiki/AlterModelOnSyncDB

mysql, - MyISAM, InnoDB ( , , post_syncdb ). MyISAM, . , InnoDB , , MyISAM; , : -/

InnoDB, MyISAM, :

# add at the beginning of your migration
if db.backend_name == 'mysql':
   db.execute('SET storage_engine=INNODB')

:

# add this to settings.py
DATABASE_OPTIONS = {
   "init_command": "SET storage_engine=INNODB", # XXX: performance hit...
}
+3

, InnoDB. "" , 0001_initial? PS: , .

rm -fr app/migrations/*
./manage.py schemamigration app --initial
./manage.py migrate app
+1

:

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

.

1, .

, , 0 1 , SQL , .

+1

All Articles