-- ============================================
-- MIGRACIÓN 019: Problemas técnicos del lead
-- ============================================

CREATE TABLE IF NOT EXISTS lead_technical_problems (
    id INT AUTO_INCREMENT PRIMARY KEY,
    lead_id INT NOT NULL,
    description TEXT NOT NULL,
    status ENUM('pendiente', 'resuelto') NOT NULL DEFAULT 'pendiente',
    resolved_at TIMESTAMP NULL,
    created_by INT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (lead_id) REFERENCES leads(id) ON DELETE CASCADE,
    FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE INDEX idx_lead_tech_problems_lead_id ON lead_technical_problems(lead_id);
