mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
c09c20ad8d
closes #2354 refs #1641 - added addUnique() - added dropUnique() - added addColumn() -> needed for #2330 - dropColumn() is missing due to lack of knex support - further cleanup of the migrations module
28 lines
No EOL
739 B
JavaScript
28 lines
No EOL
739 B
JavaScript
var _ = require('lodash'),
|
|
knex = require('../../models/base').knex;
|
|
|
|
function getTables() {
|
|
return knex.raw('show tables').then(function (response) {
|
|
return _.flatten(_.map(response[0], function (entry) {
|
|
return _.values(entry);
|
|
}));
|
|
});
|
|
}
|
|
|
|
function getIndexes(table) {
|
|
return knex.raw('SHOW INDEXES from ' + table).then(function (response) {
|
|
return _.flatten(_.pluck(response[0], 'Key_name'));
|
|
});
|
|
}
|
|
|
|
function getColumns(table) {
|
|
return knex.raw('SHOW COLUMNS FROM ' + table).then(function (response) {
|
|
return _.flatten(_.pluck(response[0], 'Field'));
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
getTables: getTables,
|
|
getIndexes: getIndexes,
|
|
getColumns: getColumns
|
|
}; |