Added posts.lexical database field (#15397)

closes https://github.com/TryGhost/Team/issues/1884

- adds `post.lexical` ready for use by the lexical-powered editor re-write
- fulfils the same purpose as `posts.mobiledoc` so uses the same field properties
- added `lexical` to allowed formats in Post model so it won't be included by default in API responses meaning tests/snapshots don't need updating at present
This commit is contained in:
Kevin Ansfield 2022-09-13 11:21:47 +01:00 committed by GitHub
parent 890279a95b
commit 8cdd2e10b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 2 deletions

View File

@ -0,0 +1,8 @@
const {createAddColumnMigration} = require('../../utils');
module.exports = createAddColumnMigration('posts', 'lexical', {
type: 'text',
maxlength: 1000000000,
fieldtype: 'long',
nullable: true
});

View File

@ -45,6 +45,7 @@ module.exports = {
title: {type: 'string', maxlength: 2000, nullable: false, validations: {isLength: {max: 255}}}, title: {type: 'string', maxlength: 2000, nullable: false, validations: {isLength: {max: 255}}},
slug: {type: 'string', maxlength: 191, nullable: false}, slug: {type: 'string', maxlength: 191, nullable: false},
mobiledoc: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true}, mobiledoc: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
lexical: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
html: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true}, html: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
comment_id: {type: 'string', maxlength: 50, nullable: true}, comment_id: {type: 'string', maxlength: 50, nullable: true},
plaintext: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true}, plaintext: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},

View File

@ -974,7 +974,7 @@ Post = ghostBookshelf.Model.extend({
return filter; return filter;
} }
}, { }, {
allowedFormats: ['mobiledoc', 'html', 'plaintext'], allowedFormats: ['mobiledoc', 'lexical', 'html', 'plaintext'],
orderDefaultOptions: function orderDefaultOptions() { orderDefaultOptions: function orderDefaultOptions() {
return { return {

View File

@ -12,6 +12,7 @@ module.exports = [
exclude: [ exclude: [
'title', 'title',
'mobiledoc', 'mobiledoc',
'lexical',
'html', 'html',
'plaintext', 'plaintext',
// @TODO: https://github.com/TryGhost/Ghost/issues/10335 // @TODO: https://github.com/TryGhost/Ghost/issues/10335
@ -55,6 +56,7 @@ module.exports = [
exclude: [ exclude: [
'title', 'title',
'mobiledoc', 'mobiledoc',
'lexical',
'html', 'html',
'plaintext', 'plaintext',
// @TODO: https://github.com/TryGhost/Ghost/issues/10335 // @TODO: https://github.com/TryGhost/Ghost/issues/10335

View File

@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
*/ */
describe('DB version integrity', function () { describe('DB version integrity', function () {
// Only these variables should need updating // Only these variables should need updating
const currentSchemaHash = '823828c5eafb58c0916307d41e834538'; const currentSchemaHash = '9cc4c1dae2237d960081d77aa4a528cc';
const currentFixturesHash = '8cf221f0ed930ac1fe8030a58e60d64b'; const currentFixturesHash = '8cf221f0ed930ac1fe8030a58e60d64b';
const currentSettingsHash = 'd54210758b7054e2174fd34aa2320ad7'; const currentSettingsHash = 'd54210758b7054e2174fd34aa2320ad7';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';