2013-01-25 137 views
1

任何人都可以解釋這個錯誤給我試圖使用sudo python manage.py migrate核心。謝謝。django南錯誤遷移失敗

(django-env)pc-03:Ares user$ sudo python manage.py migrate core 
Running migrations for core: 
- Migrating forwards to 0001_initial. 
> core:0001_initial 
FATAL ERROR - The following SQL query failed: CREATE TABLE `country` (`countryID` varchar(255) NOT NULL PRIMARY KEY, `abbreviation` varchar(15) NOT NULL, `name` varchar(105) NOT NULL, `prefix` varchar(15) NOT NULL, `active` longtext NOT NULL, `created` datetime NULL, `modified` datetime NULL); 
The error was: (1050, "Table 'country' 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 `country` CASCADE; [] 
    = DROP TABLE `company` CASCADE; [] 
    = DROP TABLE `campaign` CASCADE; [] 
    = DROP TABLE `redemptionMethod` CASCADE; [] 
    = DROP TABLE `incentiveCost` CASCADE; [] 
    = DROP TABLE `incentive` CASCADE; [] 
    = DROP TABLE `recipient` CASCADE; [] 
    = DROP TABLE `code` CASCADE; [] 
    = DROP TABLE `redeemed` 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: core:0001_initial 

回答

4

錯誤是不言自明的:「表」國家'已經存在「,這意味着你已經在數據庫中創建了表」國家「。爲了避免這種情況,您可以將初始遷移運行爲假:

sudo python manage.py migrate core --fake 
+0

謝謝您我不確定是否因爲某種原因試圖放棄這些花費。謝謝 – Prometheus

+1

如果該表不包含有用數據,則可以在遷移之前手動將其刪除。 –

+0

好奇,@惠正 - 如果你可以完全放下桌子,你爲什麼會遷移?遷移的整個目的不是維護具有不推薦使用結構數據的數據結構嗎? – jdero