Added temporary database table for analytic events (#13312)

refs https://github.com/TryGhost/Team/issues/1053

This table is going to be completely deleted at some point in the
future. It serves as a persistent datastore for a spike into collection
analytic events for members. We've opted for a generic table, rather
than a table for each event, so that we can push the DB to the limit in
terms of the length of the table, and find out performance issues A$AP
This commit is contained in:
Fabien 'egg' O'Carroll 2021-09-17 11:15:21 +02:00 committed by GitHub
parent ba587ba882
commit 2dca63eae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 2 deletions

View File

@ -0,0 +1,12 @@
const utils = require('../../utils');
module.exports = utils.addTable('temp_member_analytic_events', {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
event_name: {type: 'string', maxlength: 50, nullable: false},
created_at: {type: 'dateTime', nullable: false},
member_id: {type: 'string', maxlength: 24, nullable: false},
member_status: {type: 'string', maxlength: 50, nullable: false},
entry_id: {type: 'string', maxlength: 24, nullable: true},
source_url: {type: 'string', maxlength: 2000, nullable: true},
metadata: {type: 'string', maxlength: 191, nullable: true}
});

View File

@ -633,5 +633,15 @@ module.exports = {
created_by: {type: 'string', maxlength: 24, nullable: false},
updated_at: {type: 'dateTime', nullable: true},
updated_by: {type: 'string', maxlength: 24, nullable: true}
},
temp_member_analytic_events: {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
event_name: {type: 'string', maxlength: 50, nullable: false},
created_at: {type: 'dateTime', nullable: false},
member_id: {type: 'string', maxlength: 24, nullable: false},
member_status: {type: 'string', maxlength: 50, nullable: false},
entry_id: {type: 'string', maxlength: 24, nullable: true},
source_url: {type: 'string', maxlength: 2000, nullable: true},
metadata: {type: 'string', maxlength: 191, nullable: true}
}
};

View File

@ -0,0 +1,9 @@
const ghostBookshelf = require('./base');
const MemberAnalyticEvent = ghostBookshelf.Model.extend({
tableName: 'temp_member_analytic_events'
});
module.exports = {
MemberAnalyticEvent: ghostBookshelf.model('MemberAnalyticEvent', MemberAnalyticEvent)
};

View File

@ -43,6 +43,7 @@ describe('Exporter', function () {
'members_stripe_customers',
'members_stripe_customers_subscriptions',
'members_subscribe_events',
'temp_member_analytic_events',
'migrations',
'migrations_lock',
'mobiledoc_revisions',

View File

@ -173,10 +173,16 @@ describe('Exporter', function () {
} = require('../../../../core/server/data/exporter/table-lists.js');
const nonSchemaTables = ['migrations', 'migrations_lock'];
const requiredTables = schemaTables.concat(nonSchemaTables);
// NOTE: You should not add tables to this list unless they are temporary
const ignoredTables = ['temp_member_analytic_events'];
const expectedTables = requiredTables.filter(table => !ignoredTables.includes(table)).sort();
const actualTables = BACKUP_TABLES.concat(TABLES_ALLOWLIST).sort();
// NOTE: this test is serving a role of a reminder to have a look into exported tables allowlists
// if it failed you probably need to add or remove a table entry from table-lists module
[...Object.keys(schema.tables), ...nonSchemaTables].sort().should.eql([...BACKUP_TABLES, ...TABLES_ALLOWLIST].sort());
should.deepEqual(actualTables, expectedTables);
});
it('should be fixed when default settings is changed', function () {

View File

@ -32,7 +32,7 @@ const defaultSettings = require('../../../../core/server/data/schema/default-set
*/
describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = '98f6433d608dd44a30f59c243091f6aa';
const currentSchemaHash = '939c4993e183e0664362383a875cfc2d';
const currentFixturesHash = '8e04dbcb4b8e429e70989572fc9c67b9';
const currentSettingsHash = 'aa3fcbc8ab119b630aeda7366ead5493';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';