2012-07-03 39 views
0

我犯了一個錯誤,在我的模式中定義一個名爲desc的列,它是一個保留關鍵字。我很快意識到自己的錯誤並改變了我的模式,將我的模式列名修改爲descriptionsymfony 1.4:doctrine:build-sql問題

現在,當我運行doctrine:build --alldoctrine:build-sql它仍然基於我以前的錯誤生成sql。

我驗證了這一點,因爲它仍在生成語句中的desc的sql語句,該語句自從被刪除之後。我清除了緩存,刪除了原始的sql文件,並清除了我的日誌。

世界如何是doctrine:build-sql產生一個完全刪除和刪除的錯誤?我該如何糾正這個問題?

很明顯,直到我可以修復它,doctrine:build被打破。

編輯:

這裏是我的原始模式:

ReasonCode: 
    columns: 
    id:   { type: integer, primary: true, notnull: true, autoincrement: true, unique: true } 
    desc: { type: string } 

RejectionCode: 
    columns: 
    id:   { type: integer, primary: true, notnull: true, autoincrement: true, unique: true } 
    desc: { type: string } 

ConsiderationCode: 
    columns: 
    id:   { type: integer, primary: true, notnull: true, autoincrement: true, unique: true } 
    desc: { type: string } 

,這裏是我的修訂方案:

ReasonCode: 
    columns: 
    id:   { type: integer, primary: true, notnull: true, autoincrement: true, unique: true } 
    name: { type: string } 

RejectionCode: 
    columns: 
    id:   { type: integer, primary: true, notnull: true, autoincrement: true, unique: true } 
    name: { type: string } 

ConsiderationCode: 
    columns: 
    id:   { type: integer, primary: true, notnull: true, autoincrement: true, unique: true } 
    name: { type: string } 

這裏的生成生成的SQL模式每次:

CREATE TABLE consideration_code (id BIGINT UNIQUE AUTO_INCREMENT, desc TEXT, name TEXT, PRIMARY KEY(id)) ENGINE = INNODB; 
CREATE TABLE reason_code (id BIGINT UNIQUE AUTO_INCREMENT, desc TEXT, name TEXT, PRIMARY KEY(id)) ENGINE = INNODB; 
CREATE TABLE rejection_code (id BIGINT UNIQUE AUTO_INCREMENT, desc TEXT, name TEXT, PRIMARY KEY(id)) ENGINE = INNODB; 

回答

1

doctrine:build-sql根據生成的模型(php類)生成SQL。您需要先使用doctrine:build-model重新生成模型。

您是否在您的schema.yml中有其他desc字段?您是否嘗試清空文件夾cache?你能粘貼你的schema.yml嗎?

desc字段仍然在您生成的模型(PHP文件)?

編輯:

另外一個根本的解決辦法:

  1. 清空schema.yml
  2. 運行doctrine:clean-model-files清理所有的舊模式
  3. 把你的新schema.yml(修正後的)
  4. 重新運行doctrine:build --all
+0

我試了兩種方式:教條:建模 - 然後教條:建立 - 的SQL,然後教條:建立 - 所有,它以正確的順序做一切。這兩種方式仍舊會導致生成的sql與舊的錯誤。我的php生成的模型也包含錯誤,除了修改的列以外還有一個「desc」字段;即我的php模型中有兩列,而在我的模式中,我只有一列。我也試着用教條清理我的模型:clean-model-files,它沒有找到任何清理的東西。我將在我的原始問題中發佈我的模式,但它非常簡單。 – Patrick

+0

我會試一試...支持。 – Patrick

+0

我覺得很愚蠢。感謝你的建議,它讓我想到了答案。當我清空原始模式,然後嘗試清理模型文件時,結果顯示「找不到需要刪除的任何文件」。之後的解決方案變得很明顯:我正在複製並重命名舊的模式文件作爲備份,並將其放在相同的config/doctrine文件夾中。沒有意識到放置在該文件夾中的所有內容都會嘗試運行。我將舊文件移除到不同的目錄並重新運行構建命令。問題解決了。謝啦。 – Patrick