0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/server/data/migration/004/05-drop-unique-on-clients-secret.js
Hannah Wolfe 84f387785a Migration messaging improvements
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
2016-03-22 09:59:22 +00:00

24 lines
834 B
JavaScript

var commands = require('../../schema').commands,
db = require('../../db'),
table = 'clients',
column = 'secret',
message = 'Dropping unique on: ' + table + '.' + column;
module.exports = function dropUniqueOnClientsSecret(logger) {
return db.knex.schema.hasTable(table).then(function (exists) {
if (exists) {
return commands.getIndexes(table).then(function (indexes) {
if (indexes.indexOf(table + '_' + column + '_unique') > -1) {
logger.info(message);
return commands.dropUnique(table, column);
} else {
logger.warn(message);
}
});
} else {
// @TODO: this should probably be an error
logger.warn(message);
}
});
};