Selaa lähdekoodia

修复模块数据库表变更

neo 1 vuosi sitten
vanhempi
commit
6c30ad91eb
1 muutettua tiedostoa jossa 8 lisäystä ja 7 poistoa
  1. 8 7
      dev/modules.lua

+ 8 - 7
dev/modules.lua

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