Skip to content

Commit 5ed4d82

Browse files
committed
check if index exists before deleting it
1 parent 53ce5e5 commit 5ed4d82

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Jobs/SetupIndex.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private function migrate(ElasticaClient $elastica): void
4343
try {
4444
$response = $elastica->getClient()->request(sprintf('_alias/%s', $this->indexConfig->getName()));
4545
} catch (ClientException|ConnectionException|ResponseException) {
46-
if (count($index->getAliases()) === 0) {
46+
if ($index->exists() && count($index->getAliases()) === 0) {
4747
$index->delete();
4848
}
4949

@@ -58,7 +58,9 @@ private function migrate(ElasticaClient $elastica): void
5858
return;
5959
}
6060

61-
$index->delete();
61+
if ($index->exists()) {
62+
$index->delete();
63+
}
6264
}
6365

6466
private function cleanup(ElasticaClient $elastica): void

0 commit comments

Comments
 (0)