带有 Doctrine 的 Amazon Aurora 数据库

问题描述 投票:0回答:1

我需要一些帮助,我正在使用mysql和学说,一切都很完美,但现在我正在使用Auroradb,它使用两个实例(读取器和写入器)。 起初我尝试使用两个实体管理器,一个用于写入,另一个用于读取,但我遇到了 SyliusRbacBundle 的问题。

那么,还有没有其他方法可以使用极光和教义??????

更新1

这是我使用 Daniel 的配置后得到的错误

通过关系“Litigon\UserBundle\Entity\User#authorizationRoles”发现了一个新实体,该实体未配置为实体的级联持久操作:SuperAdministrador。要解决此问题: 对此未知实体显式调用 EntityManager#persist() 或配置级联以在映射中保留此关联,例如 @ManyToOne(..,cascade={"persist"})。

因此,如果我按照很多人的建议合并默认实体管理器,我会遇到 aurora 问题,因为另一个管理器用于读取器实例,然后在刷新 aurora 时说不允许写入。

symfony doctrine-orm sylius
1个回答
1
投票

您需要指定模型或实体实际位于学说配置中的位置,还需要注意的是,Sylius 模型通常位于组件上而不是捆绑包中。最后,但并非最不重要的是,只能与自动映射建立一个连接:

orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        default_entity_manager: default
        entity_managers:
            default:
                connection: default
                mappings:
                    loggable:
                        type: annotation
                        alias: Gedmo
                        prefix: Gedmo\Loggable\Entity
                        dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
                    FOSUserBundle:
                        type: xml
                        dir: Resources/config/doctrine-mapping
                        prefix: FOS\UserBundle\Model
                    SyliusRbacBundle:
                      type: xml
                      dir: Resources/config/doctrine/model
                      prefix: Sylius\Component\Rbac\Model
                    SyliusResourceBundle: ~
                    OtherBundle: ~
            writer:
                connection: writer
                mappings:
                    loggable:
                        type: annotation
                        alias: Gedmo
                        prefix: Gedmo\Loggable\Entity
                        dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
                    FOSUserBundle:
                      type: xml
                      dir: Resources/config/doctrine-mapping
                      prefix: FOS\UserBundle\Model
                    SyliusRbacBundle:
                        type: xml
                        dir: Resources/config/doctrine/model
                        prefix: Sylius\Component\Rbac\Model
                    SyliusResourceBundle: ~
© www.soinside.com 2019 - 2024. All rights reserved.