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条)

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来