-- ============================================
-- MIGRACIÓN 002: user_invitations
-- ============================================

CREATE TABLE IF NOT EXISTS user_invitations (
    id INT AUTO_INCREMENT PRIMARY KEY,
    email VARCHAR(200) NOT NULL,
    token VARCHAR(255) NOT NULL UNIQUE,
    role ENUM('super_admin', 'comercial_manager') NOT NULL,
    invited_by INT NOT NULL,
    status ENUM('pendiente', 'aceptada', 'expirada') NOT NULL DEFAULT 'pendiente',
    expires_at TIMESTAMP NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (invited_by) REFERENCES users(id) ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
