Switch to Prisma Postgres

Neon

Learn how to migrate from Neon to Prisma Postgres

This guide walks you through migrating data from Neon to Prisma Postgres using pg_dump and pg_restore.

Prerequisites

  • A Neon database connection URL

  • A Prisma Data Platform account

  • PostgreSQL CLI tools (pg_dump, pg_restore) version 17

    If 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

1. Create a new Prisma Postgres database

  1. Log in to Prisma Data Platform and open the Console.
  2. In a workspace of your choice, click New project.
  3. Name your project, then click Get started under Prisma Postgres.
  4. Select a region and click Create project.

Once provisioned, get your direct connection string:

  1. Click the API Keys tab in your project's sidenav.
  2. Click Create API key, give it a name, and click Create.
  3. Copy the connection string starting with postgres:// — you'll need this in step 3.

2. Export data from Neon

Copy a non-pooled connection string from Neon (disable Connection pooling) and ensure it includes sslmode=require:

postgresql://USER:PASSWORD@YOUR-NEON-HOST/DATABASE?sslmode=require

Export 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 NEON_DATABASE_URL='postgresql://USER:PASSWORD@YOUR-NEON-HOST/DATABASE?sslmode=require'

Then run:

pg_dump \
  -Fc \
  -d "$NEON_DATABASE_URL" \
  -n public \
  -f neon_dump.bak

3. 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" \
  neon_dump.bak

The --no-owner and --no-acl flags skip Neon-specific role assignments that don't exist in Prisma Postgres.

To validate the import, open Prisma Studio from the Studio tab in your project, or run:

npx prisma studio

4. Update your application

Already using Prisma ORM

Update DATABASE_URL in your .env file:

.env
DATABASE_URL="postgres://USER:PASSWORD@db.prisma.io:5432/?sslmode=require"

Then regenerate Prisma Client:

npx prisma generate

Not yet using Prisma ORM

Follow Add Prisma ORM to an existing project to introspect your database, generate a schema, and migrate your queries.

On this page