简体   繁体   中英

Symfony2 ACLs and Doctrine2: database is never in sync with the current entity metadata

I basically have two different Doctrine connexions in my config.yml file, default (dev, prod environments) and test (for my test suite). Here is my default connexion config:

# 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..]

In my security.yml config, I registered ACLs for my default connexion:

security:
    acl:
        connection: default

Now, here is my problem:

When I run these commands

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

I have my 5 ACLs related tables already created. The extra command

./app/console init:acl

results in Aborting: The table with name 'myproject_prod.acl_classes' already exists.

Then, later, if I do a ./app/console doctrine:schema:update --dump-sql --env=prod it results in

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

I may use --force to do these requests, It will always result the same. Tables are here, foreign keys ok, but doctrine will always think Its not synchronized with metadata..

I dunno if it is problematic, since in my app all is perfectly functional, ACLs working great, but I feel a little bit frustrated when I update my schema or validate it to see this happing.

Help on this would be much appreciated.

Thanks!

EDIT: I'm on Symfony2.1 RC4

Seems that the problem has been taken seriously here: https://github.com/symfony/symfony/issues/5108

Soon fixed I think :)

same thing happens to me aswell, also running 2.1 rc4

Any time i have added an entity, and i generate the getters/setters, then do an update schema with --force i get these 5 executions aswell

I have ignored it so far, and it has not caused any issues so far ..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM