DoctrineBundle: Doctrine schema update filter problem

I have a problem with excluding table from schema with symfony 2.8.5

According to this http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html#manual-tables I can exclude tables form schema diff and ignore them

When I set this filter to specific table

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                schema_filter: ~^(?!table_name)~

and then run php app/console doctrine:schema:update --dump-sql

I see SQL for creation of the excluded table. When I comment the schema_filter … no DB changes will be made.

This option should not produce create/alter/drop statements for excluded tables or I’m wrong?

I have wrote to Symfony about this, by they said that this is doctrine problem https://github.com/symfony/symfony/issues/19076

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

@ServerExe the schema filter applies to the introspection of the existing database. It does not apply to the schema built from the mapping. If you want to remove some table from that schema (so that they are not created by Doctrine), you should use a listener on the \Doctrine\ORM\Tools\ToolEvents::postGenerateSchema Doctrine event to modify the Schema before it is used by Doctrine to compare it to the existing DB (in that listener, you can remove tables from the schema)

hi @kimhemsoe,

Let’s say we have tables managed (and created on setup) by Wordpress regular (all starting with wp_) and some nice Doctrine Entities that allow OO-access to these tables.

Setting the schema_filter option to ~^(?!wp_)~ filters out the Wordpress tables for

doctrine:migrations:diff doctrine:schema:drop

but not

doctrine:schema:create

which feels strange and leads to problems.

If you don’t want to change the behaviour of schema_filter on doctrine:schema:create by default how about an option to at least trigger this behaviour for the ones of us that need that?

Best Regards

Filter does not work configured tables, only tables in the database.

If you have t1, t2, and t3 and your entities is configured to use t1,t2,t3 and t4. If you filter t2, doctrine sees t1 and t3 from the database, compares that with configured entities and ends up with that t2 and t4 is not created. It will created those tables for you.

So to sum up. Filter “hides” tables in the database from doctrine, it does not stop doctrine from trying to create these tables