diff --git a/migrations/20190826210725-apps-add-taskId.js b/migrations/20190826210725-apps-add-taskId.js new file mode 100644 index 000000000..72e4dd6ff --- /dev/null +++ b/migrations/20190826210725-apps-add-taskId.js @@ -0,0 +1,17 @@ +'use strict'; + +var async = require('async'); + +exports.up = function(db, callback) { + async.series([ + db.runSql.bind(db, 'ALTER TABLE apps ADD COLUMN taskId INTEGER'), + db.runSql.bind(db, 'ALTER TABLE apps ADD CONSTRAINT apps_task_constraint FOREIGN KEY(taskId) REFERENCES tasks(id)') + ], callback); +}; + +exports.down = function(db, callback) { + async.series([ + db.runSql.bind(db, 'ALTER TABLE app DROP FOREIGN KEY apps_task_constraint'), + db.runSql.bind(db, 'ALTER TABLE apps DROP COLUMN taskId'), + ], callback); +}; diff --git a/migrations/schema.sql b/migrations/schema.sql index fccf622e4..f51e3be1a 100644 --- a/migrations/schema.sql +++ b/migrations/schema.sql @@ -88,12 +88,14 @@ CREATE TABLE IF NOT EXISTS apps( label VARCHAR(128), // display name tagsJson VARCHAR(2048), // array of tags dataDir VARCHAR(256) UNIQUE, + taskId INTEGER, // current task // the following fields do not belong here, they can be removed when we use a queue for apptask restoreConfigJson VARCHAR(256), // used to pass backupId to restore from to apptask oldConfigJson TEXT, // used to pass old config to apptask (configure, restore) updateConfigJson TEXT, // used to pass new config to apptask (update) + FOREIGN KEY(taskId) REFERENCES tasks(id), PRIMARY KEY(id)); CREATE TABLE IF NOT EXISTS appPortBindings(