-- Rewrite any already-stored `/media/...` URLs (the pre-Phase-10 upload -- path, which never actually worked in production — Next.js 16's -- `next start` does not dynamically serve files added to public/ after -- the build; see src/lib/media/media-storage.ts's header for the full -- account) to the new `/api/media/...` prefix served by -- src/app/api/media/[...path]/route.ts. -- -- Confirmed via a direct read of the live database before writing this -- migration: exactly one MediaAsset row and its matching -- BusinessGalleryImage row use the old prefix; every other image field -- currently stores a full external URL (Business.logoUrl/coverImageUrl, -- etc.) and is untouched by this. Every statement below is still -- included for completeness/safety, covers every image column that can -- receive a MediaPicker-sourced URL, and is a no-op wherever nothing -- matches. -- -- Idempotent: re-running finds nothing left matching `/media/%` (rows -- already rewritten now start with `/api/media/%`), so this is safe to -- apply more than once. UPDATE `MediaAsset` SET `url` = CONCAT('/api', `url`) WHERE `url` LIKE '/media/%'; UPDATE `BusinessGalleryImage` SET `imageUrl` = CONCAT('/api', `imageUrl`) WHERE `imageUrl` LIKE '/media/%'; UPDATE `Business` SET `logoUrl` = CONCAT('/api', `logoUrl`) WHERE `logoUrl` LIKE '/media/%'; UPDATE `Business` SET `coverImageUrl` = CONCAT('/api', `coverImageUrl`) WHERE `coverImageUrl` LIKE '/media/%'; UPDATE `Business` SET `faviconUrl` = CONCAT('/api', `faviconUrl`) WHERE `faviconUrl` LIKE '/media/%'; UPDATE `Business` SET `appIconUrl` = CONCAT('/api', `appIconUrl`) WHERE `appIconUrl` LIKE '/media/%'; UPDATE `Business` SET `welcomeBackgroundDesktopUrl` = CONCAT('/api', `welcomeBackgroundDesktopUrl`) WHERE `welcomeBackgroundDesktopUrl` LIKE '/media/%'; UPDATE `Business` SET `welcomeBackgroundMobileUrl` = CONCAT('/api', `welcomeBackgroundMobileUrl`) WHERE `welcomeBackgroundMobileUrl` LIKE '/media/%'; UPDATE `LoyaltyProgramme` SET `cardBackgroundImageUrl` = CONCAT('/api', `cardBackgroundImageUrl`) WHERE `cardBackgroundImageUrl` LIKE '/media/%'; UPDATE `Service` SET `imageUrl` = CONCAT('/api', `imageUrl`) WHERE `imageUrl` LIKE '/media/%'; UPDATE `User` SET `image` = CONCAT('/api', `image`) WHERE `image` LIKE '/media/%';