"php app/console doctrine:schema:update --force" gives a syntax error

898 views Asked by At

I have an error when I run php app/console doctrine:schema:update --force in a symfony project and i get the following error:

[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 

This is the generated sql that gives the error:

DROP INDEX idx-id ON extra

The error is that the index name is not wrapped with "`" , how can I get it so the index name is always wrapped with "`" ?

1

There are 1 answers

0
StuBez On BEST ANSWER

This is was a 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.

Assuming you're now letting Doctrine name your indexes, my suggestion would be to rename (or drop) the index manually and then run the schema update.