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

Raffaello
  • 1,641
  • 15
  • 29

2 Answers2

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

Artamiel
  • 3,652
  • 2
  • 19
  • 24
  • 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. – Raffaello Apr 13 '15 at 10:58
  • Updated to the versions you specified. Still no problems whatsoever. Can you please edit and include your **doctrine** configuration only, the whole of it. – Artamiel Apr 13 '15 at 11:06
  • included the config.yml – Raffaello Apr 13 '15 at 12:30
  • 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. – Artamiel Apr 13 '15 at 12:33
  • 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? – Raffaello Apr 13 '15 at 14:55
  • 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. – Artamiel Apr 13 '15 at 15:37
  • 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? – Raffaello Apr 13 '15 at 16:00
  • 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. – Artamiel Apr 13 '15 at 16:04
  • Thanks. Tomortow i ll give it a try. – Raffaello Apr 13 '15 at 18:15
  • you were right!! about multiple connections. The symfony2 doc in this case it was not helping me understanding at all... thx – Raffaello Apr 14 '15 at 15:04
  • 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 ``` – Olotin Temitope Mar 27 '18 at 15:15
0

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

Dan Blows
  • 20,846
  • 10
  • 65
  • 96
  • yes. I installed. I followed the rules in the symfony2 doc. http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html – Raffaello Apr 13 '15 at 12:21
  • Can you check that's it definitely installed? Look at the terminal to see if it's picking up the `doctrine:migrations` command. – Dan Blows Apr 13 '15 at 12:23
  • 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 script – Raffaello Apr 13 '15 at 12:25
  • Do you have multiple connections (as per @Andariel's answer)? – Dan Blows Apr 13 '15 at 12:26
  • I've just one connection for the dev and prod environment. Things are little different for the test env that have one more connection. – Raffaello Apr 13 '15 at 12:29