mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
be37070fb6
migration from usage of config() to just an object of config. no relevant issue - Change 'loadConfig' task to 'ensureConfig' to more accurately reflect what it is actually doing. Its sole purpose is to make sure a `config.js` file exists, and as such the name now reflects that purpose. - Update config/index.js to export the ghostConfig object directly so that it can be accessed from other modules - Update all references of config(). to config. This was a blind global find all and replace, treat it as such. - Fixes to tests to support new config access method - Allow each test to still work when invoked invidually
43 lines
No EOL
1.1 KiB
JavaScript
43 lines
No EOL
1.1 KiB
JavaScript
var _ = require('lodash'),
|
|
config = require('../../../config/index'),
|
|
|
|
//private
|
|
doRaw,
|
|
|
|
// public
|
|
getTables,
|
|
getIndexes,
|
|
getColumns;
|
|
|
|
|
|
doRaw = function doRaw(query, fn) {
|
|
return config.database.knex.raw(query).then(function (response) {
|
|
return fn(response);
|
|
});
|
|
};
|
|
|
|
getTables = function getTables() {
|
|
return doRaw('select * from sqlite_master where type = "table"', function (response) {
|
|
return _.reject(_.pluck(response, 'tbl_name'), function (name) {
|
|
return name === 'sqlite_sequence';
|
|
});
|
|
});
|
|
};
|
|
|
|
getIndexes = function getIndexes(table) {
|
|
return doRaw('pragma index_list("' + table + '")', function (response) {
|
|
return _.flatten(_.pluck(response, 'name'));
|
|
});
|
|
};
|
|
|
|
getColumns = function getColumns(table) {
|
|
return doRaw('pragma table_info("' + table + '")', function (response) {
|
|
return _.flatten(_.pluck(response, 'name'));
|
|
});
|
|
};
|
|
|
|
module.exports = {
|
|
getTables: getTables,
|
|
getIndexes: getIndexes,
|
|
getColumns: getColumns
|
|
}; |