“PHP应用程序/控制台学说:架构:更新--force”给出了一个语法错误

问题描述:

,当我在一个symfony项目运行php app/console doctrine:schema:update --force我有一个错误,我得到以下错误:“PHP应用程序/控制台学说:架构:更新--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 

错误是索引名不包裹“`”, 我怎么能得到它,因此指数名称始终包裹着“`”?

这是一个design decision

For compatibility reasons between all the supported vendors and edge case problems Doctrine 2 does NOT do automatic identifier quoting. This can lead to problems when trying to get legacy-databases to work with Doctrine 2.

假设你现在让学说名称索引时,我的建议是手动重命名(或下降)的指数,然后运行架构更新。