diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index 40ecea0..0e6c6d3 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -4397,6 +4397,12 @@ class FalukantService extends BaseService { } ); await transaction.commit(); + + // Send socket notification to update statusbar + if (count > 0) { + notifyUser(hashedUserId, 'falukantUpdateStatus', {}); + } + return { updated: count }; } catch (error) { await transaction.rollback(); diff --git a/backend/utils/sequelize.js b/backend/utils/sequelize.js index 77697b5..c3e86ad 100644 --- a/backend/utils/sequelize.js +++ b/backend/utils/sequelize.js @@ -416,8 +416,27 @@ const syncModelsAlways = async (models) => { console.log('🔍 Deployment-Modus: Führe immer Schema-Updates durch...'); try { - for (const model of Object.values(models)) { - await model.sync({ alter: true, force: false }); + for (const model of Object.values(models)) { + // Temporarily remove VIRTUAL fields before sync to prevent sync errors + const originalAttributes = model.rawAttributes; + const virtualFields = {}; + + // Find and temporarily remove VIRTUAL fields + for (const [key, attr] of Object.entries(originalAttributes)) { + if (attr.type && attr.type.constructor && attr.type.constructor.name === 'VIRTUAL') { + virtualFields[key] = attr; + delete model.rawAttributes[key]; + } + } + + try { + await model.sync({ alter: true, force: false }); + } finally { + // Restore VIRTUAL fields after sync + for (const [key, attr] of Object.entries(virtualFields)) { + model.rawAttributes[key] = attr; + } + } } console.log('✅ Schema-Updates für alle Models abgeschlossen'); } catch (error) {