/**
* Fix portal invitation email template variable names
*
* The email sending code passes clientName, clientLocationEmail, and clientLocationPhone
* but the template was using the old company* variable names, causing these fields
* to not be replaced in the sent emails.
*
* This migration updates the template to use the correct client* variable names.
*/
exports.up = async function(knex) {
const portalInvitationHtml = `
Hello {{contactName}},
Great news! You've been invited to access the customer portal for {{clientName}}. This secure portal gives you instant access to:
🎯 What You Can Access
✓ View and track your support tickets
✓ Review project updates and documentation
✓ Communicate directly with your support team
Experience seamless service management with our intuitive portal. Everything you need to stay informed and connected, all in one secure location.
Or copy and paste this link into your browser:
{{portalLink}}
⏰ Time-Sensitive Invitation
This invitation link will expire in {{expirationTime}}. Please complete your account setup before then to ensure uninterrupted access.
`;
const portalInvitationText = `
Welcome to Your Customer Portal
Hello {{contactName}},
Great news! You've been invited to access the customer portal for {{clientName}}. This secure portal gives you instant access to:
✓ View and track your support tickets
✓ Review project updates and documentation
✓ Communicate directly with your support team
SET UP YOUR PORTAL ACCESS:
{{portalLink}}
⏰ TIME-SENSITIVE: This invitation link will expire in {{expirationTime}}. Please complete your account setup before then to ensure uninterrupted access.
NEED ASSISTANCE?
Email: {{clientLocationEmail}}
Phone: {{clientLocationPhone}}
Our support team is ready to help you get started.
---
This email was sent to {{contactName}} as part of your portal access setup.
If you didn't expect this invitation, please contact us at {{clientLocationEmail}}.
© {{currentYear}} {{clientName}}. All rights reserved.
`;
// Update portal-invitation template with corrected variable names
await knex('system_email_templates')
.where({ name: 'portal-invitation' })
.update({
html_content: portalInvitationHtml,
text_content: portalInvitationText,
updated_at: new Date()
});
};
exports.down = async function(knex) {
// Revert to the previous version with company* variable names
const previousPortalInvitationHtml = `
Hello {{contactName}},
Great news! You've been invited to access the customer portal for {{companyName}}. This secure portal gives you instant access to:
🎯 What You Can Access
✓ View and track your support tickets
✓ Review project updates and documentation
✓ Communicate directly with your support team
Experience seamless service management with our intuitive portal. Everything you need to stay informed and connected, all in one secure location.
Or copy and paste this link into your browser:
{{portalLink}}
⏰ Time-Sensitive Invitation
This invitation link will expire in {{expirationTime}}. Please complete your account setup before then to ensure uninterrupted access.
`;
const previousPortalInvitationText = `
Welcome to Your Customer Portal
Hello {{contactName}},
Great news! You've been invited to access the customer portal for {{companyName}}. This secure portal gives you instant access to:
✓ View and track your support tickets
✓ Review project updates and documentation
✓ Communicate directly with your support team
SET UP YOUR PORTAL ACCESS:
{{portalLink}}
⏰ TIME-SENSITIVE: This invitation link will expire in {{expirationTime}}. Please complete your account setup before then to ensure uninterrupted access.
NEED ASSISTANCE?
Email: {{companyLocationEmail}}
Phone: {{companyLocationPhone}}
Our support team is ready to help you get started.
---
This email was sent to {{contactName}} as part of your portal access setup.
If you didn't expect this invitation, please contact us at {{companyLocationEmail}}.
© {{currentYear}} {{companyName}}. All rights reserved.
`;
await knex('system_email_templates')
.where({ name: 'portal-invitation' })
.update({
html_content: previousPortalInvitationHtml,
text_content: previousPortalInvitationText,
updated_at: new Date()
});
};