title: how set up symfony 3 doctrine migrations with multiple db?
body: <p>I am struggling to have symfony/doctrine exclude db views when validating and updating schema.</p>
  
  <p>I first tried without doctrine migrations ( <a href="https://stackoverflow.com/questions/46775200/symfony-3-doctrine-schema-filter-not-working">see this question</a>) but that did not work.</p>
  
  <p>I found out that doctrine migrations would filter out views from validation/update and it actually does, so that step seems to work with migrations.</p>
  
  <p>So, if one has just one db doctrine migrations will work fine, but the set up with multiple db is not clean cut, to say the least.</p>
  
  <p>This is a known issue as you can see on <a href="https://github.com/doctrine/DoctrineMigrationsBundle/pull/46" rel="nofollow noreferrer">this link</a>. Unfortunately when attempting to follow the solutions described in the link the results are messy.</p>
  
  <p>Even though the command migrations:update --em=default will indicate the correct database is set up, when generating migrations:diff --em=default it will mingle with other db and likewise with migrations:migrate --em=default which ends up creating tables on the other db.</p>
  
  <p>More specifically the errors are:
  - it will create the separate directories for the migrations files as indicated in the config files, but not to the corresponding em
  - it will generate mysql queries mixing up the two em
  - consequently it will update db</p>
  
  <p>My set up is as follows:</p>
  
  <p>config.yml</p>
  
  <pre><code>imports:
  ....
  - { resource: doctrine_migrations_default.yml }
  - { resource: doctrine_migrations_used.yml }
  
  doctrine:
    dbal:
      default_connection: default
      connections:
          default:      
              .....
              #schema_filter: "~^(?!view).*$~"
              schema_filter: ~^(?!view_)~
          used:
               ......
  
  orm:
      auto_generate_proxy_classes: '%kernel.debug%'
      default_entity_manager: default
      entity_managers:
          default:
              naming_strategy: doctrine.orm.naming_strategy.underscore
              connection: default
              auto_mapping: true
              mappings:
                  AppBundle:  ~
          used:
              naming_strategy: doctrine.orm.naming_strategy.underscore
              connection: used
              mappings:
                  UsedBundle: ~ 
  </code></pre>
  
  <p>Then, the specific configuration files for migrations are:</p>
  
  <p>doctrine_migrations_default.yml</p>
  
  <pre><code>doctrine_migrations: 
          dir_name: "%kernel.root_dir%/DoctrineMigrationsDefault"
          namespace: App\DoctrineMigrationsDefault
          table_name: migration_versions
          name: Application_Migrations_Default 
  </code></pre>
  
  <p>doctrine_migrations_used.yml</p>
  
  <pre><code>doctrine_migrations:
      dir_name: "%kernel.root_dir%/DoctrineMigrationsUsed"
      namespace: Used\DoctrineMigrationsUsed
      table_name: migration_versions
      name: Application Migrations Used
      organize_migrations: false
  </code></pre>
  
  <p>This is one example of how it mixes up the configs. The database name is correct. It corresponds to the em=default. But other info are coming from the em=used</p>
  
  <p>Thanks</p>
  
  <pre><code>php bin/console doctrine:migrations:status --em=default
  </code></pre>
  
  <p>== Configuration</p>
  
  <pre><code>&gt;&gt; Name:                                               Application Migrations Used
  &gt;&gt; Database Driver:                                    pdo_mysql
  &gt;&gt; Database Name:                                      symfony_cars
  &gt;&gt; Configuration Source:                               manually configured
  &gt;&gt; Version Table Name:                                 migration_versions
  &gt;&gt; Version Column Name:                                version
  &gt;&gt; Migrations Namespace:                               Used\DoctrineMigrationsUsed
  &gt;&gt; Migrations Directory:                               /Users/BAMAC/Sites/Symfony1/app/DoctrineMigrationsUsed
  &gt;&gt; Previous Version:                                   Already at first version
  &gt;&gt; Current Version:                                    0
  &gt;&gt; Next Version:                                       2017-10-19 08:03:52 (20171019080352)
  &gt;&gt; Latest Version:                                     2017-10-19 08:03:52 (20171019080352)
  &gt;&gt; Executed Migrations:                                0
  &gt;&gt; Executed Unavailable Migrations:                    0
  &gt;&gt; Available Migrations:                               1
  &gt;&gt; New Migrations:                                     1
  </code></pre>
  
  <p>Also, if I try to specifically indicate the configuration file with:</p>
  
  <blockquote>
    <p>php bin/console doctrine:migrations:status --em=default --configuration=./app/config/doctrine_migrations_default.yml</p>
  </blockquote>
  
  <p>It will not recognize the file info, even though it does so when it gets the info directly from config.yml. The following error is thrown.</p>
  
  <blockquote>
    <p>[Doctrine\DBAL\Migrations\MigrationException]<br>
      Migrations configuration key "doctrine_migrations" does not exists.</p>
  </blockquote>
  
  <p>If I take the doctrine_migrations key out it will generate an error on the next info it encounters.</p>