This guide will help you set up your Supabase database to replace Prisma.
You already have your Supabase environment variables set up:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEY
Run the SQL migration in your Supabase SQL editor:
-- Copy and paste the contents of supabase-migration.sqlRun the seed data in your Supabase SQL editor:
-- Copy and paste the contents of supabase-seed.sql-
Table names: Changed from PascalCase to snake_case
User→usersPet→pets
-
Column names: Changed from camelCase to snake_case
userId→user_idimageUrl→image_urlcreatedAt→created_at
-
ID generation: Using UUID instead of CUID
- Supabase uses
gen_random_uuid()for ID generation
- Supabase uses
All API routes have been updated to use Supabase instead of Prisma:
- ✅
/api/health- Health check - ✅
/api/users- User management - ✅
/api/users/[email]- User by email - ✅
/api/pets- Pet management - ✅
/api/pets/[id]- Pet by ID - ✅
/api/users/user/[id]/pets- User's pets
Updated lib/userAndPetHelpers.ts to use Supabase queries instead of Prisma.
- Health Check: Visit
/api/healthto verify database connection - API Endpoints: Test all your existing API endpoints
- Frontend: Verify that your frontend still works with the new data structure
- Vercel: The build should now work without Prisma dependencies
- Environment Variables: Ensure your Supabase environment variables are set in Vercel
- Database: Make sure your Supabase database is accessible from Vercel
- Row Level Security (RLS): If you get permission errors, check the RLS policies in Supabase
- Column Names: Make sure all references use the new snake_case column names
- ID Types: UUIDs are used instead of CUIDs
- Check the browser console for Supabase errors
- Use the Supabase dashboard to inspect your data
- Test API endpoints directly to isolate issues
After confirming everything works:
- Remove the
prisma/directory - Remove
lib/prisma.ts - Remove
supabase-migration.sqlandsupabase-seed.sql(after running them) - Remove this
SUPABASE_SETUP.mdfile
- ✅ Better Vercel compatibility
- ✅ Real-time subscriptions (if needed)
- ✅ Built-in authentication (if needed)
- ✅ Better performance with edge functions
- ✅ No more Prisma connection issues