
UPDATE video_translations vt
JOIN (
    SELECT lang_code, slug, MIN(id) AS keep_id
    FROM video_translations
    WHERE slug IS NOT NULL AND slug != ''
    GROUP BY lang_code, slug
    HAVING COUNT(*) > 1
) dup ON vt.lang_code = dup.lang_code AND vt.slug = dup.slug AND vt.id != dup.keep_id
SET vt.slug = CONCAT(vt.slug, '-', vt.video_id);

ALTER TABLE video_translations ADD UNIQUE INDEX idx_lang_slug (lang_code, slug);
