我在symfony项目中运行php app/console doctrine:schema:update --force
时遇到错误,我收到以下错误:
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'DROP INDEX idx-id ON extra':
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-id ON extra' at line 1
[Doctrine\DBAL\Driver\Mysqli\MysqliException]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-id ON extra' at line 1
这是生成的sql,它给出了错误:
DROP INDEX idx-id ON extra
错误是索引名称没有用“`”包装, 我怎么能得到它所以索引名称总是用“`”包裹?
答案 0 :(得分:1)
这是一个design decision:
出于兼容性原因,所有受支持的供应商和边缘案例问题之间,Doctrine 2 NOT 执行自动标识符引用。当试图让遗留数据库与Doctrine 2一起使用时,这可能会导致问题。
假设您现在让Doctrine为您的索引命名,我的建议是手动重命名(或删除)索引,然后运行架构更新。