2016-03-14 20:39:00 +03:00
|
|
|
var commands = require('../../schema').commands,
|
|
|
|
db = require('../../db'),
|
|
|
|
|
|
|
|
table = 'users',
|
2016-03-21 15:44:23 +03:00
|
|
|
column = 'tour',
|
|
|
|
message = 'Adding column: ' + table + '.' + column;
|
2016-03-14 20:39:00 +03:00
|
|
|
|
2016-03-21 15:44:23 +03:00
|
|
|
module.exports = function addTourColumnToUsers(logger) {
|
2016-03-14 20:39:00 +03:00
|
|
|
return db.knex.schema.hasTable(table).then(function (exists) {
|
|
|
|
if (exists) {
|
|
|
|
return db.knex.schema.hasColumn(table, column).then(function (exists) {
|
|
|
|
if (!exists) {
|
2016-03-21 15:44:23 +03:00
|
|
|
logger.info(message);
|
2016-03-14 20:39:00 +03:00
|
|
|
return commands.addColumn(table, column);
|
2016-03-21 15:44:23 +03:00
|
|
|
} else {
|
|
|
|
logger.warn(message);
|
2016-03-14 20:39:00 +03:00
|
|
|
}
|
|
|
|
});
|
2016-03-21 15:44:23 +03:00
|
|
|
} else {
|
|
|
|
// @TODO: this should probably be an error
|
|
|
|
logger.warn(message);
|
2016-03-14 20:39:00 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|