2013-04-29 50 views
0

我正在從配置文件模型設置更改爲擴展用戶模型。我試圖根據this guide設置我的南遷。我有一個用戶參考模型中的其他幾個車型,所以當我自動生成我的架構遷移我相處的線線:alter_column遷移失敗,我關心嗎?

db.alter_column(u'app_model', 'user', 
    self.gf('django.db.models.fields.related.ForeignKey')(to=orm['app.user'])) 

的問題是這些遷移的原因南部打破當我嘗試遷移:

FATAL ERROR - The following SQL query failed: INSERT INTO "_south_new_app_model"() SELECT FROM "app_model"; 
The error was: near ")": syntax error 
! 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: 
! 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: app:0018_auto__chg_field_model_user.py 
DatabaseError: near ")": syntax error 

注:這是./manage.py schemamigration app --auto創建的遷移。我沒有編輯它。

事情是,我關心嗎?存儲在數據庫中的引用類型是相同的,我已經完成了重命名錶的步驟。如果我從遷移中刪除alter_table行,似乎所有東西都會繼續工作。這是一個可怕的,可怕的想法,還是可以嗎?

+0

你在使用什麼數據庫引擎?我認爲是的,當有錯誤時,您應該始終關心。也許它現在的作品,但後來有明星出現的錯誤,你甚至不記得你忽略了過去的錯誤:) – 2013-04-29 15:31:14

+0

@Paulo這只是在一個測試數據庫運行sqlite3(我猜是一部分問題)。我的生產數據庫是MySQL。我可以用另一個mysql實例進行測試,但如果可能的話,我寧願避免它。 – fredley 2013-04-29 15:55:45

回答

1

Sqlite3是問題所在。您可能會看到here,sqlite3僅支持alter table操作的有限子集,因此導致South無法執行遷移。如果你需要這樣做,你必須將測試數據庫移植到另一個支持alter table的引擎。我建議,有時遷移可能會非常棘手,您可能認爲它正在工作,但總是更好地測試它。

如果您認爲工作正常,那麼請繼續,忽略錯誤,但請注意,它現在可能正在工作,但也許遷移沒有成功,稍後您會在開發環境中發現與數據庫相關的奇怪錯誤。