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

Added comments table creation migration (#14998)

refs https://github.com/TryGhost/Team/issues/1664

Field notes:

- `parent_id` - used for nested comments but will be limited to 1 level in app-level validation
- `member_id` - when a member is deleted for now the member id is kept but in the future may be removed, hence `nullable: true`
- `status` - "hidden" status will be used when a staff user hides a comment, "deleted" is used when a comment author deletes
- `html` - will store pre-sanitised html
- `edited_at` - used to show an "X edited at Y" note when displaying comments, separate to `updated_at` because changing the status would also change `updated_at` but shouldn't show the "edited at" UI
This commit is contained in:
Kevin Ansfield 2022-07-05 11:17:17 +02:00 committed by Hannah Wolfe
parent 6d521cc14c
commit 799a42062c
5 changed files with 28 additions and 3 deletions

View file

@ -31,8 +31,8 @@ const BACKUP_TABLES = [
'members_paid_subscription_events',
'members_subscribe_events',
'members_product_events',
'members_newsletters'
'members_newsletters',
'comments'
];
// NOTE: exposing only tables which are going to be included in a "default" export file

View file

@ -0,0 +1,13 @@
const {addTable} = require('../../utils');
module.exports = addTable('comments', {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
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'},
parent_id: {type: 'string', maxlength: 24, nullable: true, unique: false, references: 'comments.id'},
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},
created_at: {type: 'dateTime', nullable: false},
updated_at: {type: 'dateTime', nullable: false}
});

View file

@ -742,5 +742,16 @@ module.exports = {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
newsletter_id: {type: 'string', maxlength: 24, nullable: false, references: 'newsletters.id', cascadeDelete: true}
},
comments: {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
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'},
parent_id: {type: 'string', maxlength: 24, nullable: true, unique: false, references: 'comments.id'},
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},
created_at: {type: 'dateTime', nullable: false},
updated_at: {type: 'dateTime', nullable: false}
}
};

View file

@ -25,6 +25,7 @@ describe('Exporter', function () {
'actions',
'api_keys',
'brute',
'comments',
'custom_theme_settings',
'email_batches',
'email_recipients',

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 = '2f4266e6e5087ad92dd30f3e721d46e5';
const currentSchemaHash = 'b582244f25b7e33b7cdda20427f79702';
const currentFixturesHash = '1d6562a1963a9b9d10d06070d537f11f';
const currentSettingsHash = '0b138cdd40e48b5b7dc4ebac2a7819a7';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';