fix: use upsert for tier change template migration (refs #59)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 3m5s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 30s
Deploy to Staging / Verify Staging (pull_request) Successful in 8s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 3m5s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 30s
Deploy to Staging / Verify Staging (pull_request) Successful in 8s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
Changed INSERT to INSERT...ON CONFLICT DO UPDATE so the migration works for: - Fresh deployments (inserts new template) - Existing databases (updates template to fix variable substitution) Removed unnecessary migration 008. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@ CHECK (template_key IN (
|
|||||||
'subscription_tier_change'
|
'subscription_tier_change'
|
||||||
));
|
));
|
||||||
|
|
||||||
-- Insert subscription tier change email template
|
-- Insert or update subscription tier change email template
|
||||||
INSERT INTO email_templates (template_key, name, description, subject, body, variables, html_body) VALUES
|
INSERT INTO email_templates (template_key, name, description, subject, body, variables, html_body) VALUES
|
||||||
(
|
(
|
||||||
'subscription_tier_change',
|
'subscription_tier_change',
|
||||||
@@ -86,4 +86,12 @@ MotoVaultPro Team',
|
|||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>'
|
</html>'
|
||||||
);
|
)
|
||||||
|
ON CONFLICT (template_key) DO UPDATE SET
|
||||||
|
name = EXCLUDED.name,
|
||||||
|
description = EXCLUDED.description,
|
||||||
|
subject = EXCLUDED.subject,
|
||||||
|
body = EXCLUDED.body,
|
||||||
|
variables = EXCLUDED.variables,
|
||||||
|
html_body = EXCLUDED.html_body,
|
||||||
|
updated_at = NOW();
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
/**
|
|
||||||
* Migration: Fix subscription tier change email template
|
|
||||||
* @ai-summary Fixes template to use simple variable substitution instead of conditionals
|
|
||||||
* @ai-context TemplateService only supports {{variable}}, not Handlebars conditionals
|
|
||||||
*/
|
|
||||||
|
|
||||||
-- Update the existing template to use simple variable substitution
|
|
||||||
UPDATE email_templates
|
|
||||||
SET
|
|
||||||
body = 'Hi {{userName}},
|
|
||||||
|
|
||||||
Your MotoVaultPro subscription has been {{changeType}}.
|
|
||||||
|
|
||||||
Previous Tier: {{previousTier}}
|
|
||||||
New Tier: {{newTier}}
|
|
||||||
Reason: {{reason}}
|
|
||||||
|
|
||||||
{{additionalInfo}}
|
|
||||||
|
|
||||||
If you have any questions, please contact support.
|
|
||||||
|
|
||||||
Best regards,
|
|
||||||
MotoVaultPro Team',
|
|
||||||
variables = '["userName", "changeType", "previousTier", "newTier", "reason", "additionalInfo"]',
|
|
||||||
updated_at = NOW()
|
|
||||||
WHERE template_key = 'subscription_tier_change';
|
|
||||||
Reference in New Issue
Block a user