-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
Add support for multiple connections managed by migrations #590
base: 3.4.x
Are you sure you want to change the base?
Conversation
Is "my_custom_connection" on the example the name of a migration table? This example/naming confuses me |
No, it is the name of a connection (see https://symfony.com/doc/current/reference/configuration/doctrine.html#doctrine-dbal-configuration). The name of the migrations table (of which there is only one per database/connection) is configured in the storage (see https://symfony.com/bundles/DoctrineMigrationsBundle/current/index.html#configuration) |
->info('A list of connections managed by migrations, for which the migrations administrative table shall be filtered. The "default" connection is automatically filtered.') | ||
->prototype('scalar')->end() | ||
->defaultValue([]) | ||
->end() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having to re-specify connections here feels clumsy. Users won't understand why they need to do so.
@@ -135,6 +135,13 @@ public function load(array $configs, ContainerBuilder $container): void | |||
$container->setParameter('doctrine.migrations.preferred_em', $config['em']); | |||
$container->setParameter('doctrine.migrations.preferred_connection', $config['connection']); | |||
|
|||
if ($config['connections'] !== []) { | |||
$filterDefinition = $container->getDefinition('doctrine_migrations.schema_filter_listener'); | |||
foreach ($config['connections'] as $connection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than looping on this, how about creating a compiler pass that uses this parameter:
DoctrineMigrationsBundle/src/DependencyInjection/CompilerPass/ConfigureDependencyFactoryPass.php
Line 82 in e858ce0
$allowedConnections = $container->getParameter('doctrine.connections'); |
How then does this relate to or fix the issue of the default dropping of the migrations table (the issues you posted this PR to as a solution) Forgive my confusion, I must be missing something |
References doctrine/migrations#1406, which fixes the filtering of the migrations table for the default connection but not for any other connections.
This PR adds a configuration option to communicate the migrations-managed connections to the migrations library.
Not sure what else is required in terms of tests/documentation etc.
Super short example: