From 5c758ba5b1d36b3343401e593b4d31c3af462abe Mon Sep 17 00:00:00 2001 From: Dorian Wouters Date: Thu, 1 Jun 2017 17:38:07 -0400 Subject: [PATCH] Put table existence check into a function --- init.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index a245390..6703452 100644 --- a/init.lua +++ b/init.lua @@ -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 .. ' (' ..