mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Added email_only column to posts_meta table
closes https://github.com/TryGhost/Team/issues/893 - We need a place to store email-only flag and posts_meta is the best place for it
This commit is contained in:
parent
7ac8765170
commit
755a3a320e
7 changed files with 23 additions and 4 deletions
|
@ -52,7 +52,8 @@ const mapPost = (model, frame) => {
|
|||
_(metaAttrs).filter((k) => {
|
||||
return (!frame.options.columns || (frame.options.columns && frame.options.columns.includes(k)));
|
||||
}).each((attr) => {
|
||||
jsonModel[attr] = _.get(jsonModel.posts_meta, attr) || null;
|
||||
const defaultValue = (attr === 'email_only') ? false : null;
|
||||
jsonModel[attr] = _.get(jsonModel.posts_meta, attr) || defaultValue;
|
||||
});
|
||||
delete jsonModel.posts_meta;
|
||||
|
||||
|
@ -89,6 +90,7 @@ const mapPage = (model, frame) => {
|
|||
|
||||
delete jsonModel.email_subject;
|
||||
delete jsonModel.email_recipient_filter;
|
||||
delete jsonModel.email_only;
|
||||
|
||||
return jsonModel;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
const {createAddColumnMigration} = require('../../utils');
|
||||
|
||||
module.exports = createAddColumnMigration('posts_meta', 'email_only', {
|
||||
type: 'bool',
|
||||
nullable: false,
|
||||
defaultTo: false
|
||||
});
|
|
@ -74,7 +74,8 @@ module.exports = {
|
|||
email_subject: {type: 'string', maxlength: 300, nullable: true},
|
||||
frontmatter: {type: 'text', maxlength: 65535, nullable: true},
|
||||
feature_image_alt: {type: 'string', maxlength: 191, nullable: true, validations: {isLength: {max: 125}}},
|
||||
feature_image_caption: {type: 'text', maxlength: 65535, nullable: true}
|
||||
feature_image_caption: {type: 'text', maxlength: 65535, nullable: true},
|
||||
email_only: {type: 'bool', nullable: false, defaultTo: false}
|
||||
},
|
||||
users: {
|
||||
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
||||
|
|
|
@ -4,6 +4,12 @@ const urlUtils = require('../../shared/url-utils');
|
|||
const PostsMeta = ghostBookshelf.Model.extend({
|
||||
tableName: 'posts_meta',
|
||||
|
||||
defaults: function defaults() {
|
||||
return {
|
||||
email_only: false
|
||||
};
|
||||
},
|
||||
|
||||
formatOnWrite(attrs) {
|
||||
['og_image', 'twitter_image'].forEach((attr) => {
|
||||
if (attrs[attr]) {
|
||||
|
|
|
@ -39,6 +39,8 @@ describe('Posts API', function () {
|
|||
localUtils.API.checkResponse(jsonResponse.posts[0], 'post');
|
||||
localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
|
||||
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
|
||||
_.isBoolean(jsonResponse.posts[0].email_only).should.eql(true);
|
||||
jsonResponse.posts[0].email_only.should.eql(false);
|
||||
|
||||
// Ensure default order
|
||||
jsonResponse.posts[0].slug.should.eql('scheduled-post');
|
||||
|
|
|
@ -69,7 +69,8 @@ const expectedProperties = {
|
|||
'meta_title',
|
||||
'meta_description',
|
||||
'email_subject',
|
||||
'frontmatter'
|
||||
'frontmatter',
|
||||
'email_only'
|
||||
],
|
||||
|
||||
page: [
|
||||
|
|
|
@ -32,7 +32,7 @@ const defaultSettings = require('../../../../core/server/data/schema/default-set
|
|||
*/
|
||||
describe('DB version integrity', function () {
|
||||
// Only these variables should need updating
|
||||
const currentSchemaHash = 'a2248eaa72a9d08c3753b90a9436dbe3';
|
||||
const currentSchemaHash = '6becb030fb054078d95f927bcfcd4f5e';
|
||||
const currentFixturesHash = '97283c575b1f6c84c27db6e1b1be21d4';
|
||||
const currentSettingsHash = 'aa3fcbc8ab119b630aeda7366ead5493';
|
||||
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
||||
|
|
Loading…
Add table
Reference in a new issue