From 479df36a48183e6d23df125ca7e49c828cf5eccf Mon Sep 17 00:00:00 2001 From: Thibaut Patel Date: Mon, 7 Feb 2022 16:04:38 +0100 Subject: [PATCH] Added the `last_seen_at` column to members refs https://github.com/TryGhost/Team/issues/1304 - This migration adds a column to store when a members was last seen - The utils.js e2e test file was refactored according to the commit https://github.com/TryGhost/Ghost/commit/06dd9bac5957d4cd3415a3086c275b2a7501fe3e --- ...4-34-add-last-seen-at-column-to-members.js | 10 ++++++++ core/server/data/schema/schema.js | 1 + test/e2e-api/admin/utils.js | 24 ++++++++++++++----- .../unit/server/data/schema/integrity.test.js | 2 +- 4 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 core/server/data/migrations/versions/4.36/2022-02-07-14-34-add-last-seen-at-column-to-members.js diff --git a/core/server/data/migrations/versions/4.36/2022-02-07-14-34-add-last-seen-at-column-to-members.js b/core/server/data/migrations/versions/4.36/2022-02-07-14-34-add-last-seen-at-column-to-members.js new file mode 100644 index 0000000000..3b7a2fd6dc --- /dev/null +++ b/core/server/data/migrations/versions/4.36/2022-02-07-14-34-add-last-seen-at-column-to-members.js @@ -0,0 +1,10 @@ +const {createAddColumnMigration} = require('../../utils'); + +module.exports = createAddColumnMigration( + 'members', + 'last_seen_at', + { + type: 'dateTime', + nullable: true + } +); diff --git a/core/server/data/schema/schema.js b/core/server/data/schema/schema.js index 65248090fa..0b3b47cf7b 100644 --- a/core/server/data/schema/schema.js +++ b/core/server/data/schema/schema.js @@ -369,6 +369,7 @@ module.exports = { email_count: {type: 'integer', unsigned: true, nullable: false, defaultTo: 0}, email_opened_count: {type: 'integer', unsigned: true, nullable: false, defaultTo: 0}, email_open_rate: {type: 'integer', unsigned: true, nullable: true, index: true}, + last_seen_at: {type: 'dateTime',nullable: true}, created_at: {type: 'dateTime', nullable: false}, created_by: {type: 'string', maxlength: 24, nullable: false}, updated_at: {type: 'dateTime', nullable: true}, diff --git a/test/e2e-api/admin/utils.js b/test/e2e-api/admin/utils.js index 452a8054f6..0c55f6ab96 100644 --- a/test/e2e-api/admin/utils.js +++ b/test/e2e-api/admin/utils.js @@ -131,12 +131,24 @@ const expectedProperties = { subscriber: _(schema.subscribers) .keys() , - member: _(schema.members) - .keys() - .concat('avatar_image') - .concat('comped') - .concat('labels') - , + member: [ + 'id', + 'uuid', + 'email', + 'status', + 'name', + 'note', + 'geolocation', + 'subscribed', + 'email_count', + 'email_opened_count', + 'email_open_rate', + 'created_at', + 'updated_at', + 'avatar_image', + 'comped', + 'labels' + ], member_signin_url: ['member_id', 'url'], role: _(schema.roles) .keys() diff --git a/test/unit/server/data/schema/integrity.test.js b/test/unit/server/data/schema/integrity.test.js index 906c716263..53439fab72 100644 --- a/test/unit/server/data/schema/integrity.test.js +++ b/test/unit/server/data/schema/integrity.test.js @@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route */ describe('DB version integrity', function () { // Only these variables should need updating - const currentSchemaHash = '9e4eeb5c260047fe21d1f93c523bd771'; + const currentSchemaHash = 'c8442427463a0bf25ecca871b01016dc'; const currentFixturesHash = 'beb040c0376a492c2a44767fdd825a3e'; const currentSettingsHash = '437d4c6da8759f5c35f11f811b86e5bc'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';