-- Fix R2 URLs in profiles
UPDATE profiles 
SET avatar_url = REGEXP_REPLACE(avatar_url, 'https://[a-zA-Z0-9]+\.r2\.cloudflarestorage\.com/sojorn-media/', 'https://img.sojorn.net/', 'g') 
WHERE avatar_url LIKE '%r2.cloudflarestorage.com%';

UPDATE profiles 
SET cover_url = REGEXP_REPLACE(cover_url, 'https://[a-zA-Z0-9]+\.r2\.cloudflarestorage\.com/sojorn-media/', 'https://img.sojorn.net/', 'g') 
WHERE cover_url LIKE '%r2.cloudflarestorage.com%';

-- Fix R2 URLs in posts
UPDATE posts 
SET image_url = REGEXP_REPLACE(image_url, 'https://[a-zA-Z0-9]+\.r2\.cloudflarestorage\.com/sojorn-media/', 'https://img.sojorn.net/', 'g') 
WHERE image_url LIKE '%r2.cloudflarestorage.com%';

UPDATE posts 
SET video_url = REGEXP_REPLACE(video_url, 'https://[a-zA-Z0-9]+\.r2\.cloudflarestorage\.com/sojorn-media/', 'https://quips.sojorn.net/', 'g') 
WHERE video_url LIKE '%r2.cloudflarestorage.com%';

UPDATE posts 
SET thumbnail_url = REGEXP_REPLACE(thumbnail_url, 'https://[a-zA-Z0-9]+\.r2\.cloudflarestorage\.com/sojorn-media/', 'https://img.sojorn.net/', 'g') 
WHERE thumbnail_url LIKE '%r2.cloudflarestorage.com%';
