mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
refs #6301 - fix messages that joined with comma and therefore missed outputting version no - change `logInfo` to `logger` that has both an info and a warn method - add new warn method to errors - add a warn message everytime a migration (data or fixture) gets skipped over - update logger everywhere, including tests - update tests to check logger.warn gets called
27 lines
1 KiB
JavaScript
27 lines
1 KiB
JavaScript
var Promise = require('bluebird'),
|
|
commands = require('../../schema').commands,
|
|
db = require('../../db'),
|
|
|
|
table = 'clients',
|
|
columns = ['redirection_uri', 'logo', 'status', 'type', 'description'];
|
|
|
|
module.exports = function addManyColumnsToClients(logger) {
|
|
return db.knex.schema.hasTable(table).then(function (exists) {
|
|
if (exists) {
|
|
return Promise.mapSeries(columns, function (column) {
|
|
var message = 'Adding column: ' + table + '.' + column;
|
|
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('Adding columns to table: ' + table);
|
|
}
|
|
});
|
|
};
|