aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-05-31 00:04:05 +0200
committerKim Alvefur <zash@zash.se>2019-05-31 00:04:05 +0200
commit02e5f2886c45a7fd24a0ac342bbd677a4aa034df (patch)
treefec4eb7a94adb49a5976b35f5fec43de835f1990 /util
parent8848e1ea6c2a30a487d624c01311c8d3363a0a1a (diff)
parentc2576aea62e6567c7690a17e1c33d8256f683899 (diff)
downloadprosody-02e5f2886c45a7fd24a0ac342bbd677a4aa034df.tar.gz
prosody-02e5f2886c45a7fd24a0ac342bbd677a4aa034df.zip
Merge 0.11->trunk
Diffstat (limited to 'util')
-rw-r--r--util/sql.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/util/sql.lua b/util/sql.lua
index 47900102..00c7b57f 100644
--- a/util/sql.lua
+++ b/util/sql.lua
@@ -238,6 +238,9 @@ function engine:transaction(...)
end
function engine:_create_index(index)
local sql = "CREATE INDEX \""..index.name.."\" ON \""..index.table.."\" (";
+ if self.params.driver ~= "MySQL" then
+ sql = sql:gsub("^CREATE INDEX", "%1 IF NOT EXISTS");
+ end
for i=1,#index do
sql = sql.."\""..index[i].."\"";
if i ~= #index then sql = sql..", "; end
@@ -256,6 +259,9 @@ function engine:_create_index(index)
end
function engine:_create_table(table)
local sql = "CREATE TABLE \""..table.name.."\" (";
+ do
+ sql = sql:gsub("^CREATE TABLE", "%1 IF NOT EXISTS");
+ end
for i,col in ipairs(table.c) do
local col_type = col.type;
if col_type == "MEDIUMTEXT" and self.params.driver ~= "MySQL" then