mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
Removed use of deprecated new Error() syntax
refs2f1123d6ca
refs6f1a3e1774
- The use of new Error() has been deprecated. Refactoring the migration to use `createIrreversibleMigration` made most sense to have central error handling for migration which are not meant to be reverted.
This commit is contained in:
parent
bfb899b293
commit
8f5d6ebf8c
@ -1,28 +1,24 @@
|
||||
const logging = require('@tryghost/logging');
|
||||
const {createIrreversibleMigration} = require('../../utils');
|
||||
|
||||
module.exports = {
|
||||
async up({connection}) {
|
||||
let result = await connection('settings')
|
||||
.where('key', '=', 'labs')
|
||||
.select('value');
|
||||
module.exports = createIrreversibleMigration(async (knex) => {
|
||||
let result = await knex('settings')
|
||||
.where('key', '=', 'labs')
|
||||
.select('value');
|
||||
|
||||
if (!result || !result[0]) {
|
||||
logging.warn(`Could not find labs setting`);
|
||||
result = [{}];
|
||||
}
|
||||
|
||||
const labs = JSON.parse(result[0].value);
|
||||
|
||||
labs.members = !!labs.members || !!labs.subscribers;
|
||||
|
||||
logging.info(`Updating labs setting removing subscribers (was ${labs.subscribers}) settings members to ${labs.members}`);
|
||||
labs.subscribers = undefined;
|
||||
|
||||
await connection('settings')
|
||||
.where('key', '=', 'labs')
|
||||
.update('value', JSON.stringify(labs));
|
||||
},
|
||||
async down() {
|
||||
throw new Error();
|
||||
if (!result || !result[0]) {
|
||||
logging.warn(`Could not find labs setting`);
|
||||
result = [{}];
|
||||
}
|
||||
};
|
||||
|
||||
const labs = JSON.parse(result[0].value);
|
||||
|
||||
labs.members = !!labs.members || !!labs.subscribers;
|
||||
|
||||
logging.info(`Updating labs setting removing subscribers (was ${labs.subscribers}) settings members to ${labs.members}`);
|
||||
labs.subscribers = undefined;
|
||||
|
||||
await knex('settings')
|
||||
.where('key', '=', 'labs')
|
||||
.update('value', JSON.stringify(labs));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user