-- Script pour convertir les URLs relatives en URLs absolues
-- Exécuter ce script pour corriger les données existantes

-- Corriger les URLs des chevaux
UPDATE horses
SET france_galop_url = CONCAT('https://www.zone-turf.fr', france_galop_url)
WHERE france_galop_url IS NOT NULL
  AND france_galop_url NOT LIKE 'http%'
  AND france_galop_url LIKE '/%';

-- Corriger les URLs des jockeys
UPDATE jockeys
SET france_galop_url = CONCAT('https://www.zone-turf.fr', france_galop_url)
WHERE france_galop_url IS NOT NULL
  AND france_galop_url NOT LIKE 'http%'
  AND france_galop_url LIKE '/%';

-- Corriger les URLs des entraineurs
UPDATE trainers
SET france_galop_url = CONCAT('https://www.zone-turf.fr', france_galop_url)
WHERE france_galop_url IS NOT NULL
  AND france_galop_url NOT LIKE 'http%'
  AND france_galop_url LIKE '/%';

-- Vérifier le résultat
SELECT 'Chevaux' as type, COUNT(*) as count FROM horses WHERE france_galop_url LIKE 'https://www.zone-turf.fr/%'
UNION ALL
SELECT 'Jockeys' as type, COUNT(*) as count FROM jockeys WHERE france_galop_url LIKE 'https://www.zone-turf.fr/%'
UNION ALL
SELECT 'Trainers' as type, COUNT(*) as count FROM trainers WHERE france_galop_url LIKE 'https://www.zone-turf.fr/%';
