From 540b12537a6cf34b3cb21886f17aff560dcd00c5 Mon Sep 17 00:00:00 2001 From: marc tobias Date: Sat, 8 Feb 2020 15:16:20 +0100 Subject: [PATCH] setup: delete invalid indices in create-search-indices step --- lib/setup/SetupClass.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/setup/SetupClass.php b/lib/setup/SetupClass.php index 34ece8e0..100e3847 100755 --- a/lib/setup/SetupClass.php +++ b/lib/setup/SetupClass.php @@ -566,6 +566,15 @@ class SetupFunctions { info('Create Search indices'); + $sSQL = 'SELECT relname FROM pg_class, pg_index '; + $sSQL .= 'WHERE pg_index.indisvalid = false AND pg_index.indexrelid = pg_class.oid'; + $aInvalidIndices = $this->oDB->getCol($sSQL); + + foreach ($aInvalidIndices as $sIndexName) { + info("Cleaning up invalid index $sIndexName"); + $this->oDB->exec("DROP INDEX $sIndexName;"); + } + $sTemplate = file_get_contents(CONST_BasePath.'/sql/indices.src.sql'); if (!$this->dbReverseOnly()) { $sTemplate .= file_get_contents(CONST_BasePath.'/sql/indices_search.src.sql'); -- 2.45.1