CREATE TABLE IF NOT EXISTS `rentabilidad_productos` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `reporte_id` INT NOT NULL,
    `product_id` INT NOT NULL,
    `recaudo` DECIMAL(10, 2) DEFAULT 0.00,
    `unidades_vendidas` INT DEFAULT 0,
    `costo_ads` DECIMAL(10, 2) DEFAULT 0.00,
    `comision` DECIMAL(10, 2) DEFAULT 0.00,
    FOREIGN KEY (`reporte_id`) REFERENCES `rentabilidad_reportes`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`product_id`) REFERENCES `products`(`id`) ON DELETE CASCADE,
    UNIQUE KEY `reporte_product` (`reporte_id`, `product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
