Fix notification_templates table column names

Update auth email template migration and edge function to use correct column names:
- template_key → key
- subject → email_subject
- html_content → email_body_html

Matches existing notification_templates schema used in NotifikasiTab.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-01-02 13:41:30 +07:00
parent 0d29c953c1
commit c6250d2b47
2 changed files with 10 additions and 28 deletions

View File

@@ -82,7 +82,7 @@ serve(async (req: Request) => {
const { data: template, error: templateError } = await supabase
.from('notification_templates')
.select('*')
.eq('template_key', 'auth_email_verification')
.eq('key', 'auth_email_verification')
.single();
if (templateError || !template) {
@@ -110,13 +110,13 @@ serve(async (req: Request) => {
};
// Process shortcodes in subject
let subject = template.subject;
let subject = template.email_subject;
Object.entries(templateVars).forEach(([key, value]) => {
subject = subject.replace(new RegExp(`{${key}}`, 'g'), value);
});
// Process shortcodes in HTML body
let htmlBody = template.html_content;
let htmlBody = template.email_body_html;
Object.entries(templateVars).forEach(([key, value]) => {
htmlBody = htmlBody.replace(new RegExp(`{${key}}`, 'g'), value);
});

View File

@@ -4,18 +4,15 @@
-- Insert default auth email verification template
INSERT INTO notification_templates (
template_key,
template_name,
description,
subject,
html_content,
key,
name,
is_active,
created_at,
updated_at
email_subject,
email_body_html
) VALUES (
'auth_email_verification',
'Verifikasi Email - OTP',
'Template untuk mengirim kode OTP verifikasi email saat pendaftaran',
true,
'Kode Verifikasi Email Anda - {platform_name}',
'---
<!DOCTYPE html>
@@ -96,15 +93,6 @@ INSERT INTO notification_templates (
color: #666;
border-top: 2px solid #000;
}
.button {
display: inline-block;
background: #000;
color: #fff;
padding: 12px 24px;
text-decoration: none;
font-weight: 600;
margin-top: 10px;
}
</style>
</head>
<body>
@@ -146,14 +134,8 @@ INSERT INTO notification_templates (
</div>
</body>
</html>
---',
true,
NOW(),
NOW()
) ON CONFLICT (template_key) DO NOTHING;
-- Add comment
COMMENT ON TABLE notification_templates IS 'Contains email templates for various notifications including auth emails';
---'
) ON CONFLICT (key) DO NOTHING;
-- Return success message
DO $$