mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Settings keys renames (#11948)
refs https://github.com/TryGhost/Ghost/issues/10318
- Adds following renames to settings table keys:
'default_locale' -> 'lang'
'active_timezone' -> 'timezone'
'ghost_head' -> 'codeinjection_head'
'ghost_foot' -> 'codeinjection_foot'
'brand.publicationColor' -> 'accent_color'
- The renames are done to match revised naming conventions and naming
exposed through APIs
- Supersedes this revert - 1eeb5a60b8
and #11946
This commit is contained in:
parent
5c800a6fe7
commit
2614565d5a
1 changed files with 82 additions and 0 deletions
|
@ -0,0 +1,82 @@
|
||||||
|
const logging = require('../../../../../shared/logging');
|
||||||
|
|
||||||
|
const renameMapping = [{
|
||||||
|
from: 'default_locale',
|
||||||
|
to: 'lang'
|
||||||
|
}, {
|
||||||
|
from: 'active_timezone',
|
||||||
|
to: 'timezone'
|
||||||
|
}, {
|
||||||
|
from: 'ghost_head',
|
||||||
|
to: 'codeinjection_head'
|
||||||
|
}, {
|
||||||
|
from: 'ghost_foot',
|
||||||
|
to: 'codeinjection_foot'
|
||||||
|
}];
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
config: {
|
||||||
|
transaction: true
|
||||||
|
},
|
||||||
|
|
||||||
|
async up(options) {
|
||||||
|
await Promise.map(renameMapping, async (renameMap) => {
|
||||||
|
logging.info(`Renaming ${renameMap.from} to ${renameMap.to}`);
|
||||||
|
|
||||||
|
return await options
|
||||||
|
.transacting('settings')
|
||||||
|
.where('key', renameMap.from)
|
||||||
|
.update({
|
||||||
|
key: renameMap.to
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const brandResult = await options
|
||||||
|
.transacting('settings')
|
||||||
|
.where('key', 'brand')
|
||||||
|
.select('value');
|
||||||
|
|
||||||
|
const value = JSON.parse(brandResult[0].value);
|
||||||
|
const accentColor = value.brand.primaryColor || '';
|
||||||
|
|
||||||
|
logging.info(`Updating brand.primaryColor in settings to accent_color with value '${accentColor}'`);
|
||||||
|
|
||||||
|
return await options
|
||||||
|
.transacting('settings')
|
||||||
|
.where('key', 'brand')
|
||||||
|
.update('key', 'accent_color')
|
||||||
|
.update('value', accentColor);
|
||||||
|
},
|
||||||
|
|
||||||
|
async down(options) {
|
||||||
|
await Promise.map(renameMapping, async (renameMap) => {
|
||||||
|
logging.info(`Renaming ${renameMap.to} to ${renameMap.from}`);
|
||||||
|
|
||||||
|
return await options
|
||||||
|
.transacting('settings')
|
||||||
|
.where('key', renameMap.to)
|
||||||
|
.update({
|
||||||
|
key: renameMap.from
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
let accentColor = await options
|
||||||
|
.transacting('settings')
|
||||||
|
.where('key', 'accent_color')
|
||||||
|
.select('value');
|
||||||
|
|
||||||
|
const primaryColor = accentColor[0].value || '';
|
||||||
|
|
||||||
|
logging.info(`Updating accent_color in settings to brand.primaryColor with value '${primaryColor}'`);
|
||||||
|
|
||||||
|
return await options
|
||||||
|
.transacting('settings')
|
||||||
|
.where('key', 'accent_color')
|
||||||
|
.update('key', 'brand')
|
||||||
|
.update('value', JSON.stringify({
|
||||||
|
brand: {
|
||||||
|
primaryColor
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
Loading…
Add table
Reference in a new issue