apps: update ts in code instead of database
ts is useful as a versioning mechanism (for example, icon changed). update the timestamp explicity in code instead of db. this way health and healthTime can be updated without changing ts.
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
exports.up = function(db, callback) {
|
||||||
|
db.runSql('ALTER TABLE apps MODIFY ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP', [], function (error) {
|
||||||
|
if (error) console.error(error);
|
||||||
|
callback(error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function(db, callback) {
|
||||||
|
db.runSql('ALTER TABLE apps MODIFY ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', [], function (error) {
|
||||||
|
if (error) console.error(error);
|
||||||
|
callback(error);
|
||||||
|
});
|
||||||
|
};
|
||||||
+4
-1
@@ -367,6 +367,9 @@ function clear(callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update(id, app, callback) {
|
function update(id, app, callback) {
|
||||||
|
// ts is useful as a versioning mechanism (for example, icon changed). update the timestamp explicity in code instead of db.
|
||||||
|
// this way health and healthTime can be updated without changing ts
|
||||||
|
app.ts = new Date();
|
||||||
updateWithConstraints(id, app, '', callback);
|
updateWithConstraints(id, app, '', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,7 +460,7 @@ function updateWithConstraints(id, app, constraints, callback) {
|
|||||||
function setHealth(appId, health, healthTime, callback) {
|
function setHealth(appId, health, healthTime, callback) {
|
||||||
assert.strictEqual(typeof appId, 'string');
|
assert.strictEqual(typeof appId, 'string');
|
||||||
assert.strictEqual(typeof health, 'string');
|
assert.strictEqual(typeof health, 'string');
|
||||||
assert(util.isDate(healthTime));
|
assert(util.types.isDate(healthTime));
|
||||||
assert.strictEqual(typeof callback, 'function');
|
assert.strictEqual(typeof callback, 'function');
|
||||||
|
|
||||||
var values = { health, healthTime };
|
var values = { health, healthTime };
|
||||||
|
|||||||
Reference in New Issue
Block a user