Software /
code /
prosody
Comparison
plugins/mod_storage_sql.lua @ 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 |
parent | 13156:019cd1db9bec |
child | 13158:cf2a907ac130 |
comparison
equal
deleted
inserted
replaced
13156:019cd1db9bec | 13157:841276d0cc25 |
---|---|
857 for row in engine:select [[SELECT "relname" FROM "pg_indexes" WHERE "tablename"='prosody' AND "indexname"='prosody_index';]] do | 857 for row in engine:select [[SELECT "relname" FROM "pg_indexes" WHERE "tablename"='prosody' AND "indexname"='prosody_index';]] do |
858 indices[row[1]] = true; | 858 indices[row[1]] = true; |
859 end | 859 end |
860 end | 860 end |
861 end) | 861 end) |
862 if apply_changes then | 862 if indices["prosody_index"] then |
863 local success = engine:transaction(function () | 863 if apply_changes then |
864 return assert(engine:execute([[DROP INDEX "prosody_index";]])); | 864 local success = engine:transaction(function () |
865 end); | 865 return assert(engine:execute([[DROP INDEX "prosody_index";]])); |
866 if not success then | 866 end); |
867 module:log("error", "Failed to delete obsolete index \"prosody_index\""); | 867 if not success then |
868 return false; | 868 module:log("error", "Failed to delete obsolete index \"prosody_index\""); |
869 end | 869 return false; |
870 else | 870 end |
871 changes = changes or indices["prosody_index"]; | 871 else |
872 changes = true; | |
873 end | |
872 end | 874 end |
873 end | 875 end |
874 return changes; | 876 return changes; |
875 end | 877 end |
876 | 878 |