2015-01-05 81 views
0

我在尝试使用南迁移到django时遇到了以下错误。django-south迁移期间的错误

Running migrations for sites: 
    - Migrating forwards to 0004_initial. 
    > sites:0002_initial 
    FATAL ERROR - The following SQL query failed: CREATE TABLE `django_site` (`id` 
    nteger AUTO_INCREMENT NOT NULL PRIMARY KEY, `domain` varchar(100) NOT NULL, `na 
    e` varchar(50) NOT NULL) 
    The error was: (1050, "Table 'django_site' already exists") 
    ! 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 `django_site` CASCADE; [] 

! The South developers regret this has happened, and would 
! like to gently persuade you to consider a slightly 
! easier-to-deal-with DBMS (one that supports DDL transactions) 
! NOTE: The error which caused the migration to fail is further up. 
Error in migration: sites:0002_initial 
Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
    ............. 

    django.db.utils.OperationalError: (1050, "Table 'django_site' already exists") 

类似的问题也打开here。任何解决方法?该错误似乎是由于在github问题中讨论的Create table语句,或者可能存在其他错误。我找不到它。

+0

你在“干净”的数据库上运行这个吗? SQL错误告诉你,你已经有一个表'django_site'。 – vicvicvic

+0

你有没有看到链接...是的,我正在运行'干净'db –

+1

是的,我看到了链接。这不是同一个问题。你得到的SQL错误“表'django_site'已经存在”,所以出于某种原因表已经存在。 – vicvicvic

回答

1

如果Django的版本< 1.7

python manage.py migrate yourapp --fake 

其他

python manage.py migrate --fake 

--fake:记录迁移序列已被应用,但实际上并没有运行。 - >more