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.
This commit is contained in:
Torsten Schulz (local)
2026-01-23 13:39:14 +01:00
parent 6471158847
commit d3a554108f

View File

@@ -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) {