-- Update hero video URLs to use muaziin.sa instead of api.muaziin.sa
-- This ensures videos are served from the correct domain

UPDATE hero_videos 
SET video_url = REPLACE(video_url, 'https://muaziin.sa', 'https://muaziin.sa')
WHERE video_url LIKE '%api.muaziin.sa%';

-- Also update any http://api.muaziin.sa to https://muaziin.sa
UPDATE hero_videos 
SET video_url = REPLACE(video_url, 'http://api.muaziin.sa', 'https://muaziin.sa')
WHERE video_url LIKE '%http://api.muaziin.sa%';

-- Update relative URLs to absolute URLs if needed
-- This updates /uploads/ paths to full URLs
UPDATE hero_videos 
SET video_url = CONCAT('https://muaziin.sa', video_url)
WHERE video_url LIKE '/uploads/%' 
  AND video_url NOT LIKE 'http%';

-- Verify the updates
SELECT id, title, video_url 
FROM hero_videos 
WHERE deleted_at IS NULL
ORDER BY position ASC, id DESC;
