Put table existence check into a function

This commit is contained in:
Dorian Wouters 2017-06-01 17:38:07 -04:00
parent aaea6cd076
commit 5c758ba5b1
No known key found for this signature in database
GPG Key ID: 6E9DA8063322434B
1 changed files with 8 additions and 3 deletions

View File

@ -184,13 +184,18 @@ do
end
end
local auth_table_created
do -- Auth table existence check and setup
local function table_exists(name)
conn:query("SHOW TABLES LIKE '" .. tables.auths.name .. "'")
local res = conn:store_result()
local exists = (res:row_count() ~= 0)
res:free()
if not exists then
return exists
end
thismod.table_exists = table_exists
local auth_table_created
do -- Auth table existence check and setup
if not table_exists(tables.auths.name) then
-- Auth table doesn't exist, create it
local S = tables.auths.schema
conn:query('CREATE TABLE ' .. tables.auths.name .. ' (' ..