From 1581f439e9336b85ef66f03993e2d398cfa6b496 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Fri, 16 Sep 2022 10:19:05 +0100 Subject: [PATCH] Added `post_revisions` table (#15420) no issue - initially this will perform the same function as `mobiledoc_revisions` but storing `lexical` instead of `mobiledoc` - naming is intentionally generic ready for later expansions --- ghost/core/core/server/data/exporter/table-lists.js | 1 + .../5.15/2022-09-16-08-22-add-post-revisions-table.js | 9 +++++++++ ghost/core/core/server/data/schema/schema.js | 7 +++++++ ghost/core/test/integration/exporter/exporter.test.js | 1 + .../core/test/unit/server/data/schema/integrity.test.js | 2 +- 5 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 ghost/core/core/server/data/migrations/versions/5.15/2022-09-16-08-22-add-post-revisions-table.js diff --git a/ghost/core/core/server/data/exporter/table-lists.js b/ghost/core/core/server/data/exporter/table-lists.js index 9e977ab20f..c4c0f86940 100644 --- a/ghost/core/core/server/data/exporter/table-lists.js +++ b/ghost/core/core/server/data/exporter/table-lists.js @@ -21,6 +21,7 @@ const BACKUP_TABLES = [ 'tokens', 'sessions', 'mobiledoc_revisions', + 'post_revisions', 'email_batches', 'email_recipients', 'members_cancel_events', diff --git a/ghost/core/core/server/data/migrations/versions/5.15/2022-09-16-08-22-add-post-revisions-table.js b/ghost/core/core/server/data/migrations/versions/5.15/2022-09-16-08-22-add-post-revisions-table.js new file mode 100644 index 0000000000..40639ed5e9 --- /dev/null +++ b/ghost/core/core/server/data/migrations/versions/5.15/2022-09-16-08-22-add-post-revisions-table.js @@ -0,0 +1,9 @@ +const {addTable} = require('../../utils'); + +module.exports = addTable('post_revisions', { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + post_id: {type: 'string', maxlength: 24, nullable: false, index: true}, + lexical: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true}, + created_at_ts: {type: 'bigInteger', nullable: false}, + created_at: {type: 'dateTime', nullable: false} +}); diff --git a/ghost/core/core/server/data/schema/schema.js b/ghost/core/core/server/data/schema/schema.js index 628a54c318..85a751e104 100644 --- a/ghost/core/core/server/data/schema/schema.js +++ b/ghost/core/core/server/data/schema/schema.js @@ -387,6 +387,13 @@ module.exports = { created_at_ts: {type: 'bigInteger', nullable: false}, created_at: {type: 'dateTime', nullable: false} }, + post_revisions: { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + post_id: {type: 'string', maxlength: 24, nullable: false, index: true}, + lexical: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true}, + created_at_ts: {type: 'bigInteger', nullable: false}, + created_at: {type: 'dateTime', nullable: false} + }, members: { id: {type: 'string', maxlength: 24, nullable: false, primary: true}, uuid: {type: 'string', maxlength: 36, nullable: true, unique: true, validations: {isUUID: true}}, diff --git a/ghost/core/test/integration/exporter/exporter.test.js b/ghost/core/test/integration/exporter/exporter.test.js index 7f96e8fc44..6f8e9f7228 100644 --- a/ghost/core/test/integration/exporter/exporter.test.js +++ b/ghost/core/test/integration/exporter/exporter.test.js @@ -61,6 +61,7 @@ describe('Exporter', function () { 'permissions', 'permissions_roles', 'permissions_users', + 'post_revisions', 'posts', 'posts_authors', 'posts_meta', diff --git a/ghost/core/test/unit/server/data/schema/integrity.test.js b/ghost/core/test/unit/server/data/schema/integrity.test.js index a330dedd85..c64badea7c 100644 --- a/ghost/core/test/unit/server/data/schema/integrity.test.js +++ b/ghost/core/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 = '9cc4c1dae2237d960081d77aa4a528cc'; + const currentSchemaHash = 'cd7c94ce33c1e22b05335f05ab4fd86c'; const currentFixturesHash = '8cf221f0ed930ac1fe8030a58e60d64b'; const currentSettingsHash = '2978a5684a2d5fcf089f61f5d368a0c0'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';