symfony2.6 doctrine2 schema_filter parameter not exists
Asked Answered
B

2

2

I am using symfony 2.6 (composer.json equal to its github repo) and I am trying to use the schema filter of DBAL.

in config.yml

# Doctrine Configuration
doctrine:
    dbal:
        schema_filter: ^sf2_

but error returned on shell:

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
  Unrecognized option "schema_filter" under "doctrine.dbal"

What am I missing?

EDIT:

config.yml (doctrine part only)

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver:   "%database.driver%"
                host:     "%database.master.host%"
                port:     "%database.master.port%"
                dbname:   "%database.master.dbname%"
                user:     "%database.master.user%"
                password: "%database.master.password%"
                charset:  UTF8
                options:
                    1002:  "SET NAMES 'UTF8'"
                # if using pdo_sqlite as your database driver, add the path in parameters.yml
                # e.g. database_path: "%kernel.root_dir%/data/data.db3"
                # path:     "%database_path%"
                slaves:
                    slave1:
                        host:     "%database.slave1.host%"
                        port:     "%database.slave1.port%"
                        dbname:   "%database.slave1.dbname%"
                        user:     "%database.slave1.user%"
                        password: "%database.slave1.password%"
                mapping_types:
                    enum:   string
                    set:    string
                    bit:    boolean
        types:
        # some types

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        default_entity_manager: default
        entity_managers:
            default:
                connection: default

(POST) CONSIDERATION:

Anyway the schema_filter does not fit my requirements it is too vague to define with a reg exp (I mean for my actual schema is required a too complex reg exp and it is not pratical at all). I posted in doctrine2 groups a request for "enhancing" this option. https://groups.google.com/forum/#!topic/doctrine-user/Tr4kkpIxwRk

Bashee answered 13/4, 2015 at 10:34 Comment(0)
G
4

What is your exact symfony version? I tried this config option with Symfony 2.6.5 and everything works fine.

Do you happen to have multiple connections? There is a note in documentation about this, at the end of the page:

Note that if you have multiple connections configured then the schema_filter configuration will need to be placed per-connection.

Manual tables

Guthrie answered 13/4, 2015 at 10:53 Comment(11)
symfony 2.6.6 doctrine.dbal 2.4.4 doctrine-bundle 1.4.0 doctrine/orm 2.4.7 and so on. Just composer update from the symfony2.6 standard comnposer.json file.Bashee
Updated to the versions you specified. Still no problems whatsoever. Can you please edit and include your doctrine configuration only, the whole of it.Guthrie
included the config.ymlBashee
Just as I thought. You have multiple connections defined. Take a look at the block quote I added before, as well as the link. You should include that option in doctrine.dbal.connections.default under charset for example.Guthrie
for the multiple connection is it still true even for different environments? Ok, I supposed a little bit this thing, but make no sense at all, because it is not aware doctrine of other connection in othe environment... Or is it up to synfony2? could you please explain why it happens?Bashee
If you defined your second connection in your config_dev.yml then Symfony load this file every time you run your application under app_dev.php. Symfony load its extra configuration file based on current environment. So when you have multiple connections, that option have to be defined for each one. When you use doctrine dbal's default config setup, it gets defined just once.Guthrie
where I have multiple connection is on config_test.yml the dev one is "clean": no doctrine parameters, it means in the dev env I have only one connection. Does it affect doctrine/symfony2 anyway for this filter schema parameter?Bashee
No no, lets look it in different angle. Even if you have only one connection, the moment you change your configuration by adding the option connections your configuration is considered as one with multiple connections. And no, I do not believe it affects symfony in any way as long as you know what this filter does.Guthrie
Thanks. Tomortow i ll give it a try.Bashee
you were right!! about multiple connections. The symfony2 doc in this case it was not helping me understanding at all... thxBashee
I think you might want to like this solution. ``` doctrine: dbal: default_connection: default schema_filter: ~^(?!date_)~ driver: "%database_driver%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: UTF8 ```Tiptop
D
0

The schema_filter parameter is part of the Doctrine Migrations bundle. Do you have that installed?

Detrition answered 13/4, 2015 at 12:2 Comment(5)
yes. I installed. I followed the rules in the symfony2 doc. symfony.com/doc/current/bundles/DoctrineMigrationsBundle/…Bashee
Can you check that's it definitely installed? Look at the terminal to see if it's picking up the doctrine:migrations command.Detrition
Yes it is installed because I've already used without that option. and yes it is present in the list of command available listed in the console scriptBashee
Do you have multiple connections (as per @Andariel's answer)?Detrition
I've just one connection for the dev and prod environment. Things are little different for the test env that have one more connection.Bashee

© 2022 - 2024 — McMap. All rights reserved.