|
@@ -18,11 +18,12 @@ local function l_is_module_table_exist(mdlName)
|
18
|
18
|
local tbName = string.format("mdl_%s", tostring(mdlName))
|
19
|
19
|
local sql =
|
20
|
20
|
string.format(
|
21
|
|
- "SELECT table_name FROM information_schema.TABLES WHERE TABLE_SCHEMA='%s' and table_name ='mdl_%s'",
|
|
21
|
+ "SELECT table_name FROM information_schema.TABLES WHERE TABLE_SCHEMA='%s' and table_name ='%s'",
|
22
|
22
|
constDb["mysql"]["game"]["database"],
|
23
|
23
|
tbName
|
24
|
24
|
)
|
25
|
25
|
local result = lib_game_mysql:query(sql)
|
|
26
|
+ -- log.info("l_is_module_table_exist sql[%s] result[%s]", sql, tostring(result))
|
26
|
27
|
if result and #result > 0 then
|
27
|
28
|
return true
|
28
|
29
|
end
|
|
@@ -50,7 +51,7 @@ end
|
50
|
51
|
local function l_modify_module_table(mdlName, columnNameOptions)
|
51
|
52
|
local tbName = string.format("mdl_%s", tostring(mdlName))
|
52
|
53
|
-- 更新字段
|
53
|
|
- local tableColumns = {}
|
|
54
|
+ local mapColumns = {}
|
54
|
55
|
local sql =
|
55
|
56
|
string.format(
|
56
|
57
|
"select COLUMN_NAME, IS_NULLABLE, COLUMN_TYPE, DATA_TYPE, COLUMN_COMMENT, COLUMN_DEFAULT from information_schema.columns where table_schema = '%s' and table_name = '%s'",
|
|
@@ -59,21 +60,21 @@ local function l_modify_module_table(mdlName, columnNameOptions)
|
59
|
60
|
)
|
60
|
61
|
local result = lib_game_mysql:query(sql)
|
61
|
62
|
if result then
|
62
|
|
- for _k, _v in pairs(result) do
|
|
63
|
+ for _, v in pairs(result) do
|
63
|
64
|
assert(v["COLUMN_NAME"], cjson_encode(v))
|
64
|
65
|
local column_name = v["COLUMN_NAME"]
|
65
|
|
- tableColumns[column_name] = true
|
|
66
|
+ mapColumns[column_name] = true
|
66
|
67
|
end
|
67
|
68
|
end
|
68
|
69
|
|
69
|
70
|
-- add column
|
70
|
71
|
local columns = ""
|
71
|
|
- for _k, _v in pairs(columnNameOptions) do
|
72
|
|
- if not tableColumns[_k] then
|
|
72
|
+ for k, v in pairs(columnNameOptions) do
|
|
73
|
+ if not mapColumns[k] then
|
73
|
74
|
if not is_empty(columns) then
|
74
|
75
|
columns = columns .. ","
|
75
|
76
|
end
|
76
|
|
- columns = string.format("%s %s %s", columns, _k, _v)
|
|
77
|
+ columns = string.format("%s %s %s", columns, k, v)
|
77
|
78
|
end
|
78
|
79
|
end
|
79
|
80
|
if not is_empty(columns) then
|