-- Add email_templates category in system_settings if needed INSERT INTO system_settings (key, value, category) VALUES ('email_templates_enabled', 'true', 'email') ON CONFLICT (key) DO NOTHING; -- Add email_logs table for template logs if it doesn't exist ALTER TABLE email_logs ADD COLUMN IF NOT EXISTS template_id VARCHAR(255); ALTER TABLE email_logs ADD COLUMN IF NOT EXISTS template_type VARCHAR(50); -- Create default login code template INSERT INTO system_settings (key, value, category) VALUES ( 'email_template_login_code_default', '{"name":"Login Code Template","type":"login_code","subject":"Your Login Code","content":"

Your login code is: {{code}}

This code will expire in 15 minutes.

Or click here to log in directly.

","isDefault":true,"createdAt":"2025-04-29T00:00:00.000Z"}', 'email_templates' ) ON CONFLICT (key) DO NOTHING; -- Create default shipping notification template INSERT INTO system_settings (key, value, category) VALUES ( 'email_template_shipping_notification_default', '{"name":"Shipping Notification Template","type":"shipping_notification","subject":"Your Order Has Shipped!","content":"

Your Order Has Shipped!

Order #{{order_id}}

Hello {{first_name}},

Good news! Your order has been shipped and is on its way to you.

Shipping Details

Carrier: {{carrier}}

Tracking Number: {{tracking_number}}

Shipped On: {{shipped_date}}

Estimated Delivery: {{estimated_delivery}}

Order Summary

{{items_html}}
ItemQtyPriceTotal

Thank you for your purchase!

© 2025 Rocks, Bones & Sticks. All rights reserved.

","isDefault":true,"createdAt":"2025-04-29T00:00:00.000Z"}', 'email_templates' ) ON CONFLICT (key) DO NOTHING; -- Create default order confirmation template INSERT INTO system_settings (key, value, category) VALUES ( 'email_template_order_confirmation_default', '{"name":"Order Confirmation Template","type":"order_confirmation","subject":"Order Confirmation","content":"

Order Confirmation

Order #{{order_id}}

Hello {{first_name}},

Thank you for your order! We are processing it now and will send you another email when it ships.

Order Details

Order Date: {{order_date}}

Order Total: {{order_total}}

Shipping To: {{shipping_address}}

Order Summary

{{items_html}}
ItemQtyPriceTotal

© 2025 Rocks, Bones & Sticks. All rights reserved.

","isDefault":true,"createdAt":"2025-04-29T00:00:00.000Z"}', 'email_templates' ) ON CONFLICT (key) DO NOTHING; -- Create default low stock alert template INSERT INTO system_settings (key, value, category) VALUES ( 'email_template_low_stock_alert_default', '{"name":"Low Stock Alert Template","type":"low_stock_alert","subject":"Low Stock Alert: {{product_name}}","content":"

Low Stock Alert

Hello,

This is an automated notification to inform you that the following product is running low on stock:

{{product_name}}

Current Stock: {{current_stock}}

Threshold: {{threshold}}

You might want to restock this item soon to avoid running out of inventory.

© 2025 Rocks, Bones & Sticks. All rights reserved.

","isDefault":true,"createdAt":"2025-04-29T00:00:00.000Z"}', 'email_templates' ) ON CONFLICT (key) DO NOTHING; -- Create default welcome email template INSERT INTO system_settings (key, value, category) VALUES ( 'email_template_welcome_email_default', '{"name":"Welcome Email Template","type":"welcome_email","subject":"Welcome to Rocks, Bones & Sticks!","content":"

Welcome to Rocks, Bones & Sticks!

Hello {{first_name}},

Thank you for creating an account with us. We are excited to have you join our community of natural curiosity enthusiasts!

As a member, you will enjoy:

Start exploring our collections today and discover the beauty of nature!

Shop Now

© 2025 Rocks, Bones & Sticks. All rights reserved.

","isDefault":true,"createdAt":"2025-04-29T00:00:00.000Z"}', 'email_templates' ) ON CONFLICT (key) DO NOTHING; INSERT INTO system_settings (key, value, category) VALUES ( 'email_template_refund_confirmation_default', '{"name":"Refund Confirmation Template","type":"refund_confirmation","subject":"Your Refund for Order #{{order_id}} Has Been Processed","content":"

Refund Confirmation

Order #{{order_id}}

Hello {{first_name}},

We are writing to confirm that your refund for order #{{order_id}} has been processed. The refund amount of {{refund_amount}} has been issued to your original payment method.

Refund Details

Refund Amount: {{refund_amount}}

Refund Date: {{refund_date}}

Refund Method: {{refund_method}}

Refund Reason: {{refund_reason}}

Please note that it may take 5-10 business days for the refund to appear in your account, depending on your payment provider.

If you have any questions about this refund, please do not hesitate to contact our customer support team.

Thank you for your understanding.

© 2025 Rocks, Bones & Sticks. All rights reserved.

","isDefault":true,"createdAt":"2025-05-02T00:00:00.000Z"}', 'email_templates' ) ON CONFLICT (key) DO NOTHING;