const { Device, Tenant } = require('./server/models'); async function createStockholmDevice() { try { // Find the uamils-ab tenant const tenant = await Tenant.findOne({ where: { slug: 'uamils-ab' } }); if (!tenant) { console.log('❌ Tenant uamils-ab not found'); return; } // Check if device "1941875381" already exists (from your test packet) const existingDevice = await Device.findOne({ where: { id: '1941875381' } }); if (existingDevice) { console.log('✅ Test device already exists'); console.log(` ID: ${existingDevice.id}`); console.log(` Name: ${existingDevice.name}`); console.log(` Approved: ${existingDevice.is_approved}`); console.log(` Active: ${existingDevice.is_active}`); console.log(` Tenant: ${existingDevice.tenant_id}`); return; } // Create test device with the ID from your packet const testDevice = await Device.create({ id: '1941875381', name: 'Test Device 1941875381', type: 'drone_detector', location: 'Test Location', description: 'Test drone detector device', is_approved: true, is_active: true, tenant_id: tenant.id, coordinates: JSON.stringify({ latitude: 0, longitude: 0 }), config: JSON.stringify({ detection_range: 25000, alert_threshold: 5000, frequency_bands: ['2.4GHz', '5.8GHz'], sensitivity: 'high' }) }); console.log('✅ Test device created successfully'); console.log(` ID: ${testDevice.id}`); console.log(` Name: ${testDevice.name}`); console.log(` Tenant: ${testDevice.tenant_id}`); console.log(` Approved: ${testDevice.is_approved}`); } catch (error) { console.error('❌ Error creating Stockholm device:', error.message); } } createStockholmDevice() .then(() => { console.log('✅ Test device setup completed'); process.exit(0); }) .catch(error => { console.error('❌ Setup failed:', error); process.exit(1); });