From 1cbeb7509455a5cbde92511b784529f20bb08efa Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 25 Jul 2025 13:50:01 +0200 Subject: [PATCH] Fix migration column and JSON errors - Fixed migration 029: Use base email_templates columns (subject, body_html, body_text) instead of language-specific columns that don't exist yet - Fixed migration 004: JSON.stringify the setting_value for app_settings table - Removed German translations from backup email templates in core migration The errors occurred because: 1. Migration 029 assumed language columns existed, but they're added by later migrations 2. Migration 004 passed a plain string to a JSON column in PostgreSQL --- .../core/029_add_backup_service_tables.js | 35 ++++--------------- .../legacy/004_add_categories_and_cms.js | 2 +- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/backend/migrations/core/029_add_backup_service_tables.js b/backend/migrations/core/029_add_backup_service_tables.js index 40ceaa8..fcba79d 100644 --- a/backend/migrations/core/029_add_backup_service_tables.js +++ b/backend/migrations/core/029_add_backup_service_tables.js @@ -156,9 +156,8 @@ async function up() { const backupEmailTemplates = [ { template_key: 'backup_failed', - subject_en: 'Backup Failed - Immediate Attention Required', - subject_de: 'Backup fehlgeschlagen - Sofortige Aufmerksamkeit erforderlich', - body_html_en: `

Backup Failed

+ subject: 'Backup Failed - Immediate Attention Required', + body_html: `

Backup Failed

The scheduled backup has failed and requires immediate attention.

Error Details:

Please check the system logs for more details and resolve the issue as soon as possible.

`, - body_html_de: `

Backup fehlgeschlagen

-

Das geplante Backup ist fehlgeschlagen und erfordert sofortige Aufmerksamkeit.

-

Fehlerdetails:

- -

Bitte überprüfen Sie die Systemprotokolle für weitere Details und beheben Sie das Problem so schnell wie möglich.

`, - body_text_en: 'Backup Failed\n\nThe scheduled backup has failed and requires immediate attention.\n\nStart Time: {{start_time}}\nBackup Type: {{backup_type}}\nError: {{error_message}}\n\nPlease check the system logs for more details.', - body_text_de: 'Backup fehlgeschlagen\n\nDas geplante Backup ist fehlgeschlagen und erfordert sofortige Aufmerksamkeit.\n\nStartzeit: {{start_time}}\nBackup-Typ: {{backup_type}}\nFehler: {{error_message}}\n\nBitte überprüfen Sie die Systemprotokolle für weitere Details.', + body_text: 'Backup Failed\n\nThe scheduled backup has failed and requires immediate attention.\n\nStart Time: {{start_time}}\nBackup Type: {{backup_type}}\nError: {{error_message}}\n\nPlease check the system logs for more details.', variables: JSON.stringify(['start_time', 'backup_type', 'error_message']) }, { template_key: 'backup_completed', - subject_en: 'Backup Completed Successfully', - subject_de: 'Backup erfolgreich abgeschlossen', - body_html_en: `

Backup Completed

+ subject: 'Backup Completed Successfully', + body_html: `

Backup Completed

The scheduled backup has been completed successfully.

Backup Summary:

`, - body_html_de: `

Backup abgeschlossen

-

Das geplante Backup wurde erfolgreich abgeschlossen.

-

Backup-Zusammenfassung:

-`, - body_text_en: 'Backup Completed\n\nThe scheduled backup has been completed successfully.\n\nStart Time: {{start_time}}\nDuration: {{duration}}\nFiles Backed Up: {{files_count}}\nTotal Size: {{total_size}}\nBackup Type: {{backup_type}}', - body_text_de: 'Backup abgeschlossen\n\nDas geplante Backup wurde erfolgreich abgeschlossen.\n\nStartzeit: {{start_time}}\nDauer: {{duration}}\nGesicherte Dateien: {{files_count}}\nGesamtgröße: {{total_size}}\nBackup-Typ: {{backup_type}}', + body_text: 'Backup Completed\n\nThe scheduled backup has been completed successfully.\n\nStart Time: {{start_time}}\nDuration: {{duration}}\nFiles Backed Up: {{files_count}}\nTotal Size: {{total_size}}\nBackup Type: {{backup_type}}', variables: JSON.stringify(['start_time', 'duration', 'files_count', 'total_size', 'backup_type']) } ]; diff --git a/backend/migrations/legacy/004_add_categories_and_cms.js b/backend/migrations/legacy/004_add_categories_and_cms.js index 297e8e5..0b1c619 100644 --- a/backend/migrations/legacy/004_add_categories_and_cms.js +++ b/backend/migrations/legacy/004_add_categories_and_cms.js @@ -40,7 +40,7 @@ async function up() { // Add language preference to app_settings for global default await db('app_settings').insert({ setting_key: 'default_language', - setting_value: 'en', + setting_value: JSON.stringify('en'), setting_type: 'general', updated_at: new Date() });