mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Updated unsplash setting migration to be idempotent
refs https://github.com/TryGhost/Ghost/issues/10318 - Previous version of migration was not following the idempotence rule of migrations
This commit is contained in:
parent
e0cc314f91
commit
abb8c1df74
@ -2,6 +2,8 @@ const logging = require('../../../../../shared/logging');
|
||||
const {createIrreversibleMigration} = require('../../utils');
|
||||
|
||||
module.exports = createIrreversibleMigration(async (knex) => {
|
||||
logging.info('Updating unsplash setting value');
|
||||
|
||||
const unsplashSetting = await knex('settings')
|
||||
.select('value')
|
||||
.where({
|
||||
@ -10,6 +12,12 @@ module.exports = createIrreversibleMigration(async (knex) => {
|
||||
.first();
|
||||
|
||||
let isActive;
|
||||
|
||||
if (unsplashSetting && (unsplashSetting.value === 'true' || unsplashSetting.value === 'false')) {
|
||||
logging.warn(`Skipping update of unsplash value. Current value is already boolean: ${unsplashSetting.value}`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const value = JSON.parse(unsplashSetting.value);
|
||||
isActive = typeof value.isActive === 'boolean' ? value.isActive : true;
|
||||
|
Loading…
Reference in New Issue
Block a user