dongtang1909 2017-09-01 13:00
浏览 66
已采纳

如何在Symfony 3 / Doctrine中重命名表?

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?

  • 写回答

3条回答 默认 最新

  • duandi5328 2017-09-01 13:06
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目
  • ¥15 利用pthon计算薄膜结构的光导纳
  • ¥15 海康hlss视频流怎么播放
  • ¥15 Paddleocr:out of memory error on GPU