-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[8.x] Add DatabaseRefreshed event to be emitted after database refreshed #34952
Conversation
This is technically a breaking change, if anyone is extending those commands, since now their calls to the parent constructor will be broken. |
Doesn't laravel support injecting dependencies as params to handle? That would be a good way around the constructor changes. |
@GrahamCampbell Ya that may be an alternative. I was trying to stick to the pattern the other Database events were using. |
Right, ok. Don't make any changes. We can wait for Taylor to review this on Monday. |
It would be a breaking change even if the dependencies are injected into |
@paras-malhotra thats a good point |
To make this not breaking you probably need to service locate the dispatcher out of the container. The container is already available to commands as |
The |
@taylorotwell Updated to use the container. |
@driesvints Looks like there's a "suggest" in there for that already: https://github.com/illuminate/database/blob/master/composer.json#L41 |
@hotmeteor perfect 👍 |
$this->laravel[Dispatcher::class]->dispatch( | ||
new DatabaseRefreshed() | ||
); | ||
|
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.
Would it be possible to move this so it dispatches before the seeders are being run? Or have a separate event or something for that? It will run at different times now depending on whether you run migrate:fresh --seed
or migrate:fresh && db:seed
This PR adds a new
DatabaseRefreshed
event that is emitted after eitherphp artisan migrate:fresh
orphp artisan migrate:refresh
is run.Being able to listen to this event will allow developers to perform secondary actions to their local environment after refreshing, for example clearing stale or invalid cookies or redefining environment variables related to obsolete data.