0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Added migration to populate email_recipient_filter

no-issue

This populates the email_recipient_filter column for existing posts
based on 1. if they were sent as an email and 2. their visibility.
This commit is contained in:
Fabien O'Carroll 2020-11-03 14:46:26 +00:00 committed by Fabien 'egg' O'Carroll
parent 3b0a84b33b
commit dd0f80c9fa

View file

@ -0,0 +1,34 @@
const {createTransactionalMigration} = require('../../utils');
const logging = require('../../../../../shared/logging');
module.exports = createTransactionalMigration(
async function up(connection) {
logging.info('Updating email_recipient_filter values based on visibility and send_email_when_published');
await connection('posts')
.update('email_recipient_filter', 'paid')
.where({
send_email_when_published: true,
visibility: 'paid'
});
await connection('posts')
.update('email_recipient_filter', 'all')
.where({
send_email_when_published: true,
visibility: 'members'
});
await connection('posts')
.update('email_recipient_filter', 'all')
.where({
send_email_when_published: true,
visibility: 'public'
});
},
async function down(connection) {
logging.info('Updating email_recipient_filter values to none');
await connection('posts')
.update('email_recipient_filter', 'none');
}
);