mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Added new default free tier
refs https://github.com/TryGhost/Team/issues/1037 Free tier is now setup the same way as other tiers, to allow custom description/benefits. This change: - adds a migration to add a default free tier for all sites - adds a default fixture to insert a free tier for all new sites
This commit is contained in:
parent
761a330e16
commit
e54395eab5
2 changed files with 44 additions and 1 deletions
|
@ -0,0 +1,37 @@
|
||||||
|
const {createTransactionalMigration} = require('../../utils');
|
||||||
|
const ObjectID = require('bson-objectid');
|
||||||
|
const {slugify} = require('@tryghost/string');
|
||||||
|
const logging = require('@tryghost/logging');
|
||||||
|
|
||||||
|
module.exports = createTransactionalMigration(
|
||||||
|
async function up(knex) {
|
||||||
|
const [result] = await knex
|
||||||
|
.count('id', {as: 'total'})
|
||||||
|
.from('products')
|
||||||
|
.where('type', 'free');
|
||||||
|
|
||||||
|
if (result.total !== 0) {
|
||||||
|
logging.warn(`Not adding default free tier, a free tier already exists`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = 'Free';
|
||||||
|
const id = ObjectID().toHexString();
|
||||||
|
|
||||||
|
logging.info(`Adding tier "${name}"`);
|
||||||
|
await knex('products')
|
||||||
|
.insert({
|
||||||
|
id: id,
|
||||||
|
name: name,
|
||||||
|
type: 'free',
|
||||||
|
slug: slugify(id),
|
||||||
|
created_at: knex.raw(`CURRENT_TIMESTAMP`)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async function down(knex) {
|
||||||
|
logging.info('Removing free tier');
|
||||||
|
await knex('products')
|
||||||
|
.where('type', 'free')
|
||||||
|
.del();
|
||||||
|
}
|
||||||
|
);
|
|
@ -3,9 +3,15 @@
|
||||||
{
|
{
|
||||||
"name": "Product",
|
"name": "Product",
|
||||||
"entries": [
|
"entries": [
|
||||||
|
{
|
||||||
|
"name": "Free",
|
||||||
|
"slug": "free",
|
||||||
|
"type": "free"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Default Product",
|
"name": "Default Product",
|
||||||
"slug": "default-product"
|
"slug": "default-product",
|
||||||
|
"type": "paid"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue