0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Added benefits, offers and snippets to exporter

- These are more things that we should write an importer for
This commit is contained in:
Hannah Wolfe 2022-05-20 15:10:14 +01:00
parent 3471f6cca0
commit d6d6841186
No known key found for this signature in database
GPG key ID: AB586C3B5AE5C037
5 changed files with 35 additions and 14 deletions

View file

@ -1,5 +1,8 @@
const {BACKUP_TABLES, TABLES_ALLOWLIST} = require('./table-lists');
module.exports = { module.exports = {
doExport: require('./exporter'), doExport: require('./exporter'),
fileName: require('./export-filename'), fileName: require('./export-filename'),
BACKUP_TABLES: require('./table-lists').BACKUP_TABLES BACKUP_TABLES,
TABLES_ALLOWLIST
}; };

View file

@ -17,10 +17,7 @@ const BACKUP_TABLES = [
'permissions', 'permissions',
'permissions_roles', 'permissions_roles',
'permissions_users', 'permissions_users',
'benefits',
'products_benefits',
'webhooks', 'webhooks',
'snippets',
'tokens', 'tokens',
'sessions', 'sessions',
'mobiledoc_revisions', 'mobiledoc_revisions',
@ -34,9 +31,8 @@ const BACKUP_TABLES = [
'members_paid_subscription_events', 'members_paid_subscription_events',
'members_subscribe_events', 'members_subscribe_events',
'members_product_events', 'members_product_events',
'members_newsletters', 'members_newsletters'
'offers',
'offer_redemptions'
]; ];
// NOTE: exposing only tables which are going to be included in a "default" export file // NOTE: exposing only tables which are going to be included in a "default" export file
@ -57,7 +53,12 @@ const TABLES_ALLOWLIST = [
'stripe_products', 'stripe_products',
'stripe_prices', 'stripe_prices',
'posts_products', 'posts_products',
'newsletters' 'newsletters',
'benefits',
'products_benefits',
'offers',
'offer_redemptions',
'snippets'
]; ];
// NOTE: these are settings keys which should never end up in the export file // NOTE: these are settings keys which should never end up in the export file

View file

@ -14,6 +14,8 @@ const localUtils = require('./utils');
let request; let request;
let eventsTriggered; let eventsTriggered;
const TABLE_ALLOWLIST_LENGTH = 20;
describe('DB API (canary)', function () { describe('DB API (canary)', function () {
let backupKey; let backupKey;
let schedulerKey; let schedulerKey;
@ -52,8 +54,8 @@ describe('DB API (canary)', function () {
should.exist(jsonResponse.db); should.exist(jsonResponse.db);
jsonResponse.db.should.have.length(1); jsonResponse.db.should.have.length(1);
// NOTE: 16 default tables + 1 from include parameters // NOTE: default tables + 1 from include parameters
Object.keys(jsonResponse.db[0].data).length.should.eql(16); Object.keys(jsonResponse.db[0].data).length.should.eql(TABLE_ALLOWLIST_LENGTH + 1);
}); });
}); });

View file

@ -40,7 +40,7 @@ describe('Exporter', function () {
it('should try to export all the correct tables (without excluded)', function (done) { it('should try to export all the correct tables (without excluded)', function (done) {
exporter.doExport().then(function (exportData) { exporter.doExport().then(function (exportData) {
// NOTE: 15 default tables // NOTE: 15 default tables
const expectedCallCount = 15; const expectedCallCount = exporter.TABLES_ALLOWLIST.length;
should.exist(exportData); should.exist(exportData);
@ -67,7 +67,12 @@ describe('Exporter', function () {
'stripe_products', 'stripe_products',
'stripe_prices', 'stripe_prices',
'posts_products', 'posts_products',
'newsletters' 'newsletters',
'benefits',
'products_benefits',
'offers',
'offer_redemptions',
'snippets'
]; ];
for (let call = 0; call < expectedCallCount; call++) { for (let call = 0; call < expectedCallCount; call++) {
@ -86,7 +91,7 @@ describe('Exporter', function () {
exporter.doExport({include}).then(function (exportData) { exporter.doExport({include}).then(function (exportData) {
// NOTE: 15 default tables + 2 includes // NOTE: 15 default tables + 2 includes
const expectedCallCount = 17; const expectedCallCount = exporter.TABLES_ALLOWLIST.length + 2;
should.exist(exportData); should.exist(exportData);
@ -114,7 +119,12 @@ describe('Exporter', function () {
'stripe_products', 'stripe_products',
'stripe_prices', 'stripe_prices',
'posts_products', 'posts_products',
'newsletters' 'newsletters',
'benefits',
'products_benefits',
'offers',
'offer_redemptions',
'snippets'
].concat(include); ].concat(include);
for (let call = 0; call < expectedCallCount; call++) { for (let call = 0; call < expectedCallCount; call++) {

View file

@ -141,17 +141,22 @@ const exportedBodyLatest = () => {
version: '4.1.2' version: '4.1.2'
}, },
data: { data: {
benefits: [],
custom_theme_settings: [], custom_theme_settings: [],
newsletters: [], newsletters: [],
offers: [],
offer_redemptions: [],
posts: [], posts: [],
posts_authors: [], posts_authors: [],
posts_meta: [], posts_meta: [],
posts_products: [], posts_products: [],
posts_tags: [], posts_tags: [],
products: [], products: [],
products_benefits: [],
roles: [], roles: [],
roles_users: [], roles_users: [],
settings: [], settings: [],
snippets: [],
stripe_prices: [], stripe_prices: [],
stripe_products: [], stripe_products: [],
tags: [], tags: [],