【问题标题】:Symfony2 ACLs and Doctrine2: database is never in sync with the current entity metadataSymfony2 ACL 和 Doctrine2:数据库永远不会与当前实体元数据同步
【发布时间】:2012-08-13 10:53:22
【问题描述】:

我的config.yml 文件中基本上有两个不同的 Doctrine 连接,默认(开发、生产环境)和测试(用于我的测试套件)。这是我的默认连接配置:

# Doctrine Configuration
doctrine:
    dbal:
        default_connection:   default
        connections:
            default:
                driver:   %database_driver%
                host:     %database_host%
                port:     %database_port%
                dbname:   %database_name%
                user:     %database_user%
                password: %database_password%
                charset:  UTF8
    orm:
        default_entity_manager: default
        auto_generate_proxy_classes: %kernel.debug%
        entity_managers:
            default:
                connection: default
                metadata_cache_driver:          array
                query_cache_driver:             array
                result_cache_driver:            array
                mappings:
                    [my bundles here..]

在我的 security.yml 配置中,我为我的默认连接注册了 ACL:

security:
    acl:
        connection: default

现在,这是我的问题:

当我运行这些命令时

./app/console doctrine:database:drop --connection=default --force
./app/console doctrine:database:create --connection=default
./app/console doctrine:schema:create --em=prod

我已经创建了 5 个与 ACL 相关的表。额外的命令

./app/console init:acl

结果为@​​987654327@

然后,稍后,如果我执行 ./app/console doctrine:schema:update --dump-sql --env=prod 会导致

ALTER TABLE acl_classes CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL;
ALTER TABLE acl_security_identities CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL;
ALTER TABLE acl_object_identities CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE parent_object_identity_id parent_object_identity_id INT UNSIGNED DEFAULT NULL, CHANGE class_id class_id INT UNSIGNED NOT NULL;
ALTER TABLE acl_object_identity_ancestors CHANGE object_identity_id object_identity_id INT UNSIGNED NOT NULL, CHANGE ancestor_id ancestor_id INT UNSIGNED NOT NULL;
ALTER TABLE acl_entries CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE security_identity_id security_identity_id INT UNSIGNED NOT NULL, CHANGE object_identity_id object_identity_id INT UNSIGNED DEFAULT NULL, CHANGE class_id class_id INT UNSIGNED NOT NULL, CHANGE ace_order ace_order SMALLINT UNSIGNED NOT NULL

我可以使用 --force 来做这些请求,它总是会产生相同的结果。表在这里,外键还可以,但是学说总是会认为它与元数据不同步..

我不知道这是否有问题,因为在我的应用程序中所有功能都完美无缺,ACL 运行良好,但是当我更新我的架构或验证它以看到这种情况时,我感到有点沮丧。

我们将不胜感激。

谢谢!

编辑:我在 Symfony2.1 RC4 上

【问题讨论】:

    标签: doctrine doctrine-orm acl symfony-2.1


    【解决方案1】:

    看来这里的问题已经认真对待了:https://github.com/symfony/symfony/issues/5108

    我认为很快就会修复 :)

    【讨论】:

      【解决方案2】:

      同样的事情也发生在我身上,也在运行 2.1 rc4

      任何时候我添加了一个实体,我生成了 getter/setter,然后使用 --force 更新架构,我也得到了这 5 次执行

      到目前为止我都忽略了它,到目前为止还没有引起任何问题..

      【讨论】:

        猜你喜欢
        • 2023-03-16
        • 2014-04-07
        • 1970-01-01
        • 1970-01-01
        • 2012-01-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多