-
-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schema filters for setups with multiple connections are only applied to the connection referred to by default_connection #1861
Comments
The On DoctrineMigrationsBundle this is however only registered for the default connection. Or you think if no connection name is passed it should apply to all connections? (that would break BC though) Also related: doctrine/migrations#1406 (comment) and doctrine/DoctrineMigrationsBundle#590 |
@dmaicher If not explicitly configured otherwise, we’d expect all connections to behave the same. The current behaviour is extremely implicit and (while I haven’t checked) I assume this is not documented in the configuration. The service definition you link to also doesn’t explicitly mention the default connection; this is a fallback which is handled in code in the filter pass.
I feel like this is the best outcome, but as you mention this brings a BC break. Assuming this would be fixed in the next major Symfony release I see several interim/alternative solutions:
There could be better options, I hope this sparks some discussion. |
Maybe another solution would be to add a bundle configuration option to make the behavior change for tags that don't have a connection specified, and deprecate not setting it to |
This seems intended #935 (comment) The way I see it, this is a bug in doctrine migrations bundle, as SchemaFilterListener is there and it doesn't list all connections However, the way to facilitate both OP and linked comment thread would be to default to all connections if not otherwise specified, but still allow to specify connection for the tag. I don't think this is a big enough behavioral change to introduce a config option for it nor delay for next major either. |
Bug Report
Summary
Schema filters are only registered for the default connection on multi-connection setups.
For example, combining this with the migrations bundle, the
doctrine_migration_versions
table is only filtered out of e.g.doctrine:schema:drop
for the default_connection in a setup with multiple entity managers and multiple migration configurations. This causes implicit (and depending on the filters, potentially destructive) behaviour.Current behavior
The
\Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DbalSchemaFilterPass
registers schema filters (like\Doctrine\Bundle\MigrationsBundle\EventListener\SchemaFilterListener
) only for the connection referred to by default_connection.Expected behavior
Schema filters should be applied to every connection when tagged appropriately in the container.
How to reproduce
Configuring Symfony's doctrine.yaml as follows (snippet from our configuration with modified naming):
Results in the following output for the different databases.
Assuming:
database1
has tablesabc
anddoctrine_migration_versions
database2
has tablesdef
anddoctrine_migration_versions
Running
bin/console doctrine:schema:drop --dump-sql --full-database --em=database1
yields:Running
bin/console doctrine:schema:drop --dump-sql --full-database --em=database2
yields:Note the absence of doctrine_migration_versions in the case of database1, because it is automatically selected as default_connection by the Doctrine bundle and thus the filter is applied.
The text was updated successfully, but these errors were encountered: