Skip to content

Conversation

abellion
Copy link
Contributor

@abellion abellion commented Nov 7, 2017

This PR makes use of the container to autowire the migrations instances.

@browner12
Copy link
Contributor

is there any immediate benefit from this? or is it more for consistency?

@GrahamCampbell GrahamCampbell changed the title [Database] Autowire migrations [5.5] Autowire migrations Nov 7, 2017
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Collection;
use Illuminate\Container\Container;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should use the contact here instead.

@laravel laravel deleted a comment from ntzm Nov 7, 2017
@sisve
Copy link
Contributor

sisve commented Nov 8, 2017

We've had migrations that weren't resolved from the container for several years now, why do we need it now? When do you need to resolve services to modify your database schema?

@deleugpn
Copy link
Contributor

deleugpn commented Nov 8, 2017

I know it's almost irrelevant, but this brings a performance impact as the Reflector will be used to instantiated migration classes. The reason I bring this up is that if there is no upside at all for this, we can see a tiny downside.

Also, tests are failing.

@abellion
Copy link
Contributor Author

abellion commented Nov 8, 2017

For consistency yes, and because we use MondoDB as our primary data storage and for some reasons we need services from the container. I think the performance impact is so tiny it shouldn't be a problem. I'm going to fix the tests.

@sisve
Copy link
Contributor

sisve commented Nov 8, 2017

Let's talk about breaking changes. What are we talking about here? In which scenarios will things blow up? Can third party packages be compatible with the current Migrator class and these new changes at the same time?

@deleugpn
Copy link
Contributor

deleugpn commented Nov 8, 2017

I agree. Talk about performance is pointless if there is a visible improvement. I only brought it up because we cannot see the improvement here. It would be nice to know how you're setting up MongoDB with migrations and how this solve that.

@sisve I don't think there's any breaking changes here. If we assume that nobody is binding the migration classes into the container, this will auto-wire the class regularly.
If somebody is binding it to the container, the container will just resolve the bound one, which seems the intended behavior. The reason I think nobody is binding it is because the migrator was not resolving it anyway.

@abellion
Copy link
Contributor Author

abellion commented Nov 8, 2017

Actually our own use case is related to MongoDB services, but I can imagine it's far from being the only one. I just don't see what's the benefit of NOT having these class autowired ?

BC layer should not be a problem as the class were constructed without any arguments (ie. an exception would be thrown). Except for default parameters I guess, but the container is taking care of them.

@sisve
Copy link
Contributor

sisve commented Nov 8, 2017

@deleugpn @abellion You're changing a method signature (Migrator::__construct). How would anyone that has derived from the class and implemented their own constructor be compatible with current and next version of the Migrator if there are two different parent::__construct to call?

@abellion
Copy link
Contributor Author

abellion commented Nov 8, 2017

@taylorotwell @GrahamCampbell Can you explain why it has been closed ?

@browner12
Copy link
Contributor

all we currently see in this PR is change for change's sake. can you explain your use case, and what the benefit of this would actually be?

@abellion
Copy link
Contributor Author

abellion commented Nov 8, 2017

We are using an internal tool do deal with MongoDB, that needs to be autowired.
Today we use the app() function to get the services, but it feels weird and inconsistant.

Actually our own use case is related to MongoDB services, but I can imagine it's far from being the only one. I just don't see what's the benefit of NOT having these class autowired ?

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.

6 participants