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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user