aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-06-17 00:22:45 +0200
committerKim Alvefur <zash@zash.se>2023-06-17 00:22:45 +0200
commit02469e4e8eca3dd5cfd42f159175ec536300db33 (patch)
tree4f693a91e99ce1fed303337ba4d3499b7c40b3f0 /plugins
parenta45c06b51fbc250f738b320c96d974bf733eb5b3 (diff)
downloadprosody-02469e4e8eca3dd5cfd42f159175ec536300db33.tar.gz
prosody-02469e4e8eca3dd5cfd42f159175ec536300db33.zip
mod_storage_sql: Only remove old index if it exists
Avoids an error if the upgrade is performed twice..
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_storage_sql.lua20
1 files changed, 11 insertions, 9 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 3afb5d78..b339a4e9 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -859,16 +859,18 @@ local function upgrade_table(engine, params, apply_changes) -- luacheck: ignore
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;