larvitdbmigration
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -24,2 +24,20 @@ 'use strict'; | ||
function getLock(cb) { | ||
db.query('SELECT running FROM `' + options.tableName + '`;', function(err, rows) { | ||
if (err) { | ||
cb(err); | ||
return; | ||
} | ||
if (parseInt(rows[0].running) === 1) { | ||
log.verbose('larvitdbmigration: Another process is running the migrations, wait and try again soon.'); | ||
setTimeout(function() { | ||
getLock(cb); | ||
}, 500); | ||
} else { | ||
cb(); | ||
} | ||
}); | ||
} | ||
return function(cb) { | ||
@@ -107,20 +125,2 @@ var tasks = [], | ||
tasks.push(function(cb) { | ||
function getLock(cb) { | ||
db.query('SELECT running FROM `' + options.tableName + '`;', function(err, rows) { | ||
if (err) { | ||
cb(err); | ||
return; | ||
} | ||
if (parseInt(rows[0].running) === 1) { | ||
log.verbose('larvitdbmigration: Another process is running the migrations, wait and try again soon.'); | ||
setTimeout(function() { | ||
getlock(cb); | ||
}, 500); | ||
} else { | ||
cb(); | ||
} | ||
}); | ||
} | ||
getLock(function(err) { | ||
@@ -127,0 +127,0 @@ var sql = 'UPDATE `' + options.tableName + '` SET running = 1;'; |
@@ -33,3 +33,3 @@ { | ||
}, | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"readmeFilename": "README.md", | ||
@@ -36,0 +36,0 @@ "scripts": {}, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7106