-- =========================================================
-- SCHEMA: Tabella training_history per storico ML
-- =========================================================
-- Memorizza storia training modelli ML
-- =========================================================

-- Drop tabella se esiste (solo per ambiente di sviluppo)
DROP TABLE IF EXISTS training_history CASCADE;

-- Crea tabella training_history
CREATE TABLE training_history (
    id VARCHAR PRIMARY KEY DEFAULT gen_random_uuid(),
    model_version TEXT NOT NULL,
    records_processed INTEGER NOT NULL,
    features_count INTEGER NOT NULL,
    accuracy DECIMAL(5, 2),
    training_duration INTEGER,
    status TEXT NOT NULL,
    notes TEXT,
    trained_at TIMESTAMP NOT NULL DEFAULT NOW()
);

-- Indici per performance
CREATE INDEX IF NOT EXISTS trained_at_idx ON training_history(trained_at);

-- Commento tabella
COMMENT ON TABLE training_history IS 'Storico training modelli ML per IDS';

-- Verifica
SELECT 'Tabella training_history creata con successo!' AS status;
