-
Notifications
You must be signed in to change notification settings - Fork 886
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
7
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.
+140
−9
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4cde0a6
docs(docs): add Neon to Prisma Postgres migration guide
aidankmcalister eeedb1a
chore(docs): resolve coderabbit comment
aidankmcalister 3100d11
chore(docs): code rabbit comments resolved
aidankmcalister 3a68ec8
Merge remote-tracking branch 'origin/main' into feat/neon-migration-g…
aidankmcalister b4b7e89
refactor(docs): move and rename neon migration guide
aidankmcalister 6b5aeec
refactor(docs): updated to align with the existing supabase guide
aidankmcalister 8161ad0
chore(docs): increase ai chat character limit
aidankmcalister 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
131 changes: 131 additions & 0 deletions
131
apps/docs/content/docs/guides/switch-to-prisma-postgres/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,131 @@ | ||
| --- | ||
| title: Neon | ||
| description: Learn how to migrate from Neon to Prisma Postgres | ||
| url: /guides/switch-to-prisma-postgres/from-neon | ||
| metaTitle: How to migrate from 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 | ||
|
|
||
| If you don't have them installed, install PostgreSQL 17 client tools: | ||
|
|
||
| ```bash | ||
| # 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 | ||
| ``` | ||
|
|
||
| :::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 | ||
| ``` | ||
|
|
||
| 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: | ||
|
|
||
| ```bash | ||
| export NEON_DATABASE_URL='postgresql://USER:PASSWORD@YOUR-NEON-HOST/DATABASE?sslmode=require' | ||
| ``` | ||
|
|
||
| Then run: | ||
|
|
||
| ```bash | ||
| pg_dump \ | ||
| -Fc \ | ||
| -d "$NEON_DATABASE_URL" \ | ||
| -n public \ | ||
| -f neon_dump.bak | ||
| ``` | ||
|
|
||
| ## 3. Import data into Prisma Postgres | ||
|
|
||
| Export your [direct connection string](/postgres/database/direct-connections) from step 1 as an environment variable: | ||
|
|
||
| ```bash | ||
| export PRISMA_POSTGRES_DATABASE_URL='postgres://...' | ||
| ``` | ||
|
|
||
| Then restore: | ||
|
|
||
| ```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. | ||
|
|
||
| :::note | ||
|
|
||
| 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](/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. | ||
2 changes: 1 addition & 1 deletion
2
apps/docs/content/docs/guides/switch-to-prisma-postgres/meta.json
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "title": "Switch to Prisma Postgres", | ||
| "pages": ["from-supabase"] | ||
| "pages": ["from-supabase", "from-neon"] | ||
| } |
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
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.