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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ metaTitle: Add Prisma Next to an existing MongoDB project
metaDescription: Add Prisma Next to an existing MongoDB project.
---

This guide shows how to add Prisma Next to a project that already uses MongoDB. You will initialize Prisma Next, describe the collections you want to work with, emit the generated artifacts, and run a couple of queries.
This guide shows how to add Prisma Next to a project that already uses MongoDB. You will run `prisma-next init`, describe the collections you want to work with, emit the generated artifacts, and run a couple of queries.

Use this path when you already have an application and database. If you want Prisma Next to create a new app for you, use the [MongoDB quickstart](/next/quickstart/mongodb).

:::warning[Prisma Next is still in development]

Expand Down Expand Up @@ -41,9 +43,11 @@ Later, `prisma-next init` will also add the Node.js types it needs and make sure
From the root of your existing project, run:

```npm
npx prisma-next init --write-env
npx prisma-next init
```

This is the existing-project path. It adds Prisma Next files and package scripts to the app you already have; it does not scaffold a new framework project.

When Prisma Next asks a few setup questions:

- choose `MongoDB`
Expand All @@ -55,7 +59,7 @@ When Prisma Next asks a few setup questions:
Update `.env` with the connection string for the MongoDB deployment your app already uses:

```text title=".env"
DATABASE_URL="mongodb://127.0.0.1:27017/my-app?replicaSet=rs0"
DATABASE_URL="mongodb://127.0.0.1:27017/app?replicaSet=rs0"
```

## 4. Describe the collections you want Prisma Next to know about
Expand Down Expand Up @@ -166,21 +170,12 @@ Run it again:
npx tsx script.ts
```

## 8. Commands you will use next
## 8. Next steps

Once Prisma Next is in the project, these are the MongoDB commands to remember:
When you change `prisma/contract.prisma`, emit the contract again:

```npm
npx prisma-next contract emit
```

Run this after you change `prisma/contract.prisma`.

```npm
npx prisma-next migration plan --name add-user-bio
npx prisma-next migration apply
```

Use these when you want Prisma Next to manage a schema change for the collections in your contract.

You do not need to create a migration just to start reading collections that already exist. Create a migration when you are ready for Prisma Next to own a change.
You do not need a migration just to read collections that already exist. Use [migration plan](/cli/next/migration-plan) when you want Prisma Next to own a schema change.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
---
title: Postgres
title: PostgreSQL
description: Add Prisma Next to an existing PostgreSQL project.
url: /next/add-to-existing-project/postgresql
metaTitle: Add Prisma Next to an existing Postgres project
metaTitle: Add Prisma Next to an existing PostgreSQL project
metaDescription: Add Prisma Next to an existing PostgreSQL project.
---

This guide shows how to add Prisma Next to a project that already uses PostgreSQL. You will initialize Prisma Next, infer a contract from the live schema, sign the database, and run a couple of queries.
This guide shows how to add Prisma Next to a project that already uses PostgreSQL. You will run `prisma-next init`, infer a contract from the live schema, sign the database, and run a couple of queries.

Use this path when you already have an application and database. If you want Prisma Next to create a new app for you, use the [PostgreSQL quickstart](/next/quickstart/postgresql).

:::warning[Prisma Next is still in development]

Expand Down Expand Up @@ -39,9 +41,11 @@ Later, `prisma-next init` will also add the Node.js types it needs and make sure
From the root of your existing project, run:

```npm
npx prisma-next init --write-env
npx prisma-next init
```

This is the existing-project path. It adds Prisma Next files and package scripts to the app you already have; it does not scaffold a new framework project.

When Prisma Next asks a few setup questions:

- choose `PostgreSQL`
Expand Down Expand Up @@ -166,25 +170,12 @@ Run it again:
npx tsx script.ts
```

## 9. Commands you will use next
## 9. Next steps

Once Prisma Next is in the project, these are the PostgreSQL commands to remember:
When you change `prisma/contract.prisma`, emit the contract again:

