From 9d97d8f89bc570b1232c0dd8450f489b39023e18 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 31 Oct 2015 14:28:11 +0100 Subject: core/web: o Adding last_timestamp o Showing last_value and last_timestamp for each property. --- migrations/20151031131941-last-timestamp.js | 30 ++++++++++++++++++++++ .../sqls/20151031131941-last-timestamp-down.sql | 1 + .../sqls/20151031131941-last-timestamp-up.sql | 2 ++ 3 files changed, 33 insertions(+) create mode 100644 migrations/20151031131941-last-timestamp.js create mode 100644 migrations/sqls/20151031131941-last-timestamp-down.sql create mode 100644 migrations/sqls/20151031131941-last-timestamp-up.sql (limited to 'migrations') diff --git a/migrations/20151031131941-last-timestamp.js b/migrations/20151031131941-last-timestamp.js new file mode 100644 index 0000000..913203f --- /dev/null +++ b/migrations/20151031131941-last-timestamp.js @@ -0,0 +1,30 @@ +var dbm = global.dbm || require('db-migrate'); +var type = dbm.dataType; +var fs = require('fs'); +var path = require('path'); + +exports.up = function(db, callback) { + var filePath = path.join(__dirname + '/sqls/20151031131941-last-timestamp-up.sql'); + fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ + if (err) return callback(err); + console.log('received data: ' + data); + + db.runSql(data, function(err) { + if (err) return callback(err); + callback(); + }); + }); +}; + +exports.down = function(db, callback) { + var filePath = path.join(__dirname + '/sqls/20151031131941-last-timestamp-down.sql'); + fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ + if (err) return callback(err); + console.log('received data: ' + data); + + db.runSql(data, function(err) { + if (err) return callback(err); + callback(); + }); + }); +}; diff --git a/migrations/sqls/20151031131941-last-timestamp-down.sql b/migrations/sqls/20151031131941-last-timestamp-down.sql new file mode 100644 index 0000000..44f074e --- /dev/null +++ b/migrations/sqls/20151031131941-last-timestamp-down.sql @@ -0,0 +1 @@ +/* Replace with your SQL commands */ \ No newline at end of file diff --git a/migrations/sqls/20151031131941-last-timestamp-up.sql b/migrations/sqls/20151031131941-last-timestamp-up.sql new file mode 100644 index 0000000..0268983 --- /dev/null +++ b/migrations/sqls/20151031131941-last-timestamp-up.sql @@ -0,0 +1,2 @@ +ALTER TABLE device_property +ADD COLUMN last_timestamp TIMESTAMPTZ; -- cgit v1.2.3