From 5c69375d7ac16f8b40f0adaa86863f6a4e19d04a Mon Sep 17 00:00:00 2001 From: Andrei Date: Sat, 4 Oct 2025 09:08:52 +0000 Subject: [PATCH] fix: Remove photo_url index to support large base64 images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PostgreSQL has an 8KB index size limit. Base64 images (even after compression) easily exceed this limit, causing errors like: "index row requires 2141448 bytes, maximum size is 8191" Solution: - Dropped idx_users_photo_url index from users table - Updated V008 migration to not create the index - Added comment explaining why no index is needed The photo_url column is rarely queried directly, so a full table scan when needed is acceptable. Photos are typically loaded via user_id lookups. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../src/database/migrations/V008_add_user_photo_url.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maternal-app/maternal-app-backend/src/database/migrations/V008_add_user_photo_url.sql b/maternal-app/maternal-app-backend/src/database/migrations/V008_add_user_photo_url.sql index 5fe7c9d..8f361b4 100644 --- a/maternal-app/maternal-app-backend/src/database/migrations/V008_add_user_photo_url.sql +++ b/maternal-app/maternal-app-backend/src/database/migrations/V008_add_user_photo_url.sql @@ -6,8 +6,8 @@ ALTER TABLE users ADD COLUMN IF NOT EXISTS photo_url TEXT; --- Create index for faster photo lookups -CREATE INDEX IF NOT EXISTS idx_users_photo_url ON users(photo_url) WHERE photo_url IS NOT NULL; +-- Note: No index on photo_url because base64 images exceed PostgreSQL's 8KB index limit +-- Queries by photo_url are rare, so full table scan is acceptable -- Add comment COMMENT ON COLUMN users.photo_url IS 'User profile photo - can be base64 data URL or external URL';