mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 03:14:03 +03:00
Added the MemberCancelEvent model
refs https://github.com/TryGhost/Team/issues/1302 - This event stores the members' subscription cancelations.
This commit is contained in:
parent
49d393c88f
commit
4ce9a5a167
@ -31,6 +31,7 @@ const BACKUP_TABLES = [
|
||||
'mobiledoc_revisions',
|
||||
'email_batches',
|
||||
'email_recipients',
|
||||
'members_cancel_events',
|
||||
'members_payment_events',
|
||||
'members_login_events',
|
||||
'members_email_change_events',
|
||||
|
@ -0,0 +1,8 @@
|
||||
const {addTable} = require('../../utils');
|
||||
|
||||
module.exports = addTable('members_cancel_events', {
|
||||
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
||||
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
|
||||
from_plan: {type: 'string', maxlength: 255, nullable: false},
|
||||
created_at: {type: 'dateTime', nullable: false}
|
||||
});
|
@ -438,6 +438,12 @@ module.exports = {
|
||||
product_id: {type: 'string', maxlength: 24, nullable: false, references: 'products.id', cascadeDelete: true},
|
||||
sort_order: {type: 'integer', nullable: false, unsigned: true, defaultTo: 0}
|
||||
},
|
||||
members_cancel_events: {
|
||||
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
||||
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
|
||||
from_plan: {type: 'string', maxlength: 255, nullable: false},
|
||||
created_at: {type: 'dateTime', nullable: false}
|
||||
},
|
||||
members_payment_events: {
|
||||
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
||||
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
|
||||
|
28
core/server/models/member-cancel-event.js
Normal file
28
core/server/models/member-cancel-event.js
Normal file
@ -0,0 +1,28 @@
|
||||
const errors = require('@tryghost/errors');
|
||||
const ghostBookshelf = require('./base');
|
||||
|
||||
const MemberCancelEvent = ghostBookshelf.Model.extend({
|
||||
tableName: 'members_cancel_events',
|
||||
|
||||
member() {
|
||||
return this.belongsTo('Member', 'member_id', 'id');
|
||||
}
|
||||
}, {
|
||||
async edit() {
|
||||
throw new errors.IncorrectUsageError({message: 'Cannot edit MemberCancelEvent'});
|
||||
},
|
||||
|
||||
async destroy() {
|
||||
throw new errors.IncorrectUsageError({message: 'Cannot destroy MemberCancelEvent'});
|
||||
}
|
||||
});
|
||||
|
||||
const MemberCancelEvents = ghostBookshelf.Collection.extend({
|
||||
model: MemberCancelEvent
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
MemberCancelEvent: ghostBookshelf.model('MemberCancelEvent', MemberCancelEvent),
|
||||
MemberCancelEvents: ghostBookshelf.collection('MemberCancelEvents', MemberCancelEvents)
|
||||
};
|
||||
|
@ -33,6 +33,7 @@ describe('Exporter', function () {
|
||||
'invites',
|
||||
'labels',
|
||||
'members',
|
||||
'members_cancel_events',
|
||||
'members_email_change_events',
|
||||
'members_labels',
|
||||
'members_login_events',
|
||||
@ -91,6 +92,7 @@ describe('Exporter', function () {
|
||||
'mobiledoc_revisions',
|
||||
'email_batches',
|
||||
'email_recipients',
|
||||
'members_cancel_events',
|
||||
'members_payment_events',
|
||||
'members_login_events',
|
||||
'members_email_change_events',
|
||||
|
@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
|
||||
*/
|
||||
describe('DB version integrity', function () {
|
||||
// Only these variables should need updating
|
||||
const currentSchemaHash = '821b2327490e3bebdc62cd54d12932e0';
|
||||
const currentSchemaHash = 'b7867be4de694b4592d748c0367064b5';
|
||||
const currentFixturesHash = '84be2bb1d62b384260b72ebfc20f81dc';
|
||||
const currentSettingsHash = '71fa38d0c805c18ceebe0fda80886230';
|
||||
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
||||
|
Loading…
Reference in New Issue
Block a user