mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05: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
1 changed files with 8 additions and 0 deletions
|
@ -2,6 +2,8 @@ const logging = require('../../../../../shared/logging');
|
||||||
const {createIrreversibleMigration} = require('../../utils');
|
const {createIrreversibleMigration} = require('../../utils');
|
||||||
|
|
||||||
module.exports = createIrreversibleMigration(async (knex) => {
|
module.exports = createIrreversibleMigration(async (knex) => {
|
||||||
|
logging.info('Updating unsplash setting value');
|
||||||
|
|
||||||
const unsplashSetting = await knex('settings')
|
const unsplashSetting = await knex('settings')
|
||||||
.select('value')
|
.select('value')
|
||||||
.where({
|
.where({
|
||||||
|
@ -10,6 +12,12 @@ module.exports = createIrreversibleMigration(async (knex) => {
|
||||||
.first();
|
.first();
|
||||||
|
|
||||||
let isActive;
|
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 {
|
try {
|
||||||
const value = JSON.parse(unsplashSetting.value);
|
const value = JSON.parse(unsplashSetting.value);
|
||||||
isActive = typeof value.isActive === 'boolean' ? value.isActive : true;
|
isActive = typeof value.isActive === 'boolean' ? value.isActive : true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue