Cursorcursorintermediate
Migrate from Prisma to Supabase Client (Cursor Prompt)
Cursor prompt to migrate from Prisma ORM to the Supabase client with schema conversion and query rewriting.
What you'll get
Project migrated from Prisma to Supabase client with equivalent queries, RLS policies, and type safety.
The Prompt
Migrate this project from Prisma ORM to the Supabase JavaScript client.
STEPS:
1. Read the existing prisma/schema.prisma to understand the data model.
2. Create equivalent Supabase tables using SQL migrations in supabase/migrations/. Map Prisma types to PostgreSQL types.
3. Generate TypeScript types from the Supabase schema using: npx supabase gen types typescript.
4. Create src/lib/supabase/client.ts and src/lib/supabase/server.ts if they don't exist.
5. For every file that imports from '@prisma/client', replace Prisma queries with Supabase equivalents:
- prisma.user.findMany() -> supabase.from('users').select('*')
- prisma.user.findUnique({ where: { id } }) -> supabase.from('users').select('*').eq('id', id).single()
- prisma.user.create({ data }) -> supabase.from('users').insert(data)
- prisma.user.update({ where, data }) -> supabase.from('users').update(data).eq('id', id)
- prisma.user.delete({ where }) -> supabase.from('users').delete().eq('id', id)
- Include/relation queries -> use .select('*, posts(*)') for joins
6. Add RLS policies for each table based on the existing access patterns.
7. Remove Prisma dependencies: @prisma/client, prisma. Delete prisma/ directory.
DO NOT:
- Change the API response shapes — keep the same data structure
- Modify frontend components
- Change environment variable names (add new ones alongside existing)
ENVIRONMENT VARIABLES TO ADD:
- NEXT_PUBLIC_SUPABASE_URL
- NEXT_PUBLIC_SUPABASE_ANON_KEY
- SUPABASE_SERVICE_ROLE_KEYReplace these variables
| Variable | Replace with |
|---|---|
| [PRISMA_SCHEMA_PATH] | Path to existing Prisma schema file |
Tips for best results
Test each migrated query individually — Supabase and Prisma handle nulls and relations differently.
Keep the Prisma schema as reference until the migration is fully tested and verified.
Follow-up prompts
Add Supabase Realtime
Now that the migration is complete, add Supabase Realtime subscriptions to replace any polling patterns that existed with Prisma.