ids.alfacom.it/database-schema/migrations/002_example_add_index.sql
marco370 7b85fcc020 Implement a database versioning system to speed up updates
Add a database versioning system that tracks applied migrations and only runs new ones, significantly improving update speed.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: ab56b852-52de-4cd1-a489-5cf48f3a2965
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/myJmPIa
2025-11-22 07:51:56 +00:00

19 lines
774 B
SQL

-- ============================================================================
-- Migration 002: Add performance indexes
-- ============================================================================
-- Descrizione: Aggiunge indici per migliorare performance query detections
-- Data: 2025-11-22
-- ============================================================================
-- Indice su blocked per filtrare IP bloccati
CREATE INDEX IF NOT EXISTS detections_blocked_idx
ON detections(blocked);
-- Indice composto per query "IP bloccati recenti"
CREATE INDEX IF NOT EXISTS detections_blocked_detected_idx
ON detections(blocked, detected_at)
WHERE blocked = true;
-- Commento descrittivo
COMMENT ON INDEX detections_blocked_idx IS 'Index for filtering blocked IPs';