-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
Alternative connection via --conn option is ignored #1160
Comments
can you please tell us which version of the doctrine migrations bundle are you using? |
@goetas: of course the latest release:
|
Experiencing the same issue with:
|
Are you using the symfony bundle? if yes, what is the bundle version (not the migrations lib) |
Hi,
It doesn't matter what is defined as the
|
@ureimers hmm. that is weird and looks like a big :( |
So, after looking into the issue, there is a problem when there is only the default entity manager... the --conn option is ignore and always the entity manager connection is choosen. could you share your doctrine migrations and doctrine connection configs? |
Hi @goetas,
|
hmm, that seems weird. is there a way to reproduce this somehow in a failing test case? |
has it already been fixed? |
you did not mange to reproduce it? or you saw a commit fixing it? |
I face the same issue and you seem to be right:
This is the case for us as well. |
@mussbach so you have one entity manager and multiple connections, right? and commands and So my question is: why do you have two connections if you have only one entity manager? what is doing the other connection? |
Yes, you understood it correctly. |
I tried to update from 2.x to 3.4 and have the same error with multiple connection. Thx in advance |
I have the same issue. I have 2 connections, lets say "default" and "database_2" but only one Entity Manager on "default" (my second connection doesn't need Entities. If I provide "--conn database_2" to any of the migration commands, it always falls back to the "default". Any ideas how to sort this? |
i could solve this for me by adding "connection: migrations to doctrine_migrations.yaml (or the connection you need than) so at the end its looking like this:
|
has it already been fixed? |
While we are waiting for the fix we can use flag # config/packages/doctrine.yaml
doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
# ...
migrations: # <--- connection for migration
url: '%env(resolve:DATABASE_MIGRATIONS_URL)%'
# ...
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
# ...
migrations: # <--- orm manager for connection
connection: migrations
# ... and run php bin/console doctrine:migrations:migrate --no-interaction --em=migrations |
Same case here.. Because with the mapping, $mappings = [
realpath(__DIR__ . '/Resources/config/doctrine') => 'Allsoftware\SymfonyBundle\Entity',
];
$container->addCompilerPass(
DoctrineOrmMappingsPass::createXmlMappingDriver(
$mappings,
['allsoftware.symfony.model_manager_name'],
'allsoftware.symfony.backend_type_orm'
)
); Result of doctrine:
orm:
entity_managers:
default:
[...]
mappings:
App:
is_bundle: false
type: attribute
dir: /var/www/html/src/Entity
prefix: App\Entity
alias: App
mapping: true
+ AllsoftwareSymfonyBundle:
+ type: attribute
+ dir: src/Model
+ prefix: Allsoftware\SymfonyBundle\Model
+ mapping: true
client1:
[...]
mappings:
App:
is_bundle: false
type: attribute
dir: /var/www/html/src/Entity
prefix: App\Entity
alias: App
mapping: true |
The problem seems to be with |
Bug Report
Summary
In #1023 the option to allow alternative connections via --conn option was added. However as also stated in #1062 (comment) and #1062 (comment) an alternative connection specified via --conn option is ignored and the default connection is used instead.
Current behavior
Default connection is used.
How to reproduce
Expected behavior
Alternative connection should be used.
The text was updated successfully, but these errors were encountered: