0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Enhanced 2.18 detection (#10610)

no issue

- discovered another case
This commit is contained in:
Katharina Irrgang 2019-03-13 23:40:50 +01:00 committed by GitHub
parent ca16b197a2
commit a2f7160499
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,6 +13,7 @@ module.exports.config = {
const backupFileRegex = /ghost.([\d]{4}-[\d]{2}-[\d]{2}).json$/;
// @NOTE: spagetthi
module.exports.up = (options) => {
const contentPath = config.get('paths').contentPath;
const dataPath = path.join(contentPath, 'data');
@ -53,22 +54,23 @@ module.exports.up = (options) => {
return;
}
const settings = backup && backup.data && backup.data.settings;
const migrations = backup && backup.data && backup.data.migrations;
if (!settings) {
common.logging.warn('Could not read settings from backup file, skipping...');
return;
}
if (!migrations || !migrations.length) {
common.logging.warn('Skipping migration. Not affected.');
return localOptions
.transacting('migrations')
.then((response) => {
if (!response) {
common.logging.warn('Cannot find migrations.');
return;
}
// NOTE: If we you have a backup file which has 2.16, but not 2.17, you are affected
// NOTE: We have corrected 2.17. If you jump form 2.16 to 2.18, you are good
const isAffected = _.find(migrations, {version: '2.16'}) &&
!_.find(migrations, {version: '2.17'});
// NOTE: You are only affected if you migrated to 2.17
// 2.18 fixed the 2.17 migration (!)
const isAffected = _.find(response, {currentVersion: '2.17', version: '2.17'});
if (!isAffected) {
common.logging.warn('Skipping migration. Not affected.');
@ -128,4 +130,5 @@ module.exports.up = (options) => {
});
});
});
});
};