1
我有一個空白的MySQL數據庫,我剛剛創建。 south
在我的INSTALLED_APPS
。爲什麼南遷移失敗?
我運行:
$ ./manage.py syncdb
...
Creating table some_app_table
You just installed Django's auth system, which means you don't have any superusers defined.
...
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
Synced:
> django.contrib.auth
> django.contrib.contenttypes
...
Not synced (use migrations):
- myapp
...
$ ./manage.py schemamigration myapp --initial
+ Added model myapp.Model
...
Created 0003_initial.py. You can now apply this migration with: ./manage.py migrate myapp
$ ./manage.py migrate myapp
Running migrations for myapp:
- Migrating forwards to 0003_initial.
> skan:0001_initial
> skan:0002_initial
FATAL ERROR - The following SQL query failed: CREATE TABLE `myapp_model` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `user_id` integer NULL, `name` varchar(200) NOT NULL);
The error was: (1050, "Table 'myapp_model' already exists")
這是怎麼回事?爲什麼不能正確初始化?
'--initial'應該只用於創建初始表;你已經創建了一個表myapp_model。 – geoffspear
如果可能,重新創建數據庫並再次運行 - 初始遷移,而不運行syncdb – Mikael
@Wooble在我運行該命令之前,表不存在,我進行了雙重檢查 – fredley