Supabase
Learn how to migrate from Supabase to Prisma Postgres
This guide walks you through migrating data from Supabase to Prisma Postgres using pg_dump and pg_restore.
Prerequisites
-
A Supabase database connection URL
-
A Prisma Data Platform account
-
PostgreSQL CLI tools (
pg_dump,pg_restore) version 17If you don't have them installed, install PostgreSQL 17 client tools:
# macOS brew install libpq brew link --force libpq # Debian / Ubuntu sudo apt-get install postgresql-client-17 # Windows (via installer) # Download from https://www.postgresql.org/download/windows/ # Select "Command Line Tools" during installation
Make sure your PostgreSQL tools match the Prisma Postgres version
Prisma Postgres runs PostgreSQL 17. Run pg_dump --version or pg_restore --version to confirm.
1. Create a new Prisma Postgres database
- Log in to Prisma Data Platform and open the Console.
- In a workspace of your choice, click New project.
- Name your project, then click Get started under Prisma Postgres.
- Select a region and click Create project.
Once provisioned, get your direct connection string:
- Click the API Keys tab in your project's sidenav.
- Click Create API key, give it a name, and click Create.
- Copy the connection string starting with
postgres://— you'll need this in step 3.
2. Export data from Supabase
Copy the direct connection string from your Supabase project. In the Supabase Dashboard, go to Project Settings → Database → Connection string → URI and select the Direct connection type (not the pooled Supavisor connection):
postgresql://postgres:[PASSWORD]@db.[PROJECT-REF].supabase.co:5432/postgresExport the connection string as an environment variable. Use single quotes so that special characters in your password (like !, $, or #) are not interpreted by the shell:
export SUPABASE_DATABASE_URL='postgresql://postgres:[PASSWORD]@db.[PROJECT-REF].supabase.co:5432/postgres'Then run:
pg_dump \
-Fc \
-d "$SUPABASE_DATABASE_URL" \
-n public \
-f supabase_dump.bak3. Import data into Prisma Postgres
Export your direct connection string from step 1 as an environment variable:
export PRISMA_POSTGRES_DATABASE_URL='postgres://...'Then restore:
pg_restore \
--no-owner \
--no-acl \
-d "$PRISMA_POSTGRES_DATABASE_URL" \
supabase_dump.bakThe --no-owner and --no-acl flags skip Supabase-specific role assignments that don't exist in Prisma Postgres.
You can safely ignore the warning schema "public" already exists. The public schema is pre-created in every Prisma Postgres database, so the CREATE SCHEMA public command from the dump is redundant. Your data is still imported correctly.
To validate the import, open Prisma Studio from the Studio tab in your project, or run:
npx prisma studio4. Update your application
Already using Prisma ORM
Update DATABASE_URL in your .env file:
DATABASE_URL="postgres://USER:PASSWORD@db.prisma.io:5432/?sslmode=require"Then regenerate Prisma Client:
npx prisma generateSee the Prisma ORM with Prisma Postgres quickstart for driver adapter configuration and best practices.
Not yet using Prisma ORM
Follow Add Prisma ORM to an existing project to introspect your database, generate a schema, and migrate your queries.