From d3a554108ff020aa47b78b29b78b6e648fdd8792 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 23 Jan 2026 13:39:14 +0100 Subject: [PATCH] Enhance syncModelsAlways function to handle problematic ENUM changes - Added logic to skip synchronization for specific tables with known ENUM issues, improving stability during model synchronization. - Restored associations and virtual fields for models when skipping sync, ensuring data integrity and consistency. --- backend/utils/sequelize.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/backend/utils/sequelize.js b/backend/utils/sequelize.js index 8e0b227..0b36dae 100644 --- a/backend/utils/sequelize.js +++ b/backend/utils/sequelize.js @@ -695,6 +695,22 @@ const syncModelsAlways = async (models) => { continue; } + // Für Tabellen mit problematischen ENUM-Änderungen - wenn Tabelle existiert, überspringe Sync + // Sequelize generiert fehlerhaftes SQL bei ENUM-Änderungen mit Kommentaren + const enumProblemTables = ['TaxiMapTileHouse']; + if (enumProblemTables.includes(model.name) && tableExists) { + console.log(` ℹ️ ${model.name} Tabelle existiert bereits - überspringe Sync (ENUM-Änderungen problematisch)`); + // Restore associations before continuing + if (associationKeys.length > 0) { + model.associations = originalAssociations; + } + // Restore virtual fields + for (const [key, attr] of Object.entries(virtualFields)) { + model.rawAttributes[key] = attr; + } + continue; + } + // Verwende syncModelWithTimeout für große Tabellen const syncSuccess = await syncModelWithTimeout(model, 60000); if (!syncSuccess) {