0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00
ghost/core/server/data/migration/004/05-drop-unique-on-clients-secret.js
Hannah Wolfe 0ad93c3df2 Rewrite DB update to be explicit
refs #6301

- Replace builder & automated database upgrade with a set of explicit tasks
- Ensure the tasks can only happen if they need to
- Remove some duplicate code between fixture & db upgrades (more to do)
- Add tests
2016-03-17 21:17:19 +00:00

18 lines
634 B
JavaScript

var commands = require('../../schema').commands,
db = require('../../db'),
table = 'clients',
column = 'secret';
module.exports = function dropUniqueOnClientsSecret(logInfo) {
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) {
logInfo('Dropping unique on: ' + table + '.' + column);
return commands.dropUnique(table, column);
}
});
}
});
};