$ 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.由于某种原因,当我尝试它的时候,我得到了这个。但我的其他设置是在MyISAM中的。
为什么它在Innodb中不起作用?
发布于 2011-10-28 01:03:19
InnoDB对外键有限制,这可以确保您在进行迁移时不会破坏数据库模型。(参见http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html)
MyISAM不具有对约束的本机支持(尽管如果您选择执行http://dev.mysql.com/tech-resources/articles/mysql-enforcing-foreign-keys.html,似乎可以实现这一点)
由于MyISAM不会检查FK关系,因此不会出现错误。然而,InnoDB正在进行检查,您的迁移似乎有问题。
发布于 2011-08-26 06:25:56
另请参阅https://code.djangoproject.com/wiki/AlterModelOnSyncDB
当我使用默认表格存储引擎是MyISAM的mysql安装程序时,我也遇到了类似的错误,我想使用InnoDB (使用上面链接中找到的方法,我们使用post_syncdb信号来触发转换代码)。然而,当使用South创建新表时,它们首先是使用MyISAM引擎创建的,然后再进行转换。当这些表实际上是MyISAM时,我错误地认为InnoDB表没有做它们应该做的事情;因为表是由信号转换的,所以任何迁移错误都将无法取消应用:-/
如果您需要使用或创建缺省值为MyISAM的InnoDB表,可以通过以下方法解决:
# 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...
}发布于 2011-01-29 09:45:20
是的,南方确实支持InnoDB。您可以删除"migrations“文件夹中的内容,然后重新运行模式迁移,迁移并在此处发布0001_initial文件的结果和内容吗?PS:确保你已经备份了你的迁移文件夹,或者首先在源代码控制中。
rm -fr app/migrations/*
./manage.py schemamigration app --initial
./manage.py migrate apphttps://stackoverflow.com/questions/4834415
复制相似问题