1

尝试使用 sudo python manage.py migrate core 时,谁能向我解释这个错误。谢谢你。

(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

1 回答 1

4

错误是不言自明的:“表 'country' 已经存在”,这意味着您已经在数据库中创建了表 'country'。为避免这种情况,您可以将初始迁移作为假运行:

sudo python manage.py migrate core --fake
于 2013-01-25T12:49:46.980 回答