Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to create table in MySQL using Doctrine and Symfony2

I am working with Symfony2 and Doctrine ORM using MySql .

After creating an Entity, I am not able to create the table. It throws an exception.

anu@anu-bridge:/var/www/Symfony$ php app/console doctrine:schema:update --force --dump-sql  [Doctrine\DBAL\Schema\SchemaException] The table with name 'product' already exists.    doctrine:schema:update [--complete] [--dump-sql] [--force] [--em[="..."]] 

I tried to drop it , but still it throws the error.

anu@anu-bridge:/var/www/Symfony$ php app/console doctrine:schema:drop --force Dropping database schema...  [Doctrine\DBAL\Schema\SchemaException]          The table with name 'product' already exists.    doctrine:schema:drop [--dump-sql] [--force] [--full-database] [--em[="..."]]  [Doctrine\DBAL\Schema\SchemaException]          The table with name 'product' already exists. 

There is no tables in the database. Cleared all the cache for symfony and doctrine, but still the error is throwing.

Symfony2 version is 2.0.1 .

like image 243
Anu Avatar asked Sep 27 '11 07:09

Anu


1 Answers

I've had a similar problem. Most likely you have two entities named Category inside different Bundles. For instance:

src/Acme/SomeBundle/Entity/Product.php src/Acme/OtherBundle/Entity/Product.php 

Comment one of these files and retry the console command.

like image 109
Federico Cristina Avatar answered Sep 20 '22 21:09

Federico Cristina