doctrine:migrations:refresh command does not work on reserved MySQL keywords
fsasvari opened this issue · 1 comments
fsasvari commented
When I try to run "doctrine:migrations:refresh", the following error occurs:
Doctrine\DBAL\Exception\SyntaxErrorException : An exception occurred while executing 'DROP TABLE order':
SQLSTATE[42000]: Syntax error or access violation: 1064 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 'order' at line 1
The problem occurs when trying to drop a table which has some of the reserved MySQL keywords like ORDER.
When you look at src/Console/ResetCommand.php
, line 91:
$schema->dropTable($table);
The problem is solved if you put quotes ` between $table variable:
https://i.imgur.com/r9E8yz0.png
Is there any other solution to the problem or a possible fix?
laurentvd commented
You can specify the name of the column in your annotations or mapping files. Inside the name you can put the backticks to escape it like so:
/**
* @ORM\Column(type="string", name="`order`")
*/