-- Migration: Add statistics table for tracking Tapp events
-- Run this script to add statistics functionality

CREATE TABLE IF NOT EXISTS company_stats (
    id INT AUTO_INCREMENT PRIMARY KEY,
    company_id INT NOT NULL,
    profile_type ENUM('empresa', 'comercial', 'operativo') NOT NULL,
    event_type ENUM('escaneo', 'descarga_vcard', 'clic_enlace') NOT NULL,
    employee_id INT NULL,
    link_id INT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_company_id (company_id),
    INDEX idx_created_at (created_at),
    INDEX idx_profile_type (profile_type),
    INDEX idx_event_type (event_type)
);
