From 1fbaf4d360fc80d5b1bdaac6a460a448a68a6e47 Mon Sep 17 00:00:00 2001 From: dwindown Date: Sat, 3 Jan 2026 08:59:49 +0700 Subject: [PATCH] Fix column names in send-notification and migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated to use the correct database column names: - email_subject (not subject) - email_body_html (not body_html) Changes: - send-notification/index.ts: Added fallback to check both email_subject/subject and email_body_html/body_html for compatibility - Migration: Updated to use correct column names (email_subject, email_body_html) This matches the actual database schema shown in the notification_templates table. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- supabase/functions/send-notification/index.ts | 4 ++-- ...0250103000001_update_order_created_template_with_qr.sql | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/supabase/functions/send-notification/index.ts b/supabase/functions/send-notification/index.ts index ad83067..ef217ed 100644 --- a/supabase/functions/send-notification/index.ts +++ b/supabase/functions/send-notification/index.ts @@ -265,8 +265,8 @@ serve(async (req: Request): Promise => { } } - const subject = replaceVariables(template.subject, allVariables); - const htmlContent = replaceVariables(template.body_html || template.body_text || "", allVariables); + const subject = replaceVariables(template.email_subject || template.subject || "", allVariables); + const htmlContent = replaceVariables(template.email_body_html || template.body_html || template.body_text || "", allVariables); // Wrap with master template for consistent branding const htmlBody = EmailTemplateRenderer.render({ diff --git a/supabase/migrations/20250103000001_update_order_created_template_with_qr.sql b/supabase/migrations/20250103000001_update_order_created_template_with_qr.sql index 6b8a8fe..393e626 100644 --- a/supabase/migrations/20250103000001_update_order_created_template_with_qr.sql +++ b/supabase/migrations/20250103000001_update_order_created_template_with_qr.sql @@ -3,7 +3,8 @@ UPDATE notification_templates SET - body_html = ' + email_subject = 'Konfirmasi Pesanan - Order #{order_id}', + email_body_html = '

Konfirmasi Pesanan

@@ -78,9 +79,9 @@ WHERE key = 'order_created'; -- Verify the update SELECT key, - subject, + email_subject, is_active, - LEFT(body_html, 100) as body_preview, + LEFT(email_body_html, 100) as body_preview, updated_at FROM notification_templates WHERE key = 'order_created';