Fix jwt-token

This commit is contained in:
2025-09-15 05:39:06 +02:00
parent 9557a607d8
commit dbce97d156

View File

@@ -64,6 +64,15 @@ User.belongsTo(Tenant, { foreignKey: 'tenant_id', as: 'tenant' });
Tenant.hasMany(Device, { foreignKey: 'tenant_id', as: 'devices' }); Tenant.hasMany(Device, { foreignKey: 'tenant_id', as: 'devices' });
Device.belongsTo(Tenant, { foreignKey: 'tenant_id', as: 'tenant' }); Device.belongsTo(Tenant, { foreignKey: 'tenant_id', as: 'tenant' });
// Auto-sync database in test mode
if (process.env.NODE_ENV === 'test') {
sequelize.sync({ force: true }).then(() => {
console.log('🗄️ Test database tables created');
}).catch(error => {
console.error('❌ Test database sync failed:', error);
});
}
module.exports = { module.exports = {
sequelize, sequelize,
Device, Device,