mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Added migration to update Default Tier name
refs https://github.com/TryGhost/Team/issues/1289 This ensures that we set the default tier's name to the title of the site - which looks a lot better than "Default Product".
This commit is contained in:
parent
594df729e1
commit
8915d15a1d
@ -31,6 +31,7 @@ module.exports = class StripeMigrations {
|
||||
await this.populateDefaultProductYearlyPriceId();
|
||||
await this.revertPortalPlansSetting();
|
||||
await this.removeInvalidSubscriptions();
|
||||
await this.setDefaultProductName();
|
||||
}
|
||||
|
||||
async populateProductsAndPrices(options) {
|
||||
@ -543,4 +544,32 @@ module.exports = class StripeMigrations {
|
||||
logging.info(`No invalid subscriptions, skipping migration`);
|
||||
}
|
||||
}
|
||||
|
||||
async setDefaultProductName(options) {
|
||||
if (!options) {
|
||||
return this.models.Product.transaction((transacting) => {
|
||||
return this.setDefaultProductName({transacting});
|
||||
});
|
||||
}
|
||||
|
||||
const {data} = await this.models.Product.findPage({
|
||||
...options,
|
||||
limit: 1,
|
||||
filter: 'type:paid'
|
||||
});
|
||||
|
||||
const defaultProduct = data[0] && data[0].toJSON();
|
||||
|
||||
if (defaultProduct && defaultProduct.name === 'Default Product') {
|
||||
const siteTitle = await this.models.Settings.findOne({key: 'title'}, options);
|
||||
if (siteTitle) {
|
||||
await this.models.Product.edit({
|
||||
name: siteTitle.get('value')
|
||||
}, {
|
||||
...options,
|
||||
id: defaultProduct.id
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user