Add socket notification for status bar updates in FalukantService and enhance model sync by handling VIRTUAL fields in sequelize.js
This commit is contained in:
@@ -4397,6 +4397,12 @@ class FalukantService extends BaseService {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
await transaction.commit();
|
await transaction.commit();
|
||||||
|
|
||||||
|
// Send socket notification to update statusbar
|
||||||
|
if (count > 0) {
|
||||||
|
notifyUser(hashedUserId, 'falukantUpdateStatus', {});
|
||||||
|
}
|
||||||
|
|
||||||
return { updated: count };
|
return { updated: count };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await transaction.rollback();
|
await transaction.rollback();
|
||||||
|
|||||||
@@ -416,8 +416,27 @@ const syncModelsAlways = async (models) => {
|
|||||||
console.log('🔍 Deployment-Modus: Führe immer Schema-Updates durch...');
|
console.log('🔍 Deployment-Modus: Führe immer Schema-Updates durch...');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const model of Object.values(models)) {
|
for (const model of Object.values(models)) {
|
||||||
await model.sync({ alter: true, force: false });
|
// 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');
|
console.log('✅ Schema-Updates für alle Models abgeschlossen');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user