2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

🐛 Fix ghost update with migrations (#8810)

no issue

- if you backup your database and you are in the middle of a transaction, the transaction was not fully forwarded
- we were running into a pool error in knex
This commit is contained in:
Katharina Irrgang 2017-08-01 17:27:13 +04:00 committed by Kevin Ansfield
parent 68803ae250
commit c9e3f8b180
3 changed files with 18 additions and 13 deletions

View file

@ -22,12 +22,13 @@ writeExportFile = function writeExportFile(exportResult) {
* does an export, and stores this in a local file
* @returns {Promise<*>}
*/
backup = function backup() {
backup = function backup(options) {
logging.info('Creating database backup');
options = options || {};
var props = {
data: exporter.doExport(),
filename: exporter.fileName()
data: exporter.doExport(options),
filename: exporter.fileName(options)
};
return Promise.props(props)

View file

@ -19,11 +19,11 @@ var _ = require('lodash'),
doExport,
exportFileName;
exportFileName = function exportFileName() {
exportFileName = function exportFileName(options) {
var datetime = (new Date()).toJSON().substring(0, 10),
title = '';
return models.Settings.findOne(_.merge({key: 'title'}, modelOptions)).then(function (result) {
return models.Settings.findOne({key: 'title'}, _.merge({}, modelOptions, options)).then(function (result) {
if (result) {
title = serverUtils.safeString(result.get('value')) + '.';
}
@ -35,29 +35,33 @@ exportFileName = function exportFileName() {
});
};
getVersionAndTables = function getVersionAndTables() {
getVersionAndTables = function getVersionAndTables(options) {
var props = {
version: ghostVersion.full,
tables: commands.getTables()
tables: commands.getTables(options.transacting)
};
return Promise.props(props);
};
exportTable = function exportTable(tableName) {
exportTable = function exportTable(tableName, options) {
if (excludedTables.indexOf(tableName) < 0) {
return db.knex(tableName).select();
return (options.transacting || db.knex)(tableName).select();
}
};
doExport = function doExport() {
doExport = function doExport(options) {
options = options || {};
var tables, version;
return getVersionAndTables().then(function exportAllTables(result) {
return getVersionAndTables(options).then(function exportAllTables(result) {
tables = result.tables;
version = result.version;
return Promise.mapSeries(tables, exportTable);
return Promise.mapSeries(tables, function (tableName) {
return exportTable(tableName, options);
});
}).then(function formatData(tableData) {
var exportData = {
meta: {

View file

@ -97,7 +97,7 @@ function getTables(transaction) {
var client = (transaction || db.knex).client.config.client;
if (_.includes(_.keys(clients), client)) {
return clients[client].getTables();
return clients[client].getTables(transaction);
}
return Promise.reject(i18n.t('notices.data.utils.index.noSupportForDatabase', {client: client}));