Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
131 changes: 131 additions & 0 deletions apps/docs/content/docs/guides/switch-to-prisma-postgres/from-neon.mdx
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
```

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"
```

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.
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"]
}
16 changes: 8 additions & 8 deletions apps/docs/src/components/ai-elements/prompt-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const PromptInput = forwardRef<HTMLTextAreaElement, PromptInputProps>(
className,
...props
},
ref
ref,
) => {
const textareaRef = useRef<HTMLTextAreaElement>(null);
useImperativeHandle(ref, () => textareaRef.current!);
Expand All @@ -57,7 +57,7 @@ export const PromptInput = forwardRef<HTMLTextAreaElement, PromptInputProps>(
onSubmit(value.trim());
}
},
[value, disabled, loading, onSubmit]
[value, disabled, loading, onSubmit],
);

const handleKeyDown = useCallback(
Expand All @@ -69,7 +69,7 @@ export const PromptInput = forwardRef<HTMLTextAreaElement, PromptInputProps>(
}
}
},
[value, disabled, loading, onSubmit]
[value, disabled, loading, onSubmit],
);

const handleInput = useCallback(() => {
Expand All @@ -80,7 +80,7 @@ export const PromptInput = forwardRef<HTMLTextAreaElement, PromptInputProps>(
}
}, []);

const maxLength = 1000;
const maxLength = 10000;

return (
<form
Expand Down Expand Up @@ -119,7 +119,7 @@ export const PromptInput = forwardRef<HTMLTextAreaElement, PromptInputProps>(
size: "icon-sm",
}),
"h-8 w-8 rounded-full",
loading && "opacity-50 cursor-not-allowed"
loading && "opacity-50 cursor-not-allowed",
)}
>
<BrainIcon className="size-4" />
Expand Down Expand Up @@ -177,10 +177,10 @@ export const PromptInput = forwardRef<HTMLTextAreaElement, PromptInputProps>(
</InputGroup>
</form>
);
}
},
);

PromptInput.displayName = "PromptInput"
PromptInput.displayName = "PromptInput";

export type PromptInputFooterProps = ComponentProps<"div"> & {
attribution?: string;
Expand All @@ -196,7 +196,7 @@ export const PromptInputFooter = ({
<div
className={cn(
"text-xs text-center text-fd-muted-foreground pt-2",
className
className,
)}
{...props}
>
Expand Down
Loading