```npm
npx prisma-next contract emit
```

Run this after you change `prisma/contract.prisma`.

```npm
npx prisma-next db update
```

Use this when you want Prisma Next to update the live database directly so it matches the latest contract.

```npm
npx prisma-next migration plan --name add-user-bio
npx prisma-next migration apply
```

Use these when you want checked-in migration packages instead of a direct database update.
Use [db update](/cli/next/db-update) for a direct development update, or [migration plan](/cli/next/migration-plan) when you want a checked-in migration.
80 changes: 0 additions & 80 deletions apps/docs/content/docs/(index)/next/create-prisma.mdx

This file was deleted.

61 changes: 61 additions & 0 deletions apps/docs/content/docs/(index)/next/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: Choose a setup path
description: Choose the fastest path to try Prisma Next in a new or existing project.
url: /next/getting-started
metaTitle: Prisma Next getting started
metaDescription: Choose a Prisma Next quickstart for a new project or add Prisma Next to an existing app.
badge: early-access
---

Start with a quickstart if you want Prisma Next to create the app. Use the existing-project path if you already have an app and database.

## Start a new project

```npm
npx create-prisma@next
```

<Cards>
<Card href="/next/quickstart/postgresql" title="Quickstart with PostgreSQL" icon={<Rocket className="text-primary" />}>
Create the app, choose PostgreSQL, initialize the database, seed data, and run the first query.
</Card>
<Card href="/next/quickstart/mongodb" title="Quickstart with MongoDB" icon={<Database className="text-primary" />}>
Create the app, choose MongoDB, start or connect to MongoDB, seed data, and run the first query.
</Card>
</Cards>

## Use Prisma Postgres

```npm
npx create-prisma@next
```

<Cards>
<Card href="/next/prisma-postgres/quickstart/prisma-next" title="Quickstart with Prisma Postgres" icon={<Database className="text-primary" />}>
Create a Prisma Next app and let setup provision Prisma Postgres for the first run.
</Card>
<Card href="/next/prisma-postgres/from-the-cli" title="From the CLI" icon={<Terminal className="text-primary" />}>
Start from the command line when you want the Prisma Postgres path without browsing Console first.
</Card>
</Cards>

## Add to an existing project

```npm
npx prisma-next init
```

<Cards>
<Card href="/next/add-to-existing-project/postgresql" title="Add to PostgreSQL" icon={<Database className="text-primary" />}>
Add Prisma Next to an existing PostgreSQL app and infer a starter contract from the live schema.
</Card>
<Card href="/next/add-to-existing-project/mongodb" title="Add to MongoDB" icon={<Database className="text-primary" />}>
Add Prisma Next to an existing MongoDB app and model the collections you want to query first.
</Card>
</Cards>

## After setup

- Use the generated app scripts for the first run.
- Change the starter contract when you are ready to model your own data.
- Open the [Prisma Next overview](/orm/next) when you want the concepts behind the setup.
63 changes: 46 additions & 17 deletions apps/docs/content/docs/(index)/next/index.mdx
Original file line number Diff line number Diff line change
@@ -1,29 +1,58 @@
---
title: Get started with Prisma Next
description: Start a new Prisma Next app or add Prisma Next to an existing project.
title: Introduction to Prisma Next
description: Prisma Next is the next foundation for Prisma ORM.
url: /next
metaTitle: Get started with Prisma Next
metaDescription: Start a Prisma Next project with create-prisma@next or add Prisma Next to an existing project.
metaTitle: Introduction to Prisma Next
metaDescription: Prisma Next is the next foundation for Prisma ORM.
badge: early-access
---

Prisma Next is the next foundation for Prisma ORM. Start here if you want to try the Prisma Next workflow.
Prisma Next is the next foundation for Prisma ORM. It is an early access version of the ORM runtime, query APIs, migration flow, and project setup.

:::warning[Prisma Next is still in development]

Prisma Next is not ready for production yet. Prisma ORM 7 is still the recommended choice for production applications today.

:::

