I want to change a table from order
to shop_order
. First I alter the table name in phpmyadmin.
Furthermore I would have guessed, that changing the annotations would be sufficient:
/**
* Order
*
* @ORM\Table(name="shop_order")
* @ORM\Entity
*/
class Order { ...
But when running
php bin/console doctrine:schema:update --dump-sql
It tries to create the table again:
CREATE TABLE `order` (id INT AUTO_INCREMENT NOT NULL ...
Is there any other file I need to change?
Clear the cache and try to alter the table name back with phpMyAdmin again. Once it is order
again then use the doctrine command:
php bin/console doctrine:schema:update --dump-sql
If you want Doctrine to execute the changes then add --force
as well.
Also check your Doctrine configuration, it could be that is caching the metadata somewhere else (e.g. Memcache). You might need to clear that as well.
Doctrine caches on three levels: query cache, metadata cache and result cache. You may want to take a look at the metadata one.
doctrine:
orm:
auto_mapping: true
# each caching driver type defines its own config options
metadata_cache_driver: apc
result_cache_driver:
type: memcache
host: localhost
port: 11211
instance_class: Memcache
# the 'service' type requires to define the 'id' option too
query_cache_driver:
type: service
id: my_doctrine_common_cache_service
So, if for example yours is set to Memcache then you'll have to reset Memcache as well.
Take a look at the docs here.
try to use force
, like this:
php bin/console doctrine:schema:update --force --dump-sql
And delete the cache please
If It doesn't work I advise you to use migration because seems tha doctrine doesn't recognize the change of the table name:
up(
) and down()
methods and replace them with custom SQL (ALTER TABLE ... RENAME TO ...).Migration docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With