Updated email_track_clicks to current email_track_opens value (#15484)

fixes https://github.com/TryGhost/Team/issues/1990

We need to set the current track clicks setting to the current track opens setting, just before release.
This commit is contained in:
Simon Backx 2022-09-28 17:12:29 +02:00 committed by GitHub
parent 59b5cd59b2
commit 8af422c601
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,31 @@
const logging = require('@tryghost/logging');
const {createTransactionalMigration} = require('../../utils');
// Set email_track_clicks to the current value of email_track_opens
module.exports = createTransactionalMigration(
async function up(connection) {
const reuseValueOfSetting = await connection('settings')
.where('key', '=', 'email_track_opens')
.first();
if (!reuseValueOfSetting) {
logging.warn(`Skipped setting email_track_clicks to current value of email_track_opens - email_track_opens not found`);
return;
}
const affectedRows = await connection('settings')
.update({
value: reuseValueOfSetting.value
})
.where('key', '=', 'email_track_clicks');
if (affectedRows === 1) {
logging.info(`Set email_track_clicks to ${reuseValueOfSetting.value} (current email_track_opens value)`);
} else {
logging.warn(`Tried setting email_track_clicks to ${reuseValueOfSetting.value}${affectedRows} changes`);
}
},
async function down() {
// no-op: we don't need to change it back
}
);