Skip to content

Commit

Permalink
Added comments.in_reply_to_id column migration
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kevinansfield committed Nov 6, 2024
1 parent cd8d581 commit 8b5f278
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
});
1 change: 1 addition & 0 deletions ghost/core/core/server/data/schema/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion ghost/core/test/unit/server/data/schema/integrity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 8b5f278

Please sign in to comment.