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:
parent
3b0a84b33b
commit
dd0f80c9fa
1 changed files with 34 additions and 0 deletions
|
@ -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');
|
||||
}
|
||||
);
|
Loading…
Reference in a new issue