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

[10.x] Dispatch model pruning started and ended events #47669

Merged
merged 5 commits into from
Jul 8, 2023
Merged

[10.x] Dispatch model pruning started and ended events #47669

merged 5 commits into from
Jul 8, 2023

Conversation

ziadoz
Copy link
Contributor

@ziadoz ziadoz commented Jul 6, 2023

When the model pruning command has completed I want to run some additional SQL, such as ANALYZE TABLE, on the affected models' tables. The existing events the command dispatches aren't sufficient to do this because they fire per chunk of records deleted. This PR adds starting and ending events, similar to the migrate command, which include an array of the model classes that were pruned.

@ziadoz ziadoz marked this pull request as ready for review July 6, 2023 09:58
@@ -49,10 +51,14 @@ public function handle(Dispatcher $events)
}

if ($this->option('pretend')) {
$events->dispatch(new ModelsPruningStarted($models->toArray()));
Copy link
Contributor

Choose a reason for hiding this comment

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

@ziadoz Would it be an idea to pass the pretending flag from the command into the starting and ending events respectively?

Copy link
Contributor Author

@ziadoz ziadoz Jul 6, 2023

Choose a reason for hiding this comment

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

@morloderex Yes, I think it would be a good idea, but adding it here would be inconsistent with the existing migration events. It might be worth implementing in a separate PR though.

@taylorotwell taylorotwell merged commit b83abb4 into laravel:10.x Jul 8, 2023
15 checks passed
@taylorotwell
Copy link
Member

Renamed - also don't think they should run on pretend tbh.

@ziadoz ziadoz deleted the prune-start-end-events branch July 10, 2023 07:57
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.

None yet

3 participants