【问题标题】:Is there a way to tell doctrine not to touch specific tables?有没有办法告诉教义不要碰特定的表格?
【发布时间】:2020-10-16 00:02:26
【问题描述】:

每次我运行 doctrine:migrations:diff 来为我的更改生成迁移时,它总是包括删除一些不由学说处理的表,例如:

$this->addSql('DROP TABLE messenger_messages');
$this->addSql('DROP TABLE monitoring');

有没有办法告诉教义特定的表不属于他,所以教义不会每次都尝试删除它们?

【问题讨论】:

    标签: symfony doctrine-orm doctrine


    【解决方案1】:

    您可以在文档中找到答案:https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html#manual-tables

    简答:为您的自定义表格添加前缀,然后配置此前缀(例如,如果您的自定义表格以 't_' 开头):

    doctrine:
        dbal:
            schema_filter: ~^(?!t_)~
    

    【讨论】:

      【解决方案2】:

      您可以使用正则表达式从教义视野中排除表格。 要指定学说不应涉及的表列表,只需将其添加到配置中:

      doctrine:
        dbal:
          schema_filter: ~^(?!(messenger_messages|monitoring|foo|bar)$)~
      

      这将防止教义操纵这四个表:

      • messenger_messages
      • 监控
      • 酒吧

      感谢@Diabetic Nephropathy 用正则表达式提示方法。

      【讨论】:

        猜你喜欢
        • 2011-07-31
        • 2023-03-28
        • 1970-01-01
        • 1970-01-01
        • 2011-01-11
        • 2020-03-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多