ids.alfacom.it/database-schema/migrations/004_add_geolocation_to_detections.sql
marco370 1b9df79d56 Add IP geolocation and AS information to detection records
Integrates IP geolocation and Autonomous System (AS) information into detection records by modifying the frontend to display this data and updating the backend to perform asynchronous batch lookups for efficiency. This enhancement includes database schema updates and the creation of a new IP geolocation service.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: e81fd4a1-b7b0-48d2-ae38-f5905e278343
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/SXFWABi
2025-11-22 10:59:50 +00:00

24 lines
860 B
SQL

-- Migration 004: Add geolocation and AS information to detections table
-- Date: 2025-11-22
-- Description: Adds country, city, organization, AS number/name, ISP fields
ALTER TABLE detections
ADD COLUMN IF NOT EXISTS country TEXT,
ADD COLUMN IF NOT EXISTS country_code TEXT,
ADD COLUMN IF NOT EXISTS city TEXT,
ADD COLUMN IF NOT EXISTS organization TEXT,
ADD COLUMN IF NOT EXISTS as_number TEXT,
ADD COLUMN IF NOT EXISTS as_name TEXT,
ADD COLUMN IF NOT EXISTS isp TEXT;
-- Create index on country for fast filtering
CREATE INDEX IF NOT EXISTS country_idx ON detections(country);
-- Update schema_version
INSERT INTO schema_version (version, description)
VALUES (4, 'Add geolocation and AS information to detections')
ON CONFLICT (id) DO UPDATE SET
version = 4,
applied_at = NOW(),
description = 'Add geolocation and AS information to detections';