-- Strip baked proxy-URL prefix from deal_images.url so column holds raw R2 keys only.
-- Convention after this migration: deal_images.url = raw r2Key (no /api/img/ prefix).
UPDATE deal_images
SET url = regexp_replace(url, '^/api/img/[^/]+/[^/]+/', '')
WHERE url LIKE '/api/img/%';

-- Strip from vendors.hero_pending_image_url (pending slot may have been written with baked URL).
UPDATE vendors
SET hero_pending_image_url = regexp_replace(hero_pending_image_url, '^/api/img/[^/]+/[^/]+/', '')
WHERE hero_pending_image_url LIKE '/api/img/%';

-- Strip from vendors.hero_image_url (approved hero slot).
UPDATE vendors
SET hero_image_url = regexp_replace(hero_image_url, '^/api/img/[^/]+/[^/]+/', '')
WHERE hero_image_url LIKE '/api/img/%';

