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