0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server/data/migration/005/02-add-visibility-column-to-key-tables.js
Hannah Wolfe e7cc18d5fb Add visibility column to posts, tags and users
refs #6301, #6165

- visibility is added as a new column on posts, tags and users.
- has a relevant default value for each table
2016-04-14 18:59:14 +01:00

27 lines
988 B
JavaScript

var Promise = require('bluebird'),
commands = require('../../schema').commands,
db = require('../../db'),
tables = ['posts', 'tags', 'users'],
column = 'visibility';
module.exports = function addVisibilityColumnToKeyTables(logger) {
return Promise.mapSeries(tables, function (table) {
var message = 'Adding column: ' + table + '.' + column;
return db.knex.schema.hasTable(table).then(function (exists) {
if (exists) {
return db.knex.schema.hasColumn(table, column).then(function (exists) {
if (!exists) {
logger.info(message);
return commands.addColumn(table, column);
} else {
logger.warn(message);
}
});
} else {
// @TODO: this should probably be an error
logger.warn(message);
}
});
});
};