diff --git a/sql_sync/sql_sync.js b/sql_sync/sql_sync.js index e1f5f5b..72644bb 100644 --- a/sql_sync/sql_sync.js +++ b/sql_sync/sql_sync.js @@ -14,14 +14,16 @@ global.schema = JSON.parse(sql_schema); let loopCount = 0; let updatedCount = 0; -async.eachSeries(global.schema, function(entry){ +async.eachSeries(global.schema, function(entry, callback){ global.mysql.query("SELECT * FROM config WHERE module = ? AND item = ?", [entry.module, entry.item]).then(function(rows){ loopCount += 1; if (rows.length > 0){ - return; + return callback(); } updatedCount += 1; - global.mysql.query("INSERT INTO config (module, item, item_value, item_type, Item_desc) VALUES (?, ?, ?, ?, ?)", [entry.module, entry.item, entry.item_value, entry.item_type, entry.Item_desc]); + global.mysql.query("INSERT INTO config (module, item, item_value, item_type, Item_desc) VALUES (?, ?, ?, ?, ?)", [entry.module, entry.item, entry.item_value, entry.item_type, entry.Item_desc]).then(function(){ + return callback(); + }); }); }, function(){ console.log("Updated SQL schema with "+updatedCount+" new rows! Exiting!");