master
Alexander Blair 7 years ago
parent c924194b49
commit 9cc9e06344

@ -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!");

Loading…
Cancel
Save