From 571cd59caaddb68791745da5100fdf491f36f159 Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Sat, 20 Sep 2025 22:55:43 +0200 Subject: [PATCH] Fix jwt-token --- server/scripts/setup-database.js | 35 ++------------------------------ 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/server/scripts/setup-database.js b/server/scripts/setup-database.js index ba54ca8..ceb4dbc 100644 --- a/server/scripts/setup-database.js +++ b/server/scripts/setup-database.js @@ -34,39 +34,8 @@ const setupDatabase = async () => { await sequelize.authenticate(); console.log('✅ Database connection established successfully.\n'); - // Initialize models - console.log('📋 Initializing models...'); - Device.init(Device.getAttributes(), { sequelize, modelName: 'Device' }); - DroneDetection.init(DroneDetection.getAttributes(), { sequelize, modelName: 'DroneDetection' }); - Heartbeat.init(Heartbeat.getAttributes(), { sequelize, modelName: 'Heartbeat' }); - User.init(User.getAttributes(), { sequelize, modelName: 'User' }); - AlertRule.init(AlertRule.getAttributes(), { sequelize, modelName: 'AlertRule' }); - AlertLog.init(AlertLog.getAttributes(), { sequelize, modelName: 'AlertLog' }); - - // Define associations - console.log('🔗 Setting up model associations...'); - - // Device associations - Device.hasMany(DroneDetection, { foreignKey: 'device_id', as: 'detections' }); - Device.hasMany(Heartbeat, { foreignKey: 'device_id', as: 'heartbeats' }); - - // Detection associations - DroneDetection.belongsTo(Device, { foreignKey: 'device_id', as: 'device' }); - - // Heartbeat associations - Heartbeat.belongsTo(Device, { foreignKey: 'device_id', as: 'device' }); - - // User associations - User.hasMany(AlertRule, { foreignKey: 'user_id', as: 'alertRules' }); - User.hasMany(AlertLog, { foreignKey: 'user_id', as: 'alertLogs' }); - - // Alert associations - AlertRule.belongsTo(User, { foreignKey: 'user_id', as: 'user' }); - AlertRule.hasMany(AlertLog, { foreignKey: 'alert_rule_id', as: 'logs' }); - - AlertLog.belongsTo(User, { foreignKey: 'user_id', as: 'user' }); - AlertLog.belongsTo(AlertRule, { foreignKey: 'alert_rule_id', as: 'alertRule' }); - AlertLog.belongsTo(DroneDetection, { foreignKey: 'detection_id', as: 'detection' }); + // Models are already initialized through the imports + console.log('� Models loaded and ready...'); // Sync database (create tables) console.log('🏗️ Creating database tables...');