Skip to content
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

Open
wants to merge 1 commit into
base: 3.4.x
Choose a base branch
from

Conversation

tobias-93
Copy link

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:

doctrine_migrations:
    # all kinds of config
    connections:
        - my_custom_connection

@arderyp
Copy link

arderyp commented Jan 28, 2025

Is "my_custom_connection" on the example the name of a migration table? This example/naming confuses me

@tobias-93
Copy link
Author

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()
Copy link
Member

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) {
Copy link
Member

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:

$allowedConnections = $container->getParameter('doctrine.connections');

@arderyp
Copy link

arderyp commented Jan 29, 2025

No, it is the name of a connection

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants