mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Migrated redirect settings to welcome_page_urls (#14083)
refs https://github.com/TryGhost/Team/issues/1168 This migrates the existing settings onto the Tier objects, so that users with Tiers enabled can seamless move from global settings to Tier level settings - without losing/modifying data/functionality.
This commit is contained in:
parent
dd7227d622
commit
155ee6055d
1 changed files with 45 additions and 0 deletions
|
@ -0,0 +1,45 @@
|
|||
const logging = require('@tryghost/logging');
|
||||
|
||||
// For DML - data changes
|
||||
const {createTransactionalMigration} = require('../../utils');
|
||||
|
||||
module.exports = createTransactionalMigration(
|
||||
async function up(knex) {
|
||||
logging.info('Setting welcome_page_url from settings');
|
||||
|
||||
const paidSignupRedirect = await knex('settings')
|
||||
.select('value')
|
||||
.where('key', 'members_paid_signup_redirect')
|
||||
.first();
|
||||
|
||||
const freeSignupRedirect = await knex('settings')
|
||||
.select('value')
|
||||
.where('key', 'members_free_signup_redirect')
|
||||
.first();
|
||||
|
||||
if (paidSignupRedirect) {
|
||||
logging.info(`Setting paid Tiers welcome_page_url to ${paidSignupRedirect.value}`);
|
||||
|
||||
await knex('products')
|
||||
.update('welcome_page_url', paidSignupRedirect.value)
|
||||
.where('type', 'paid');
|
||||
} else {
|
||||
logging.info(`No members_paid_signup_redirect setting found`);
|
||||
}
|
||||
|
||||
if (freeSignupRedirect) {
|
||||
logging.info(`Setting free Tiers welcome_page_url to ${freeSignupRedirect.value}`);
|
||||
|
||||
await knex('products')
|
||||
.update('welcome_page_url', freeSignupRedirect.value)
|
||||
.where('type', 'free');
|
||||
} else {
|
||||
logging.info(`No members_paid_signup_redirect setting found`);
|
||||
}
|
||||
},
|
||||
async function down(knex) {
|
||||
logging.info('Setting welcome_page_url to NULL');
|
||||
await knex('products')
|
||||
.update('welcome_page_url', null);
|
||||
}
|
||||
);
|
Loading…
Add table
Reference in a new issue