=== Legacy API Key System Cleanup === Step 1: Checking current table structure... Current nodes table columns: - id (bigint unsigned) - node_id (varchar(128)) - device_id (varchar(64)) - tenant_id (bigint unsigned) - hostname (varchar(255)) - description (text) - name (varchar(255)) - friendly_name (varchar(190)) - notes (text) - type (enum('pc','vm','host','hyperv_host','unknown')) - type_source (enum('detected','override')) - fqdn (varchar(255)) - domain_name (varchar(255)) - os_name (varchar(255)) - os_version (varchar(255)) - architecture (varchar(64)) - processor_count (int) - system_manufacturer (varchar(255)) - system_model (varchar(255)) - system_serial (varchar(255)) - processor_name (varchar(255)) - os_build (varchar(64)) - hypervisor (varchar(64)) - serial (varchar(128)) - manufacturer (varchar(128)) - model (varchar(128)) - timezone (varchar(128)) - timezone_offset (int) - first_seen (timestamp) - last_seen (timestamp) - is_enabled (tinyint(1)) - status (enum('active','unassigned','disabled')) - auto_enrolled (tinyint(1)) - assigned_user_id (bigint unsigned) - client_ip (varchar(45)) - device_fingerprint (varchar(128)) Legacy columns found: api_key_active: ❌ NOT FOUND api_key_next: ❌ NOT FOUND api_key_salt: ❌ NOT FOUND api_key_next_salt: ❌ NOT FOUND device_token: ❌ NOT FOUND Step 2: Removing legacy columns... ⏭️ Column api_key_active doesn't exist, skipping ⏭️ Column api_key_next doesn't exist, skipping ⏭️ Column api_key_salt doesn't exist, skipping ⏭️ Column api_key_next_salt doesn't exist, skipping Step 3: Removing api_keys table... ✅ Dropped api_keys table (if it existed) Step 4: Removing legacy indexes... ⏭️ Index idx_nodes_api_key_active doesn't exist or failed to drop: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'idx_nodes_api_key_active'; check that column/key exists ⏭️ Index idx_nodes_api_key_next doesn't exist or failed to drop: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'idx_nodes_api_key_next'; check that column/key exists Step 5: Verifying cleanup... Remaining columns in nodes table: - id (bigint unsigned) - node_id (varchar(128)) - device_id (varchar(64)) - tenant_id (bigint unsigned) - hostname (varchar(255)) - description (text) - name (varchar(255)) - friendly_name (varchar(190)) - notes (text) - type (enum('pc','vm','host','hyperv_host','unknown')) - type_source (enum('detected','override')) - fqdn (varchar(255)) - domain_name (varchar(255)) - os_name (varchar(255)) - os_version (varchar(255)) - architecture (varchar(64)) - processor_count (int) - system_manufacturer (varchar(255)) - system_model (varchar(255)) - system_serial (varchar(255)) - processor_name (varchar(255)) - os_build (varchar(64)) - hypervisor (varchar(64)) - serial (varchar(128)) - manufacturer (varchar(128)) - model (varchar(128)) - timezone (varchar(128)) - timezone_offset (int) - first_seen (timestamp) - last_seen (timestamp) - is_enabled (tinyint(1)) - status (enum('active','unassigned','disabled')) - auto_enrolled (tinyint(1)) - assigned_user_id (bigint unsigned) - client_ip (varchar(45)) - device_fingerprint (varchar(128)) 🎉 SUCCESS: All legacy API key rotation columns have been removed! ✅ Token-based authentication system is now fully active Step 6: Checking device_tokens table... ✅ device_tokens table exists with 13 tokens - active: 5 tokens - revoked: 8 tokens Step 7: Testing enrollment endpoint... Testing enrollment with device_fingerprint: test_cleanup_1765433284 ✅ Device token creation test: PASSED === Cleanup Complete === 🎉 The NodeMetrics system is now fully migrated to token-based authentication! ✅ Legacy API key rotation system has been removed ✅ Token-based authentication is active ✅ Agent enrollment should now work properly Next steps: 1. Restart the NodeMetrics service to test enrollment 2. Check that devices appear in the dashboard as 'unassigned' 3. Assign devices to users via the dashboard