Files
cloudron-box/migrations/20181116191032-tasks-add-table.js
Girish Ramakrishnan 218739a6b5 Add tasks table and API
progress will be tracked with this table instead of being in-process
like progress.js
2018-11-19 17:37:42 -08:00

26 lines
749 B
JavaScript

'use strict';
exports.up = function(db, callback) {
var cmd = "CREATE TABLE tasks(" +
"id VARCHAR(32) NOT NULL UNIQUE," +
"percent INTEGER DEFAULT 0," +
"message TEXT," +
"detail TEXT," +
"result TEXT," +
"creationTime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
"ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," +
"PRIMARY KEY (id))";
db.runSql(cmd, function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('DROP TABLE tasks', function (error) {
if (error) console.error(error);
callback(error);
});
};