Updated migration to always set a value

- When both parameters passed to `update` resolve to `undefined` we throw an `Empty .update() call detected` error
- This change always updates the `sender_email` to null rather than skipping the field
- `sender_reply_to` should still be `undefined` so we don't override an existing non-null value
This commit is contained in:
Matt Hanley 2022-05-05 15:11:44 +01:00 committed by GitHub
parent bc464f8930
commit 8e1c10d146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,7 +22,7 @@ module.exports = createTransactionalMigration(
await knex('newsletters')
.update({
// CASE: members_from_address is 'noreply' - we leave it as null to maintain fallback behaviour
sender_email: !fromAddress || fromAddress.value === 'noreply' ? undefined : fromAddress.value,
sender_email: !fromAddress || fromAddress.value === 'noreply' ? null : fromAddress.value,
sender_reply_to: replyTo ? replyTo.value : undefined
})
.whereNull('sender_email')