-
Notifications
You must be signed in to change notification settings - Fork 884
docs(docs): add Neon to Prisma Postgres migration guide #7548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aidankmcalister
wants to merge
3
commits into
main
Choose a base branch
from
feat/neon-migration-guide
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| "flyio", | ||
| "vscode", | ||
| "idx", | ||
| "viewing-data" | ||
| "viewing-data", | ||
| "migrate-from-neon" | ||
| ] | ||
| } | ||
98 changes: 98 additions & 0 deletions
98
apps/docs/content/docs/guides/postgres/migrate-from-neon.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
aidankmcalister marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| 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" | ||
| ``` | ||
aidankmcalister marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.