Changeset

13157:841276d0cc25

mod_storage_sql: Only remove old index if it exists Avoids an error if the upgrade is performed twice..
author Kim Alvefur <zash@zash.se>
date Sat, 17 Jun 2023 00:22:45 +0200
parents 13156:019cd1db9bec
children 13158:cf2a907ac130
files plugins/mod_storage_sql.lua
diffstat 1 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua	Sat Jun 17 00:00:21 2023 +0200
+++ b/plugins/mod_storage_sql.lua	Sat Jun 17 00:22:45 2023 +0200
@@ -859,16 +859,18 @@
 					end
 				end
 			end)
-			if apply_changes then
-				local success = engine:transaction(function ()
-					return assert(engine:execute([[DROP INDEX "prosody_index";]]));
-				end);
-				if not success then
-					module:log("error", "Failed to delete obsolete index \"prosody_index\"");
-					return false;
+			if indices["prosody_index"] then
+				if apply_changes then
+					local success = engine:transaction(function ()
+						return assert(engine:execute([[DROP INDEX "prosody_index";]]));
+					end);
+					if not success then
+						module:log("error", "Failed to delete obsolete index \"prosody_index\"");
+						return false;
+					end
+				else
+					changes = true;
 				end
-			else
-				changes = changes or indices["prosody_index"];
 			end
 		end
 	return changes;