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:
@@ -82,7 +82,7 @@ serve(async (req: Request) => {
|
|||||||
const { data: template, error: templateError } = await supabase
|
const { data: template, error: templateError } = await supabase
|
||||||
.from('notification_templates')
|
.from('notification_templates')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('template_key', 'auth_email_verification')
|
.eq('key', 'auth_email_verification')
|
||||||
.single();
|
.single();
|
||||||
|
|
||||||
if (templateError || !template) {
|
if (templateError || !template) {
|
||||||
@@ -110,13 +110,13 @@ serve(async (req: Request) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Process shortcodes in subject
|
// Process shortcodes in subject
|
||||||
let subject = template.subject;
|
let subject = template.email_subject;
|
||||||
Object.entries(templateVars).forEach(([key, value]) => {
|
Object.entries(templateVars).forEach(([key, value]) => {
|
||||||
subject = subject.replace(new RegExp(`{${key}}`, 'g'), value);
|
subject = subject.replace(new RegExp(`{${key}}`, 'g'), value);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Process shortcodes in HTML body
|
// Process shortcodes in HTML body
|
||||||
let htmlBody = template.html_content;
|
let htmlBody = template.email_body_html;
|
||||||
Object.entries(templateVars).forEach(([key, value]) => {
|
Object.entries(templateVars).forEach(([key, value]) => {
|
||||||
htmlBody = htmlBody.replace(new RegExp(`{${key}}`, 'g'), value);
|
htmlBody = htmlBody.replace(new RegExp(`{${key}}`, 'g'), value);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,18 +4,15 @@
|
|||||||
|
|
||||||
-- Insert default auth email verification template
|
-- Insert default auth email verification template
|
||||||
INSERT INTO notification_templates (
|
INSERT INTO notification_templates (
|
||||||
template_key,
|
key,
|
||||||
template_name,
|
name,
|
||||||
description,
|
|
||||||
subject,
|
|
||||||
html_content,
|
|
||||||
is_active,
|
is_active,
|
||||||
created_at,
|
email_subject,
|
||||||
updated_at
|
email_body_html
|
||||||
) VALUES (
|
) VALUES (
|
||||||
'auth_email_verification',
|
'auth_email_verification',
|
||||||
'Verifikasi Email - OTP',
|
'Verifikasi Email - OTP',
|
||||||
'Template untuk mengirim kode OTP verifikasi email saat pendaftaran',
|
true,
|
||||||
'Kode Verifikasi Email Anda - {platform_name}',
|
'Kode Verifikasi Email Anda - {platform_name}',
|
||||||
'---
|
'---
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -96,15 +93,6 @@ INSERT INTO notification_templates (
|
|||||||
color: #666;
|
color: #666;
|
||||||
border-top: 2px solid #000;
|
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>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -146,14 +134,8 @@ INSERT INTO notification_templates (
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
---',
|
---'
|
||||||
true,
|
) ON CONFLICT (key) DO NOTHING;
|
||||||
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';
|
|
||||||
|
|
||||||
-- Return success message
|
-- Return success message
|
||||||
DO $$
|
DO $$
|
||||||
|
|||||||
Reference in New Issue
Block a user