
DELETE FROM ProductSheetActual
WHERE productDetailId IN (SELECT pd.id
                          FROM ProductDetail pd
                          WHERE trim(pd.slug) = ''
                          GROUP BY pd.id);

DELETE FROM ProductDetailTranslation
WHERE productDetailId IN (SELECT pd.id
                          FROM ProductDetail pd
                          WHERE trim(pd.slug) = ''
                          GROUP BY pd.id);

DELETE FROM ProductDetail WHERE trim(slug) = '';

ALTER TABLE `ProductDetail`
ADD UNIQUE INDEX `slug` (`slug`);