在现有数据库上安装South的问题. MySql不支持’模式更改语句’
作者:互联网
我有一个带有现有数据库的django项目,我真的想避免转储或中断.我正在尝试安装South但是当我运行我的初始迁移python manage.py migrate示例时,我收到以下错误:
Running migrations for example:
- Migrating forwards to 0001_initial.
> example: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 `example_page` CASCADE; []
= DROP TABLE `example_likebydate` CASCADE; []
= DROP TABLE `example_followbydate` 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.
Traceback (most recent call last):
...
File "/usr/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1050, "Table 'example_page' already exists")
因此,显而易见的解决方案是运行给定的SQL,但我不知道它会做什么,如果它将丢弃表并丢失我的数据,则不想运行它.
在不丢失数据的情况下,我可以选择使这个南迁移工作吗?
解决方法:
如果您的架构已经使用了用于创建0001_inital.py的models.py,那么您应该使用–fake运行初始迁移,以实质上告诉您已经处于架构的版本0001.
标签:mysql,django,django-south 来源: https://codeday.me/bug/20190610/1210319.html