0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Added comments.in_reply_to_id column migration

ref https://linear.app/tryghost/issue/PLG-230

- `comments.in_reply_to_id` will be used to keep a reference to the comment that the new comment was directed at
- used only for replies-to-replies, will be `null` for the top-level parent and `null` for any replies directly to that parent
- technically allows for infinite nesting within a parent comment thread but we won't be using that ability for now
- `comments.parent_id` will be kept as it provides a useful optimisation for loading the top-level comments list
- we're not using `comments.parent_id` for this to keep complexity down and avoid the need for recursive lookups
This commit is contained in:
Kevin Ansfield 2024-09-26 16:58:11 +01:00
parent 6dc2e7f3fe
commit f9b0280553
3 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,10 @@
const {createAddColumnMigration} = require('../../utils');
module.exports = createAddColumnMigration('comments', 'in_reply_to_id', {
type: 'string',
maxlength: 24,
nullable: true,
unique: false,
references: 'comments.id',
setNullDelete: true
});

View file

@ -958,6 +958,7 @@ module.exports = {
post_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'posts.id', cascadeDelete: true},
member_id: {type: 'string', maxlength: 24, nullable: true, unique: false, references: 'members.id', setNullDelete: true},
parent_id: {type: 'string', maxlength: 24, nullable: true, unique: false, references: 'comments.id', cascadeDelete: true},
in_reply_to_id: {type: 'string', maxlength: 24, nullable: true, unique: false, references: 'comments.id', setNullDelete: true},
status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'published', validations: {isIn: [['published', 'hidden', 'deleted']]}},
html: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
edited_at: {type: 'dateTime', nullable: true},

View file

@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
*/
describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = '1110f25f639c22135b9845c72f0be7ef';
const currentSchemaHash = 'f12341a0c74998eeb4628322fd0982fb';
const currentFixturesHash = '475f488105c390bb0018db90dce845f1';
const currentSettingsHash = '47a75e8898fab270174a0c905cb3e914';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';