Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/docs/content/docs/guides/postgres/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"flyio",
"vscode",
"idx",
"viewing-data"
"viewing-data",
"migrate-from-neon"
]
}
98 changes: 98 additions & 0 deletions apps/docs/content/docs/guides/postgres/migrate-from-neon.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
title: Neon to Prisma Postgres
description: Learn how to migrate from Neon to Prisma Postgres
url: /guides/postgres/migrate-from-neon
metaTitle: Neon to Prisma Postgres
metaDescription: 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](https://console.prisma.io) account
- PostgreSQL CLI tools (`pg_dump`, `pg_restore`) version 17

:::info[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

1. Log in to [Prisma Data Platform](https://console.prisma.io/) and open the Console.
1. In a [workspace](/console/concepts#workspace) of your choice, click **New project**.
1. Name your project, then click **Get started** under **Prisma Postgres**.
1. 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.
1. Click **Create API key**, give it a name, and click **Create**.
1. 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`:

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

Then run the following command, replacing `$NEON_DATABASE_URL` with your actual Neon database URL:

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

## 3. Import data into Prisma Postgres

To restore, replace `$PRISMA_POSTGRES_DATABASE_URL` with your [direct connection string](/postgres/database/direct-connections) from step 1:

```bash
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](/docs/studio) from the **Studio** tab in your project, or run:

```npm
npx prisma studio
```

## 4. Update your application

### Already using Prisma ORM

Update `DATABASE_URL` in your `.env` file:

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

Then regenerate Prisma Client:

```npm
npx prisma generate
```

:::tip

See the [Prisma ORM with Prisma Postgres quickstart](/prisma-orm/quickstart/prisma-postgres) for driver adapter configuration and best practices.

:::

### Not yet using Prisma ORM

Follow [Add Prisma ORM to an existing project](/prisma-orm/add-to-existing-project/prisma-postgres) to introspect your database, generate a schema, and migrate your queries.
Loading