Added ability to pass 'flags' field into new settings

refs 3b90b1f335
refs https://github.com/TryGhost/Team/issues/3011

- The "flags" property was missing from the allowed parameters in addSettings migrations utility method. Passing in "flags" is needed to complete a refed issue where we add a new "announcement" group of settings and two of these settings have a "PUBLIC" flag
This commit is contained in:
Naz 2023-04-19 14:02:03 +02:00
parent a9974742cc
commit 7969399cdf
No known key found for this signature in database

View File

@ -6,11 +6,15 @@ const {MIGRATION_USER} = require('./constants');
/**
* Creates a migration which will insert a new setting in settings table
* @param {object} settingSpec - setting key, value, group and type
*
* @param {object} settingSpec - setting type and group
* @param {string} settingSpec.key - settings key
* @param {*} settingSpec.value - settings value
* @param {'array' | 'string' | 'number' | 'boolean' | 'object'} settingSpec.type - settings type
* @param {string} settingSpec.group - settings group
* @param {'PUBLIC' | 'RO' | 'PUBLIC,RO'} [settingSpec.flags] - settings flag
* @returns {Object} migration object returning config/up/down properties
*/
function addSetting({key, value, type, group}) {
function addSetting({key, value, type, group, flags = null}) {
return createTransactionalMigration(
async function up(connection) {
const settingExists = await connection('settings')
@ -31,6 +35,7 @@ function addSetting({key, value, type, group}) {
value,
group,
type,
flags,
created_at: now,
created_by: MIGRATION_USER
});