0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00
ghost/core/server/data/migration/004/03-add-many-columns-to-clients.js

22 lines
785 B
JavaScript
Raw Normal View History

var Promise = require('bluebird'),
commands = require('../../schema').commands,
db = require('../../db'),
table = 'clients',
columns = ['redirection_uri', 'logo', 'status', 'type', 'description'];
module.exports = function addManyColumnsToClients(logInfo) {
return db.knex.schema.hasTable(table).then(function (exists) {
if (exists) {
return Promise.mapSeries(columns, function (column) {
return db.knex.schema.hasColumn(table, column).then(function (exists) {
if (!exists) {
logInfo('Adding column: ' + table + '.' + column);
return commands.addColumn(table, column);
}
});
});
}
});
};