Allow to reset many databases in migrate mode
When orm.reset.mode is migrate , the ORMDatabaseResetter will simply run doctrine:migrations:migrate. This makes impossible to use this mode when you have migrations for many dtabases.
Could this library provide a configurations option so that each of its values is passed to doctrine:migrations:migrate’s --configuration option?
Hi @MatTheCat
this is totally doable, but only in v2 (you mentioned you were using v2 in a previous issue)
I'm wondering what's the best approach. I've never used this --configuration option.
Is it the same file than the one in config/packages/doctrine_migrations.php (this one?). If so, shouldn't be already loaded as soon as the kernel boots?
Yes it is the same, but a configuration file is limited to one connection/entity manager. That’s why you need the --configuration option when you have many: to select the right one.
In the ResetDatabase trait’s case, you’d loop over them to run doctrine:migrations:migrate for each configuration.
ho OK, I missed the plural :)
Maybe we could update Foundry's config this way? WDYT?
orm:
reset:
connections
- default
entity_managers:
- default
mode: schema # or "migrate"
+ migrations:
+ configurations: [ '/path/to/config.php' ]
ping @kbond
Honestly I don’t know :sweat_smile:
We need the connections option whatever the mode, but entity_managers is specific to schema, while configurations would be specific to migrate, right?
to be totally honest, I was thinking we were passing the ems and/or the connections to doctrine:migrations:migrate, but we actually don't.
I'm not using this reset mode at all, and I don't think I've had to use migrations which deal with several em and/or connections, so I'm a little bit lost :shrug:
I think that passing --em or --conn options to doctrine:migrations:migrate would be a mistake, since it would run twice the same migration on different connections.
So at the end I think that both entity_managers and connections are specific to schema. And the new configurations you want would be specific to migrate.
Then, the ideal configuration would be:
orm:
reset:
mode: schema # or "migrate"
migrate:
configurations: [ '/path/to/config.php' ]
schema:
connections: [ 'default' ]
entity_managers: [ 'default' ]
As a first step, we can only add orm.reset.migrate.configurations, and some day I'll deprecate orm.reset.{connections, entity_managers} in favor of the ones specific to schema.
FYI, we have a lot of specific demands around the reset database mechanism, I think at some point I'll rework it so that user can override some parts, thanks to decoration
Seems like connections are only used to reset the database, not the schema :thinking:
But yeah keeping BC probably means adding a orm.reset.migrate.configurations anyway :+1:
for the schema, we're using all entity_managers given, which makes sense: from the EM you can guess the related connection
BTW, I'm on holidays this evening, and I cannot do it today. Feel free to provide a PR, but I won't be able to review before 2 weeks