Software /
code /
prosody
Changeset
10039:e90c9857a880
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 31 May 2019 00:04:05 +0200 |
parents | 10037:e01f38acde74 (current diff) 10038:7dd0dddd8e02 (diff) |
children | 10040:e8153d49caaa |
files | |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/sql.lua Thu May 30 21:44:35 2019 +0200 +++ b/util/sql.lua Fri May 31 00:04:05 2019 +0200 @@ -238,6 +238,9 @@ 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 @@ 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