## Start a new project

- [Scaffold a Prisma Next app with create-prisma@next](/next/create-prisma)

## Add Prisma Next to an existing project

- [Add Prisma Next to an existing PostgreSQL project](/next/add-to-existing-project/postgresql)
- [Add Prisma Next to an existing MongoDB project](/next/add-to-existing-project/mongodb)

## Learn the ORM workflow

Read the [Prisma Next overview](/orm/next) to learn about contracts, emitted artifacts, runtime clients, query styles, and database change commands.
Use Prisma Next when you want to try the new developer experience before it becomes the default Prisma ORM path.

```npm
npx create-prisma@next
```

Start with the setup page when you want a guided first run.

<Cards>
<Card href="/next/getting-started" title="Choose a setup path" icon={<Rocket className="text-primary" />}>
Pick a new-project quickstart or add Prisma Next to an existing app.
</Card>
</Cards>

## What you can try

<Cards>
<Card href="/next/quickstart/postgresql" title="Quickstart with PostgreSQL" icon={<Rocket className="text-primary" />}>
Create a Prisma Next app, initialize the database, seed data, and run the first query.
</Card>
<Card href="/next/quickstart/mongodb" title="Quickstart with MongoDB" icon={<Database className="text-primary" />}>
Create a Prisma Next app with a local MongoDB replica set or your own MongoDB deployment.
</Card>
<Card href="/next/add-to-existing-project/postgresql" title="Add to PostgreSQL" icon={<Database className="text-primary" />}>
Add Prisma Next to an existing PostgreSQL app with `prisma-next init`.
</Card>
<Card href="/next/add-to-existing-project/mongodb" title="Add to MongoDB" icon={<Database className="text-primary" />}>
Add Prisma Next to an existing MongoDB app and model the collections you want to query first.
</Card>
<Card href="/next/prisma-postgres/quickstart/prisma-next" title="Use Prisma Postgres" icon={<Database className="text-primary" />}>
Create a Prisma Next app backed by Prisma Postgres.
</Card>
</Cards>

## Learn the concepts

<Cards>
<Card href="/orm/next" title="Prisma Next overview" icon={<BookOpen className="text-primary" />}>
Learn the core ideas behind contracts, emitted artifacts, runtime clients, query styles, and migrations.
</Card>
</Cards>
10 changes: 7 additions & 3 deletions apps/docs/content/docs/(index)/next/meta.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"title": "Next",
"title": "Prisma Next",
"defaultOpen": true,
"root": true,
"pages": [
"---Getting Started---",
"index",
"create-prisma",
"add-to-existing-project"
"getting-started",
"---Prisma ORM---",
"quickstart",
"add-to-existing-project",
"---Prisma Postgres---",
"...prisma-postgres"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: From the CLI
description: Start a Prisma Next app with Prisma Postgres from the command line.
url: /next/prisma-postgres/from-the-cli
metaTitle: Prisma Next with Prisma Postgres from the CLI
metaDescription: Start a Prisma Next app with Prisma Postgres from the command line.
badge: early-access
---

Use the CLI when you want Prisma Next and Prisma Postgres set up without leaving the terminal.

## Start a new app

```npm
npx create-prisma@next
```

Choose PostgreSQL and Prisma Postgres when prompted.

Then run the generated scripts:

```npm
cd <project-directory>
npm run db:init
npm run db:seed
npm run dev
```

## Add Prisma Next to an existing app

If the app already exists, run Prisma Next from the project root:

```npm
npx prisma-next init
```

Choose PostgreSQL, set `DATABASE_URL` to your Prisma Postgres connection string, then follow the [PostgreSQL existing-project guide](/next/add-to-existing-project/postgresql).

## Import an existing database

- Use [Import from PostgreSQL](/next/prisma-postgres/import-from-existing-database-postgresql) when your source database is PostgreSQL.
- Use [Import from MySQL](/next/prisma-postgres/import-from-existing-database-mysql) when your source database is MySQL.
Loading
Loading