-- ============================================
-- Update Player Reports Image Paths
-- Convert from protected API paths to public paths
-- ============================================

-- Update images_json column to use public paths instead of API paths
UPDATE player_reports 
SET images_json = REPLACE(images_json, '"/api/player-reports/images/', '"/public/player-reports/images/')
WHERE images_json IS NOT NULL 
AND images_json LIKE '%"/api/player-reports/images/%';

-- Update path column in player_report_images table
UPDATE player_report_images 
SET path = REPLACE(path, '/api/player-reports/images/', '/public/player-reports/images/')
WHERE path LIKE '/api/player-reports/images/%';

-- Show updated records for verification
SELECT COUNT(*) as updated_reports FROM player_reports 
WHERE images_json IS NOT NULL 
AND images_json LIKE '%"/public/player-reports/images/%';

SELECT COUNT(*) as updated_image_records FROM player_report_images 
WHERE path LIKE '/public/player-reports/images/%';
