Skip to content

Commit

Permalink
Improve algolia cleanup script to retry deletion (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored Oct 6, 2024
1 parent 205cd22 commit 28d0596
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/seal-algolia-adapter/bin/drop_all_indexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,22 @@
$client = \Schranz\Search\SEAL\Adapter\Algolia\Tests\ClientHelper::getClient();

$return = 0;

$retryIndexes = [];
foreach ($client->listIndices()['items'] as $key => $value) {
echo 'Delete ... ' . $value['name'] . \PHP_EOL;

try {
$client->deleteIndex($value['name']);
} catch (\Exception) {
$retryIndexes[$key] = $value;
echo 'Retry later ... ' . $value['name'] . \PHP_EOL;
}
}

foreach ($retryIndexes as $key => $value) {
echo 'Delete ... ' . $value['name'] . \PHP_EOL;

try {
$client->deleteIndex($value['name']);
} catch (\Exception) {
Expand Down

0 comments on commit 28d0596

Please sign in to comment.