diff --git a/core/server/models/member-email-change-event.js b/core/server/models/member-email-change-event.js index 1e0071cbc7..7d04cd278f 100644 --- a/core/server/models/member-email-change-event.js +++ b/core/server/models/member-email-change-event.js @@ -2,7 +2,11 @@ const errors = require('@tryghost/errors'); const ghostBookshelf = require('./base'); const MemberEmailChangeEvent = ghostBookshelf.Model.extend({ - tableName: 'members_email_change_events' + tableName: 'members_email_change_events', + + member() { + return this.belongsTo('Member', 'member_id', 'id'); + } }, { async edit() { throw new errors.IncorrectUsageError('Cannot edit MemberEmailChangeEvent'); diff --git a/core/server/models/member-login-event.js b/core/server/models/member-login-event.js index 222401b62a..475d748e17 100644 --- a/core/server/models/member-login-event.js +++ b/core/server/models/member-login-event.js @@ -2,7 +2,11 @@ const errors = require('@tryghost/errors'); const ghostBookshelf = require('./base'); const MemberLoginEvent = ghostBookshelf.Model.extend({ - tableName: 'members_login_events' + tableName: 'members_login_events', + + member() { + return this.belongsTo('Member', 'member_id', 'id'); + } }, { async edit() { throw new errors.IncorrectUsageError('Cannot edit MemberLoginEvent'); diff --git a/core/server/models/member-paid-subscription-event.js b/core/server/models/member-paid-subscription-event.js index 072b6a45b6..b38747cf01 100644 --- a/core/server/models/member-paid-subscription-event.js +++ b/core/server/models/member-paid-subscription-event.js @@ -3,6 +3,11 @@ const ghostBookshelf = require('./base'); const MemberPaidSubscriptionEvent = ghostBookshelf.Model.extend({ tableName: 'members_paid_subscription_events', + + member() { + return this.belongsTo('Member', 'member_id', 'id'); + }, + customQuery(qb, options) { if (options.aggregateMRRDeltas) { if (options.limit || options.filter) { diff --git a/core/server/models/member-payment-event.js b/core/server/models/member-payment-event.js index 05e5622df9..f253a6f04f 100644 --- a/core/server/models/member-payment-event.js +++ b/core/server/models/member-payment-event.js @@ -3,6 +3,11 @@ const ghostBookshelf = require('./base'); const MemberPaymentEvent = ghostBookshelf.Model.extend({ tableName: 'members_payment_events', + + member() { + return this.belongsTo('Member', 'member_id', 'id'); + }, + customQuery(qb, options) { if (options.aggregatePaymentVolume) { if (options.limit || options.filter) { diff --git a/core/server/models/member-status-event.js b/core/server/models/member-status-event.js index 83af8add29..c5c3bc88de 100644 --- a/core/server/models/member-status-event.js +++ b/core/server/models/member-status-event.js @@ -3,6 +3,11 @@ const ghostBookshelf = require('./base'); const MemberStatusEvent = ghostBookshelf.Model.extend({ tableName: 'members_status_events', + + member() { + return this.belongsTo('Member', 'member_id', 'id'); + }, + customQuery(qb, options) { if (options.aggregateStatusCounts) { if (options.limit || options.filter) { diff --git a/core/server/models/member-subscribe-event.js b/core/server/models/member-subscribe-event.js index ef6abbb675..5a9164f9cd 100644 --- a/core/server/models/member-subscribe-event.js +++ b/core/server/models/member-subscribe-event.js @@ -3,6 +3,11 @@ const ghostBookshelf = require('./base'); const MemberSubscribeEvent = ghostBookshelf.Model.extend({ tableName: 'members_subscribe_events', + + member() { + return this.belongsTo('Member', 'member_id', 'id'); + }, + customQuery(qb, options) { if (options.aggregateSubscriptionDeltas) { if (options.limit || options.filter) {