symfony 1.4:doctrine:build-sql问题
问题描述:
我犯了一个错误,在我的模式中定义一个名为desc
的列,它是一个保留关键字。我很快意识到自己的错误并改变了我的模式,将我的模式列名修改为description
。symfony 1.4:doctrine:build-sql问题
现在,当我运行doctrine:build --all
或doctrine: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;
答
doctrine:build-sql
根据生成的模型(php类)生成SQL。您需要先使用doctrine:build-model
重新生成模型。
您是否在您的schema.yml
中有其他desc
字段?您是否尝试清空文件夹cache
?你能粘贴你的schema.yml
吗?
desc
字段仍然在您生成的模型(PHP文件)?
编辑:
另外一个根本的解决办法:
- 清空
schema.yml
- 运行
doctrine:clean-model-files
清理所有的旧模式 - 把你的新
schema.yml
(修正后的) - 重新运行
doctrine:build --all
我试了两种方式:教条:建模 - 然后教条:建立 - 的SQL,然后教条:建立 - 所有,它以正确的顺序做一切。这两种方式仍旧会导致生成的sql与旧的错误。我的php生成的模型也包含错误,除了修改的列以外还有一个“desc”字段;即我的php模型中有两列,而在我的模式中,我只有一列。我也试着用教条清理我的模型:clean-model-files,它没有找到任何清理的东西。我将在我的原始问题中发布我的模式,但它非常简单。 – Patrick
我会试一试...支持。 – Patrick
我觉得很愚蠢。感谢你的建议,它让我想到了答案。当我清空原始模式,然后尝试清理模型文件时,结果显示“找不到需要删除的任何文件”。之后的解决方案变得很明显:我正在复制并重命名旧的模式文件作为备份,并将其放在相同的config/doctrine文件夹中。没有意识到放置在该文件夹中的所有内容都会尝试运行。我将旧文件移除到不同的目录并重新运行构建命令。问题解决了。谢啦。 – Patrick