Symfony2 ACL和Doctrine2:数据库永远不会与当前实体元数据同步

时间:2012-08-13 10:53:22

标签: doctrine doctrine-orm acl symfony-2.1

我在config.yml文件中基本上有两个不同的Doctrine连接,默认(dev,prod环境)和test(对于我的测试套件)。这是我的默认连接配置:

# 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

结果为Aborting: The table with name 'myproject_prod.acl_classes' already exists.

然后,如果我做了./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来执行这些请求,它总是会产生相同的结果。表在这里,外键确定,但是doctrine总是认为它不与元数据同步..

我不知道如果它有问题,因为在我的应用程序中所有功能都非常好,ACL工作得很好,但是当我更新我的架构或验证它看到这种情况时,我感到有点沮丧。

非常感谢您的帮助。

谢谢!

编辑:我在Symfony2.1 RC4上

2 个答案:

答案 0 :(得分:1)

似乎在这里已经认真对待这个问题:https://github.com/symfony/symfony/issues/5108

我认为很快修好了。)

答案 1 :(得分:0)

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

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

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