mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
24 lines
794 B
JavaScript
24 lines
794 B
JavaScript
var commands = require('../../schema').commands,
|
|
db = require('../../db'),
|
|
|
|
table = 'posts',
|
|
column = 'mobiledoc',
|
|
message = 'Adding column: ' + table + '.' + column;
|
|
|
|
module.exports = function addMobiledocColumnToPosts(logger) {
|
|
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);
|
|
}
|
|
});
|
|
};
|