laravel / scout

Laravel Scout provides a driver based solution to searching your Eloquent models.
https://laravel.com/docs/scout
MIT License
1.54k stars 327 forks source link

[11.x] Use scout prefix when deleting all indexes #841

Closed macbookandrew closed 2 months ago

macbookandrew commented 2 months ago

I use Laravel Scout and Meilisearch with several local development sites and use SCOUT_PREFIX to avoid collisions between apps.

I recently wanted to drop and recreate the indexes for one app so used php artisan scout:delete-all-indexes assuming that it would delete just the indexes for the current app…but it actually deleted all indexes in the Meilisearch server.

This PR respects the scout.prefix config value and only deletes the indexes that begin with the prefix.

The php artisan scout:delete-index is not affected, since you have to supply the index name and it’s in theory more obvious which index you are deleting.

Alternative idea instead of this approach: the scout:delete-all-indexes command could instead notify the user that it will delete all indexes, not just those with this app’s prefix, and ask them to confirm before deleting.

Alternative idea in conjunction with this approach: the scout:delete-all-indexes command could include a --ignore-prefix or similar flag to override the behavior in this PR for those cases where the user does in fact want to remove all indexes, even those without the prefix.

driesvints commented 2 months ago

@macbookandrew thank you for your PR. Could you add an entry to the UPGRADE.md guide for this one?

macbookandrew commented 2 months ago

@driesvints done