0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/server/data/utils/sqlite3.js
Sebastian Gierlinger c09c20ad8d Allow schema changes
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
2014-06-12 17:25:55 +02:00

29 lines
No EOL
802 B
JavaScript

var _ = require('lodash'),
knex = require('../../models/base').knex;
function getTables() {
return knex.raw("select * from sqlite_master where type = 'table'").then(function (response) {
return _.reject(_.pluck(response, 'tbl_name'), function (name) {
return name === 'sqlite_sequence';
});
});
}
function getIndexes(table) {
return knex.raw("pragma index_list('" + table + "')").then(function (response) {
return _.flatten(_.pluck(response, 'name'));
});
}
function getColumns(table) {
return knex.raw("pragma table_info('" + table + "')").then(function (response) {
return _.flatten(_.pluck(response, 'name'));
});
}
module.exports = {
getTables: getTables,
getIndexes: getIndexes,
getColumns: getColumns
};