Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doctrine:migrations:refresh command does not work on reserved MySQL keywords #87

Open
fsasvari opened this issue Sep 3, 2019 · 1 comment

Comments

@fsasvari
Copy link

fsasvari commented Sep 3, 2019

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?

@fsasvari fsasvari changed the title migrations:refresh does not work on reserved MySQL keywords doctrine:migrations:refresh command does not work on reserved MySQL keywords Sep 3, 2019
@laurentvd
Copy link

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`")
 */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants