From e5499fa2f46e650c8f7400381d4984282bfdf1cb Mon Sep 17 00:00:00 2001 From: Aman Varshney Date: Tue, 24 Mar 2026 17:10:08 +0530 Subject: [PATCH 1/2] ok --- apps/docs/content/docs.v6/(index)/index.mdx | 2 +- .../prisma-orm/quickstart/prisma-postgres.mdx | 11 ++- .../(index)/prisma-postgres/from-the-cli.mdx | 70 +++---------------- .../prisma-postgres/quickstart/prisma-orm.mdx | 13 ++-- .../docs/content/docs.v6/ai/prompts/astro.mdx | 4 +- .../content/docs.v6/ai/prompts/nextjs.mdx | 58 +++++++-------- .../content/docs.v6/guides/ai-sdk-nextjs.mdx | 15 ++-- apps/docs/content/docs.v6/guides/astro.mdx | 14 +++- .../content/docs.v6/guides/authjs-nextjs.mdx | 15 ++-- .../docs.v6/guides/betterauth-astro.mdx | 15 ++-- .../docs.v6/guides/betterauth-nextjs.mdx | 15 ++-- apps/docs/content/docs.v6/guides/bun.mdx | 22 +++--- .../content/docs.v6/guides/clerk-astro.mdx | 14 +++- .../content/docs.v6/guides/clerk-nextjs.mdx | 14 +++- .../docs.v6/guides/cloudflare-workers.mdx | 14 +++- apps/docs/content/docs.v6/guides/data-dog.mdx | 14 ++-- apps/docs/content/docs.v6/guides/elysia.mdx | 14 +++- .../docs.v6/guides/embed-studio-nextjs.mdx | 15 ++-- .../content/docs.v6/guides/github-actions.mdx | 8 ++- apps/docs/content/docs.v6/guides/hono.mdx | 14 +++- .../docs.v6/guides/multiple-databases.mdx | 5 +- apps/docs/content/docs.v6/guides/nestjs.mdx | 10 ++- apps/docs/content/docs.v6/guides/nextjs.mdx | 15 ++-- .../content/docs.v6/guides/react-router-7.mdx | 15 ++-- apps/docs/content/docs.v6/guides/shopify.mdx | 28 ++++---- .../content/docs.v6/guides/solid-start.mdx | 15 ++-- .../docs/content/docs.v6/guides/sveltekit.mdx | 15 ++-- .../docs/content/docs.v6/guides/turborepo.mdx | 15 ++-- .../guides/use-prisma-in-pnpm-workspaces.mdx | 18 +++-- .../orm/overview/databases/postgresql.mdx | 2 +- .../prisma-studio/embedding-studio.mdx | 2 +- .../docs.v6/postgres/getting-started.mdx | 12 +++- apps/docs/content/docs/(index)/index.mdx | 2 +- .../prisma-orm/quickstart/prisma-postgres.mdx | 19 +++-- .../(index)/prisma-postgres/from-the-cli.mdx | 16 ++--- .../prisma-postgres/quickstart/prisma-orm.mdx | 13 ++-- apps/docs/content/docs/ai/prompts/astro.mdx | 4 +- apps/docs/content/docs/ai/prompts/nextjs.mdx | 58 +++++++-------- apps/docs/content/docs/ai/prompts/nuxt.mdx | 56 +++++++-------- .../docs/ai/tutorials/typefully-clone.mdx | 17 ++--- .../guides/authentication/authjs/nextjs.mdx | 15 ++-- .../authentication/better-auth/astro.mdx | 15 ++-- .../authentication/better-auth/nextjs.mdx | 15 ++-- .../guides/authentication/clerk/astro.mdx | 14 +++- .../guides/authentication/clerk/nextjs.mdx | 14 +++- .../guides/database/multiple-databases.mdx | 5 +- .../docs/guides/deployment/bun-workspaces.mdx | 18 +++-- .../guides/deployment/cloudflare-workers.mdx | 14 +++- .../guides/deployment/pnpm-workspaces.mdx | 16 +++-- .../docs/guides/deployment/turborepo.mdx | 13 ++-- .../content/docs/guides/frameworks/astro.mdx | 14 +++- .../content/docs/guides/frameworks/elysia.mdx | 14 +++- .../content/docs/guides/frameworks/hono.mdx | 14 +++- .../content/docs/guides/frameworks/nestjs.mdx | 10 ++- .../content/docs/guides/frameworks/nextjs.mdx | 15 ++-- .../docs/guides/frameworks/react-router-7.mdx | 15 ++-- .../docs/guides/frameworks/solid-start.mdx | 15 ++-- .../docs/guides/frameworks/sveltekit.mdx | 15 ++-- .../docs/guides/integrations/ai-sdk.mdx | 15 ++-- .../docs/guides/integrations/datadog.mdx | 14 ++-- .../docs/guides/integrations/embed-studio.mdx | 13 ++-- .../guides/integrations/github-actions.mdx | 8 ++- .../docs/guides/integrations/shopify.mdx | 28 ++++---- .../content/docs/guides/making-guides.mdx | 12 +++- .../docs/content/docs/guides/runtimes/bun.mdx | 22 +++--- .../content/docs/guides/runtimes/deno.mdx | 22 +++--- 66 files changed, 650 insertions(+), 433 deletions(-) diff --git a/apps/docs/content/docs.v6/(index)/index.mdx b/apps/docs/content/docs.v6/(index)/index.mdx index 42479025ad..1c3650d6d4 100644 --- a/apps/docs/content/docs.v6/(index)/index.mdx +++ b/apps/docs/content/docs.v6/(index)/index.mdx @@ -11,7 +11,7 @@ metaDescription: 'Build data-driven applications with ease using Prisma ORM, add [**Prisma ORM**](/v6/orm/overview/introduction/what-is-prisma) is an open-source ORM that provides fast, type-safe access to Postgres, MySQL, SQLite, and more databases. ```npm -npx prisma init --db +npx prisma init ``` ## Prisma Postgres diff --git a/apps/docs/content/docs.v6/(index)/prisma-orm/quickstart/prisma-postgres.mdx b/apps/docs/content/docs.v6/(index)/prisma-orm/quickstart/prisma-postgres.mdx index d7009d7758..1f9df35aa6 100644 --- a/apps/docs/content/docs.v6/(index)/prisma-orm/quickstart/prisma-postgres.mdx +++ b/apps/docs/content/docs.v6/(index)/prisma-orm/quickstart/prisma-postgres.mdx @@ -69,19 +69,18 @@ npx prisma Next, set up your Prisma ORM project by creating your [Prisma Schema](/v6/orm/prisma-schema/overview) file with the following command: ```npm -npx prisma init --db --output ../generated/prisma +npx prisma init --output ../generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database. +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. ::: This command does a few things: - Creates a `prisma/` directory with a `schema.prisma` file containing your database connection and schema models -- Creates a new Prisma Postgres database (when using `--db` flag) - Creates a `.env` file in the root directory for environment variables - Creates a `prisma.config.ts` file for Prisma configuration @@ -115,6 +114,12 @@ datasource db { } ``` +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ## 5. Define your data model Open `prisma/schema.prisma` and add the following models: diff --git a/apps/docs/content/docs.v6/(index)/prisma-postgres/from-the-cli.mdx b/apps/docs/content/docs.v6/(index)/prisma-postgres/from-the-cli.mdx index d12d9d8a13..d1462ffafc 100644 --- a/apps/docs/content/docs.v6/(index)/prisma-postgres/from-the-cli.mdx +++ b/apps/docs/content/docs.v6/(index)/prisma-postgres/from-the-cli.mdx @@ -6,7 +6,7 @@ metaTitle: From the CLI metaDescription: Start building a Prisma application with a Prisma Postgres database from the CLI --- -This page provides a step-by-step guide for Prisma Postgres after setting it up with `prisma init --db`: +This page provides a step-by-step guide for Prisma Postgres after setting it up with `prisma init` and `npx create-db`: 1. Set up a TypeScript app with Prisma ORM 1. Migrate the schema of your database @@ -14,79 +14,27 @@ This page provides a step-by-step guide for Prisma Postgres after setting it up ## Prerequisites -This guide assumes you set up [Prisma Postgres](/v6/postgres) instance with `prisma init --db`: +This guide assumes you initialized Prisma with `prisma init` and created a Prisma Postgres database with `npx create-db`: ```npm -npx prisma@latest init --db +npx prisma@latest init +npx create-db ``` -```text no-copy wrap -✓ Select an authentication method Google -Authenticating to Prisma Platform via browser. +Replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from `npx create-db` before continuing. -Visit the following URL in your browser to authenticate: -https://console.prisma.io/auth/cli?state=eyJjb6ll... +Once these commands terminated: -Successfully authenticated as jon@doe.com. -Let's set up your Prisma Postgres database! -✓ Select your region: ap-southeast-1 - Asia Pacific (Singapore) -✓ Enter a project name: My Prisma Project -✓ Success! Your Prisma Postgres database is ready ✅ - -We found an existing schema.prisma file in your current project directory. - ---- Database URL --- - -Connect Prisma ORM to your Prisma Postgres database with this URL: - ---- Next steps --- - -Go to https://pris.ly/ppg-init for detailed instructions. - -1. Install the Postgres adapter -npm install @prisma/adapter-pg - -...and add it to your Prisma Client instance: - -import { PrismaClient } from "./generated/prisma/client"; -import { PrismaPg } from "@prisma/adapter-pg"; - -const connectionString = `${process.env.DATABASE_URL}`; - -const adapter = new PrismaPg({ connectionString }); -const prisma = new PrismaClient({ adapter }); - -2. Apply migrations -Run the following command to create and apply a migration: -npx prisma migrate dev - -3. Manage your data -View and edit your data locally by running this command: -npx prisma studio - -...or online in Console: -https://console.prisma.io/$path - -4. Send queries from your app -If you already have an existing app with Prisma ORM, you can now run it and it will send queries against your newly created Prisma Postgres instance. - -5. Learn more -For more info, visit the Prisma Postgres docs: https://pris.ly/ppg-docs -``` - -Once this command terminated: - -- You're logged into Prisma Data Platform. -- A new Prisma Postgres instance was created. - The `prisma/` folder was created with an empty `schema.prisma` file. - The `DATABASE_URL` env var was set in a `.env` file. - The `prisma.config.ts` file was created with the default configuration. +- You have a Prisma Postgres connection string to paste into `.env`. ## 1. Organize your project directory :::note -If you ran the `prisma init --db` command inside a folder where you want your project to live, you can skip this step and [proceed to the next section](/v6/prisma-postgres/from-the-cli#2-set-up-your-project). +If you ran the `prisma init` command inside a folder where you want your project to live, you can skip this step and [proceed to the next section](/v6/prisma-postgres/from-the-cli#2-set-up-your-project). ::: @@ -178,7 +126,7 @@ Here's what each package does: ### 2.4. Review the generated prisma.config.ts -The `prisma init --db` command automatically created a `prisma.config.ts` file that looks like this: +The `prisma init` command automatically created a `prisma.config.ts` file that looks like this: ```typescript title="prisma.config.ts" import "dotenv/config"; diff --git a/apps/docs/content/docs.v6/(index)/prisma-postgres/quickstart/prisma-orm.mdx b/apps/docs/content/docs.v6/(index)/prisma-postgres/quickstart/prisma-orm.mdx index 16599db3e1..b4c3deb04f 100644 --- a/apps/docs/content/docs.v6/(index)/prisma-postgres/quickstart/prisma-orm.mdx +++ b/apps/docs/content/docs.v6/(index)/prisma-postgres/quickstart/prisma-orm.mdx @@ -56,24 +56,23 @@ Update `package.json` to enable ESM: } ``` -## 4. Initialize Prisma ORM and create a Prisma Postgres database +## 4. Initialize Prisma ORM Next, set up your Prisma ORM project by creating your [Prisma Schema](/v6/orm/prisma-schema/overview) file with the following command: ```npm -npx prisma init --db --output ../generated/prisma +npx prisma init --output ../generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database. +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, replace that value with a direct `postgres://...` connection string from Prisma Postgres. ::: This command does a few things: - Creates a `prisma/` directory with a `schema.prisma` file containing your database connection and schema models -- Creates a new Prisma Postgres database (when using `--db` flag) - Creates a `.env` file in the root directory for environment variables - Generates the Prisma Client in the `generated/prisma/` directory - Creates a `prisma.config.ts` file for Prisma configuration @@ -108,6 +107,12 @@ datasource db { } ``` +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ## 5. Define your data model Open `prisma/schema.prisma` and add the following models: diff --git a/apps/docs/content/docs.v6/ai/prompts/astro.mdx b/apps/docs/content/docs.v6/ai/prompts/astro.mdx index 7229d21b7e..e186d2b794 100644 --- a/apps/docs/content/docs.v6/ai/prompts/astro.mdx +++ b/apps/docs/content/docs.v6/ai/prompts/astro.mdx @@ -82,7 +82,7 @@ export default prisma 5. You MUST wrap all database calls in try-catch blocks 6. You MUST import from `'../generated/prisma/client'` (not `'@prisma/client'`) 7. You MUST use `import.meta.env.DATABASE_URL` in Astro (not `process.env`) -8. You MUST ALWAYS use the full `npx prisma init` command with ALL flags: `npx prisma init --db --output ../src/generated/prisma --generator-provider prisma-client` +8. You MUST use `npx prisma init --output ../src/generated/prisma` before editing the Prisma schema. If you need Prisma Postgres, run `npx create-db` and update `.env` with the returned `postgres://...` value ## CORRECT INSTALLATION @@ -97,7 +97,7 @@ npm install @prisma/extension-accelerate @prisma/client ## CORRECT PRISMA INITIALIZATION ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` ## CORRECT SCHEMA CONFIGURATION diff --git a/apps/docs/content/docs.v6/ai/prompts/nextjs.mdx b/apps/docs/content/docs.v6/ai/prompts/nextjs.mdx index 64abe95d8b..0b997f864c 100644 --- a/apps/docs/content/docs.v6/ai/prompts/nextjs.mdx +++ b/apps/docs/content/docs.v6/ai/prompts/nextjs.mdx @@ -164,7 +164,7 @@ export default prisma 10. You MUST create a test script at `scripts/test-database.ts` to verify setup 11. You MUST NOT include `url` in the datasource block of `schema.prisma` 12. You MUST NOT include `engine` property in `prisma.config.ts` -13. You MUST use `npx prisma init --db --output ../app/generated/prisma` to create a real cloud database +13. You MUST use `npx prisma init --output ../app/generated/prisma` to scaffold Prisma, then `npx create-db` to create a real cloud database 14. You MUST use standard TCP URLs (`postgres://...`) in .env 15. You MUST NOT use `accelerateUrl` or `withAccelerate` @@ -186,37 +186,35 @@ npm install @prisma/adapter-pg @prisma/client dotenv ## CORRECT PRISMA INITIALIZATION -> **FOR AI ASSISTANTS**: This command is **interactive** and requires user input. You **MUST ask the user to run this command manually** in their own terminal, then **wait for them to confirm completion** before proceeding with the next steps. Do NOT attempt to run this command yourself. +> **FOR AI ASSISTANTS**: `npx prisma init` is not interactive. Run it yourself if your environment allows it. If you need a real Prisma Postgres database, either run `npx create-db` or ask the user to run it and update `DATABASE_URL` before you continue. ```bash -# Initialize Prisma AND create a real Prisma Postgres cloud database -npx prisma init --db --output ../app/generated/prisma +# Initialize Prisma and scaffold the Prisma files +npx prisma init --output ../app/generated/prisma + +# Then create a Prisma Postgres database +npx create-db ``` -This command: +This step: -- Authenticates you with Prisma Console (if needed) -- Prompts for **region** and **project name** -- **Creates a cloud Prisma Postgres database** -- Generates: - - `prisma/schema.prisma` (with correct output path) - - `prisma.config.ts` (with dotenv import) - - **`.env` with a `DATABASE_URL`** +- Generates `prisma/schema.prisma` with the correct output path +- Generates `prisma.config.ts` +- Generates `.env` with a local `DATABASE_URL` +- Requires `npx create-db` if you want a real Prisma Postgres database -**IMPORTANT**: Ensure the generated `.env` uses a `postgres://` URL scheme. If it generates `prisma+postgres://`, replace it with the standard TCP connection string available in the Prisma Console. +**IMPORTANT**: After `npx create-db`, replace the generated `DATABASE_URL` in `.env` with the returned `postgres://...` connection string. ```text DATABASE_URL="postgres://..." ``` -**IMPORTANT**: Do NOT use `npx prisma init` without `--db` as this only creates local files without a database. - ## CORRECT PRISMA CONFIG (prisma.config.ts) -When using `npx prisma init --db`, the `prisma.config.ts` is **auto-generated** with the correct configuration: +When using `npx prisma init`, the `prisma.config.ts` is **auto-generated** with the correct configuration: ```typescript -import "dotenv/config"; // ✅ Auto-included by prisma init --db +import "dotenv/config"; // ✅ Auto-included by prisma init import { defineConfig, env } from "prisma/config"; export default defineConfig({ @@ -442,30 +440,26 @@ User should follow these steps (AI should provide these instructions): npm install @prisma/adapter-pg @prisma/client dotenv ``` -2. **Initialize Prisma AND create Prisma Postgres database** (⚠️ USER MUST RUN MANUALLY): +2. **Initialize Prisma, then create Prisma Postgres:** - > **AI ASSISTANT**: Ask the user to run this command in their own terminal. This is interactive and requires user input. Wait for the user to confirm completion before continuing. + > **AI ASSISTANT**: You can run `npx prisma init` yourself. If you should not provision cloud resources automatically, ask the user to run `npx create-db` and update `DATABASE_URL` before continuing. ```npm - npx prisma init --db --output ../app/generated/prisma + npx prisma init --output ../app/generated/prisma + npx create-db ``` - The user should follow the terminal prompts to: - - Authenticate with Prisma Console (if needed) - - Choose a region (e.g., us-east-1) - - Name your project - - Once complete, this creates `prisma/schema.prisma`, `prisma.config.ts`, AND `.env` with the `DATABASE_URL`. + This creates `prisma/schema.prisma`, `prisma.config.ts`, and `.env`, then returns a `postgres://...` connection string for Prisma Postgres. - **User should confirm when done** so the AI can proceed with the next steps. + **If you asked the user to run `npx create-db`, wait for them to share or paste the returned connection string before proceeding.** -3. **Verify `.env` was created** - Ensure `DATABASE_URL` uses `postgres://`. If it uses `prisma+postgres://`, change it to the TCP connection string. +3. **Verify `.env` was created** - Replace the generated `DATABASE_URL` with the `postgres://...` connection string returned by `npx create-db`. ```text DATABASE_URL="postgres://..." ``` - **Do NOT invent or manually change this URL. Use the one from Prisma Console.** + **Do NOT invent this URL. Use the one returned by `npx create-db`.** 4. **Update `prisma/schema.prisma`** - Add the User model (generator and datasource are already configured): @@ -524,7 +518,7 @@ Before generating any code, you MUST verify: 10. Did you add `db:test` and `db:studio` scripts to package.json? If not, STOP and FIX. 11. Did you remove `url` from the datasource block in `schema.prisma`? If not, STOP and FIX. 12. Did you remove `engine` property from `prisma.config.ts`? If not, STOP and FIX. -13. Are you using `npx prisma init --db` (not just `npx prisma init`)? If not, STOP and FIX. +13. Did you run `npx prisma init` with the documented output path? If not, STOP and FIX. 14. Is the DATABASE_URL a TCP URL (`postgres://...`)? If it's a `prisma+postgres://` URL, STOP and FIX. 15. Did Prisma generate the `.env` file? If you invented the URL manually, STOP and FIX. @@ -625,8 +619,8 @@ When asked about Prisma + Next.js implementation, you MUST: 11. ALWAYS use `@prisma/adapter-pg` and `adapter` property 12. NEVER include `url` in the datasource block of schema.prisma 13. NEVER include `engine` property in prisma.config.ts -14. ALWAYS ask the user to run `npx prisma init --db --output ../app/generated/prisma` **manually in their own terminal** (this command is interactive and requires user input for region and project name) -15. ALWAYS wait for user confirmation after they run the interactive `prisma init --db` command before proceeding +14. ALWAYS run `npx prisma init --output ../app/generated/prisma` before editing Prisma files. If you cannot provision cloud resources automatically, ask the user to run `npx create-db` and update `DATABASE_URL` before continuing +15. ALWAYS wait for user confirmation after they run `npx create-db` and share or apply the returned `postgres://...` connection string before proceeding 16. NEVER attempt to run interactive commands yourself - ask the user to do it 17. NEVER use `prisma+postgres://` URLs - ONLY `postgres://` TCP URLs 18. NEVER manually invent or fabricate DATABASE_URL values diff --git a/apps/docs/content/docs.v6/guides/ai-sdk-nextjs.mdx b/apps/docs/content/docs.v6/guides/ai-sdk-nextjs.mdx index cfd2a4adfe..81d34601f7 100644 --- a/apps/docs/content/docs.v6/guides/ai-sdk-nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/ai-sdk-nextjs.mdx @@ -69,21 +69,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Next.js AI SDK Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. - The `output` field specifies where the generated Prisma Client will be stored. +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models: diff --git a/apps/docs/content/docs.v6/guides/astro.mdx b/apps/docs/content/docs.v6/guides/astro.mdx index d010b9902b..277a2416a0 100644 --- a/apps/docs/content/docs.v6/guides/astro.mdx +++ b/apps/docs/content/docs.v6/guides/astro.mdx @@ -73,17 +73,25 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../prisma/generated +npx prisma init --output ../prisma/generated ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Astro Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file for configuring Prisma -- A `.env` file with a `DATABASE_URL` already set +- A `.env` file with a local `DATABASE_URL` already set + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 2.2. Define your Prisma Schema diff --git a/apps/docs/content/docs.v6/guides/authjs-nextjs.mdx b/apps/docs/content/docs.v6/guides/authjs-nextjs.mdx index 7f77c873c9..f62533931b 100644 --- a/apps/docs/content/docs.v6/guides/authjs-nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/authjs-nextjs.mdx @@ -69,21 +69,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Auth.js Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. - A schema configuration that specifies where the Prisma Client will be generated (`../app/generated/prisma`). +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, swap the provider to `prisma-client` and add the runtime `vercel-edge` to the generator: diff --git a/apps/docs/content/docs.v6/guides/betterauth-astro.mdx b/apps/docs/content/docs.v6/guides/betterauth-astro.mdx index 9342dee934..5ed151e962 100644 --- a/apps/docs/content/docs.v6/guides/betterauth-astro.mdx +++ b/apps/docs/content/docs.v6/guides/betterauth-astro.mdx @@ -67,21 +67,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../prisma/generated +npx prisma init --output ../prisma/generated ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Better Auth Astro Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file -- A Prisma Postgres database -- A `.env` file containing the `DATABASE_URL` at the project root +- A `.env` file containing a local `DATABASE_URL` at the project root - A `prisma.config.ts` file for configuring Prisma - An `output` directory for the generated Prisma Client as `prisma/generated` +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Configure Prisma to load environment variables To get access to the variables in the `.env` file, update your `prisma.config.ts` to import `dotenv`: diff --git a/apps/docs/content/docs.v6/guides/betterauth-nextjs.mdx b/apps/docs/content/docs.v6/guides/betterauth-nextjs.mdx index a69685d7a5..524fe42bcb 100644 --- a/apps/docs/content/docs.v6/guides/betterauth-nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/betterauth-nextjs.mdx @@ -73,20 +73,27 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Better Auth Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file -- A Prisma Postgres database -- A `.env` file containing the `DATABASE_URL` at the project root +- A `.env` file containing a local `DATABASE_URL` at the project root - An `output` directory for the generated Prisma Client as `better-auth/generated/prisma` +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Configure Prisma Create a `prisma.config.ts` file in the root of your project with the following content: diff --git a/apps/docs/content/docs.v6/guides/bun.mdx b/apps/docs/content/docs.v6/guides/bun.mdx index d28a2371f6..18f5fde2c1 100644 --- a/apps/docs/content/docs.v6/guides/bun.mdx +++ b/apps/docs/content/docs.v6/guides/bun.mdx @@ -56,7 +56,7 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Initialize Prisma ORM with Prisma Postgres in your project: ```bash -bunx --bun prisma init --db +bunx --bun prisma init ``` :::note @@ -67,32 +67,28 @@ The `--bun` flag is required to ensure Prisma runs with the Bun runtime. Without :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Bun Project" +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. ::: This command creates: - A `prisma/` directory with your `schema.prisma` file -- A new Prisma Postgres database - A `prisma.config.ts` file - A `.env` file with your `DATABASE_URL` -### 2.3. Configure environment variables for direct connection +### 2.3. Create a Prisma Postgres database -We're going to use a direct connection string for connecting to Prisma Postgres. To get your [direct connection string](/v6/postgres/database/direct-connections#how-to-connect-to-prisma-postgres-via-direct-tcp): +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: -1. Navigate to your recently created Prisma Postgres project dashboard (e.g. "My Bun Project") -2. Click the **API Keys** tab in the project's sidebar -3. Click the **Create API key** button -4. Provide a name for the API key and click **Create** -5. Copy the connection string starting with `postgres://` +```bash +npx create-db +``` -Update your `.env` file to replace the `DATABASE_URL` with the new connection string: +Update your `.env` file: ```bash title=".env" -DATABASE_URL="your_database_url_here" # [!code --] -DATABASE_URL="your_direct_connection_string_here" # [!code ++] +DATABASE_URL="postgres://..." ``` ### 2.4. Update your Prisma schema diff --git a/apps/docs/content/docs.v6/guides/clerk-astro.mdx b/apps/docs/content/docs.v6/guides/clerk-astro.mdx index db86762c85..d88e45f62e 100644 --- a/apps/docs/content/docs.v6/guides/clerk-astro.mdx +++ b/apps/docs/content/docs.v6/guides/clerk-astro.mdx @@ -174,18 +174,26 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db +npx prisma init ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for the database like "My Clerk Astro Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file with your Prisma configuration -- A `.env` file with a `DATABASE_URL` already set +- A `.env` file with a local `DATABASE_URL` already set + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 3.2. Define your Prisma Schema diff --git a/apps/docs/content/docs.v6/guides/clerk-nextjs.mdx b/apps/docs/content/docs.v6/guides/clerk-nextjs.mdx index 2cf142ca10..a1c70d449f 100644 --- a/apps/docs/content/docs.v6/guides/clerk-nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/clerk-nextjs.mdx @@ -233,16 +233,24 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for the database like "My Clerk NextJS Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file -- A `DATABASE_URL` in `.env` +- A local `DATABASE_URL` in `.env` + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 3.2. Define your Prisma Schema diff --git a/apps/docs/content/docs.v6/guides/cloudflare-workers.mdx b/apps/docs/content/docs.v6/guides/cloudflare-workers.mdx index 52b14c66fd..16d1cca272 100644 --- a/apps/docs/content/docs.v6/guides/cloudflare-workers.mdx +++ b/apps/docs/content/docs.v6/guides/cloudflare-workers.mdx @@ -55,18 +55,26 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db +npx prisma init ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Cloudflare Workers Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file with your Prisma configuration -- A `.env` file with a `DATABASE_URL` already set +- A `.env` file with a local `DATABASE_URL` already set + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 2.2. Enable Node.js compatibility in Cloudflare Workers diff --git a/apps/docs/content/docs.v6/guides/data-dog.mdx b/apps/docs/content/docs.v6/guides/data-dog.mdx index 75179a0d33..9d118fe65e 100644 --- a/apps/docs/content/docs.v6/guides/data-dog.mdx +++ b/apps/docs/content/docs.v6/guides/data-dog.mdx @@ -71,15 +71,15 @@ Run the following commands to install Prisma and a minimal TypeScript runner: npm install -D prisma tsx ``` -Then initialize Prisma with the `--db` flag to create a [new Prisma Postgres](/v6/postgres) instance: +Then initialize Prisma: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` -:::note +:::info -You will be prompted to name your database and select the closest region. For clarity, choose a memorable name (e.g., `My Datadog Project`). +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. ::: @@ -112,6 +112,12 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst ::: +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define models Now, open `prisma/schema.prisma` and update your generator block and models. Replace the `generator` block with the following, and add a `User` and a `Post` model: diff --git a/apps/docs/content/docs.v6/guides/elysia.mdx b/apps/docs/content/docs.v6/guides/elysia.mdx index 4b7c718501..097bd9944d 100644 --- a/apps/docs/content/docs.v6/guides/elysia.mdx +++ b/apps/docs/content/docs.v6/guides/elysia.mdx @@ -51,18 +51,26 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```bash -bunx --bun prisma init --db --output ../src/generated/prisma +bunx --bun prisma init --output ../src/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Elysia Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file for configuring Prisma -- A `.env` file with a `DATABASE_URL` already set +- A `.env` file with a local `DATABASE_URL` already set + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 2.2. Define your Prisma Schema diff --git a/apps/docs/content/docs.v6/guides/embed-studio-nextjs.mdx b/apps/docs/content/docs.v6/guides/embed-studio-nextjs.mdx index 6cd748d532..e454c99041 100644 --- a/apps/docs/content/docs.v6/guides/embed-studio-nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/embed-studio-nextjs.mdx @@ -89,26 +89,31 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst ### 2.2. Initialize Prisma with Prisma Postgres -Initialize Prisma in your project and create a Prisma Postgres database: +Initialize Prisma in your project: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My \***\*\_\_\*\*** Project" +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. If you choose Prisma Postgres below, create a database in the next step and replace that value with a direct `postgres://...` connection string. ::: -The `prisma init --db` command creates: +The `prisma init` command creates: - A `prisma/` directory with your `schema.prisma` file - A `prisma.config.ts` file for configuring Prisma -- A new Prisma Postgres database - A `.env` file with your `DATABASE_URL` - An output directory at `app/generated/prisma` for the Prisma Client +If you're using Prisma Postgres, create a database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.3. Define your database schema Open `prisma/schema.prisma` and replace the content with: diff --git a/apps/docs/content/docs.v6/guides/github-actions.mdx b/apps/docs/content/docs.v6/guides/github-actions.mdx index 35da8b0801..b436a40148 100644 --- a/apps/docs/content/docs.v6/guides/github-actions.mdx +++ b/apps/docs/content/docs.v6/guides/github-actions.mdx @@ -59,7 +59,7 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` This creates: @@ -68,6 +68,12 @@ This creates: - A `.env` file with `DATABASE_URL` - A generated client in `src/generated/prisma` +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma schema Edit `prisma/schema.prisma` to: diff --git a/apps/docs/content/docs.v6/guides/hono.mdx b/apps/docs/content/docs.v6/guides/hono.mdx index 529747df6f..59dddf1229 100644 --- a/apps/docs/content/docs.v6/guides/hono.mdx +++ b/apps/docs/content/docs.v6/guides/hono.mdx @@ -56,17 +56,25 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Hono Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` with your Prisma configuration -- A `.env` file with a `DATABASE_URL` already set +- A `.env` file with a local `DATABASE_URL` already set + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 2.2. Define your Prisma Schema diff --git a/apps/docs/content/docs.v6/guides/multiple-databases.mdx b/apps/docs/content/docs.v6/guides/multiple-databases.mdx index f4006ee246..3edbfbc713 100644 --- a/apps/docs/content/docs.v6/guides/multiple-databases.mdx +++ b/apps/docs/content/docs.v6/guides/multiple-databases.mdx @@ -162,10 +162,11 @@ Your user database schema is now ready. Repeat the initialization for the post database: ```npm -npx prisma init --db +npx prisma init +npx create-db ``` -After following the prompts, rename the new `prisma` folder to `prisma-post-database`: +Replace the generated `DATABASE_URL` in your `.env` file with the value from `npx create-db`, then rename the new `prisma` folder to `prisma-post-database`: ```bash mv prisma prisma-post-database diff --git a/apps/docs/content/docs.v6/guides/nestjs.mdx b/apps/docs/content/docs.v6/guides/nestjs.mdx index f9fe20dc50..a600e8c102 100644 --- a/apps/docs/content/docs.v6/guides/nestjs.mdx +++ b/apps/docs/content/docs.v6/guides/nestjs.mdx @@ -74,7 +74,7 @@ If you are using a different database provider (PostgreSQL, MySQL, SQL Server), Initialize Prisma in your project: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` This creates a new `prisma` directory with the following contents: @@ -83,6 +83,12 @@ This creates a new `prisma` directory with the following contents: - `prisma.config.ts`: A configuration file for your projects - `.env`: A [dotenv](https://github.com/motdotla/dotenv) file, typically used to store your database credentials in a group of environment variables +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.3. Set the generator output path Specify your output `path` for the generated Prisma client by either passing `--output ../src/generated/prisma` during `prisma init` or directly in your Prisma schema: @@ -112,7 +118,7 @@ datasource db { Now, open up `.env` and you should see a `DATABASE_URL` already specified: ```bash title=".env" -DATABASE_URL="" +DATABASE_URL="postgres://..." ``` :::note diff --git a/apps/docs/content/docs.v6/guides/nextjs.mdx b/apps/docs/content/docs.v6/guides/nextjs.mdx index a3d4953c5b..72d11a00e1 100644 --- a/apps/docs/content/docs.v6/guides/nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/nextjs.mdx @@ -80,22 +80,29 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My \***\*\_\_\*\*** Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma. -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. The `app/generated/prisma` output directory for the generated Prisma Client will be created when you run `prisma generate` or `prisma migrate dev` in a later step. +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models: diff --git a/apps/docs/content/docs.v6/guides/react-router-7.mdx b/apps/docs/content/docs.v6/guides/react-router-7.mdx index 9f87150a01..10d02136d3 100644 --- a/apps/docs/content/docs.v6/guides/react-router-7.mdx +++ b/apps/docs/content/docs.v6/guides/react-router-7.mdx @@ -62,21 +62,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My React Router 7 Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. - An `output` directory for the generated Prisma Client as `app/generated/prisma`. +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models and change the generator to use the `prisma-client` provider: diff --git a/apps/docs/content/docs.v6/guides/shopify.mdx b/apps/docs/content/docs.v6/guides/shopify.mdx index 1cffaedf25..ca867c3836 100644 --- a/apps/docs/content/docs.v6/guides/shopify.mdx +++ b/apps/docs/content/docs.v6/guides/shopify.mdx @@ -148,33 +148,33 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst ::: -Prisma Postgres allows you to create a new database on the fly, you can create a new database at the same time you initialize your project by adding the `--db` flag: +Initialize Prisma in your project: ```npm -npx prisma init --db +npx prisma init ``` -Once you've completed the prompts, it's time to access your new database: +Then create a Prisma Postgres database: + +```npm +npx create-db +``` + +Copy the connection string from the CLI output. It should look similar to this: -1. **Open the [Prisma Console](https://console.prisma.io):** - - Log in and select your newly created database project. -2. **Get your database connection string:** - - Click the **Connect** button. - - Copy the connection string that appears. It should look similar to this: ```text DATABASE_URL="postgresql://user:password@host:5432/database?sslmode=require" ``` -3. **Configure your environment:** - - Create a new `.env` file in the root of your project. - - Paste the `DATABASE_URL` you just copied into this file. -4. **Apply your database schema:** - - Run the following command to create your tables and get your database ready: + +Replace the generated `DATABASE_URL` in your `.env` file with the value from `npx create-db`. + +Apply your database schema: ```npm npx prisma migrate dev --name init ``` - Then generate Prisma Client: +Then generate Prisma Client: ```npm npx prisma generate diff --git a/apps/docs/content/docs.v6/guides/solid-start.mdx b/apps/docs/content/docs.v6/guides/solid-start.mdx index 76a86935d5..01383263c5 100644 --- a/apps/docs/content/docs.v6/guides/solid-start.mdx +++ b/apps/docs/content/docs.v6/guides/solid-start.mdx @@ -83,21 +83,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My SolidStart Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. - An `output` directory for the generated Prisma Client as `src/generated/prisma`. +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models and change the generator to use the `prisma-client` provider: diff --git a/apps/docs/content/docs.v6/guides/sveltekit.mdx b/apps/docs/content/docs.v6/guides/sveltekit.mdx index 4688bc2c86..599353179b 100644 --- a/apps/docs/content/docs.v6/guides/sveltekit.mdx +++ b/apps/docs/content/docs.v6/guides/sveltekit.mdx @@ -73,21 +73,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output src/generated/prisma +npx prisma init --output src/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My SvelteKit Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. - An `output` directory for the generated Prisma Client as `src/generated/prisma`. +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models and change the generator to use the `prisma-client` provider: diff --git a/apps/docs/content/docs.v6/guides/turborepo.mdx b/apps/docs/content/docs.v6/guides/turborepo.mdx index 6842fb5251..2a3ffa6140 100644 --- a/apps/docs/content/docs.v6/guides/turborepo.mdx +++ b/apps/docs/content/docs.v6/guides/turborepo.mdx @@ -100,25 +100,30 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Inside the `database` directory, initialize prisma by running: ```npm tab="npm" -npx prisma init --db --output ../generated/prisma +npx prisma init --output ../generated/prisma ``` ```bash tab="yarn" -yarn prisma init --db --output ../generated/prisma +yarn dlx prisma init --output ../generated/prisma ``` ```bash tab="pnpm" -pnpm prisma init --db --output ../generated/prisma +pnpm dlx prisma init --output ../generated/prisma ``` This will create several files inside `packages/database`: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. - An `output` directory for the generated Prisma Client as `generated/prisma`. +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```bash +npx create-db +``` + In the `packages/database/prisma/schema.prisma` file, add the following models: ```prisma title="packages/database/prisma/schema.prisma" diff --git a/apps/docs/content/docs.v6/guides/use-prisma-in-pnpm-workspaces.mdx b/apps/docs/content/docs.v6/guides/use-prisma-in-pnpm-workspaces.mdx index 6d87d0df61..7016aea6e3 100644 --- a/apps/docs/content/docs.v6/guides/use-prisma-in-pnpm-workspaces.mdx +++ b/apps/docs/content/docs.v6/guides/use-prisma-in-pnpm-workspaces.mdx @@ -107,24 +107,28 @@ pnpm tsc --init Initialize Prisma ORM with an instance of [Prisma Postgres](/v6/postgres) in the `database` package by running the following command: ```bash -pnpm prisma init --db +pnpm dlx prisma init ``` -Enter a name for your project and choose a database region. - :::info -We're going to be using [Prisma Postgres](/v6/postgres/getting-started) in this guide. If you're not using a Prisma Postgres database, you won't need to add the `--db` flag. +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. ::: This command: -- Connects your CLI to your [Prisma Data Platform](https://console.prisma.io) account. If you're not logged in or don't have an account, your browser will open to guide you through creating a new account or signing into your existing one. - Creates a `prisma` directory containing a `schema.prisma` file for your database models. -- Creates a `.env` file with your `DATABASE_URL` (e.g., for Prisma Postgres it should have something similar to `DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=eyJhbGciOiJIUzI..."`). +- Creates a `.env` file with a local `DATABASE_URL`. + + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```bash +npx create-db +``` -Edit the `schema.prisma` file to define a `User` model in your database and specify a [custom `output` directory](/v6/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path) to generate the Prisma Client. This ensures that generated types are resolved correctly: +Edit the `schema.prisma` file to define a `User` model in your database and specify a [custom `output` directory](/orm/reference/prisma-schema-reference#fields-for-prisma-client-provider) to generate the Prisma Client. This ensures that generated types are resolved correctly: ```prisma title="prisma/schema.prisma" generator client { diff --git a/apps/docs/content/docs.v6/orm/overview/databases/postgresql.mdx b/apps/docs/content/docs.v6/orm/overview/databases/postgresql.mdx index 37c31c28ee..80dedfa288 100644 --- a/apps/docs/content/docs.v6/orm/overview/databases/postgresql.mdx +++ b/apps/docs/content/docs.v6/orm/overview/databases/postgresql.mdx @@ -16,7 +16,7 @@ Need a Postgres instance yesterday? With [Prisma Postgres](https://www.prisma.io/postgres?utm_source=docs&utm_campaign=postgresql) you can get a database running on bare-metal in three clicks. Connection pooling, query caching, and automated backups are all included. [Visit the Console](https://console.prisma.io?utm_source=docs&utm_campaign=postgresql) to get started today. -Want any even faster way to get started with Prisma Postgres? Just run `npx prisma init --db` in your terminal. 🚀 +Want an even faster way to get started with Prisma Postgres? Run `npx prisma init`, then `npx create-db` in your terminal. 🚀 ::: diff --git a/apps/docs/content/docs.v6/postgres/database/prisma-studio/embedding-studio.mdx b/apps/docs/content/docs.v6/postgres/database/prisma-studio/embedding-studio.mdx index 030e5edd8a..6fbabf02ab 100644 --- a/apps/docs/content/docs.v6/postgres/database/prisma-studio/embedding-studio.mdx +++ b/apps/docs/content/docs.v6/postgres/database/prisma-studio/embedding-studio.mdx @@ -29,7 +29,7 @@ You can embed Prisma Studio in your own app in various scenarios: - Frontend: A React application - Backend: - A server-side application to expose the `/studio` endpoint (e.g. with Express or Hono) - - A Prisma Postgres instance (you can create one with `npx prisma init --db`) + - A Prisma Postgres instance (you can create one with `npx create-db`) :::note The embeddable version of Prisma Studio will be available for other databases in combination with Prisma ORM soon. diff --git a/apps/docs/content/docs.v6/postgres/getting-started.mdx b/apps/docs/content/docs.v6/postgres/getting-started.mdx index 390c0aa3ac..8968591b31 100644 --- a/apps/docs/content/docs.v6/postgres/getting-started.mdx +++ b/apps/docs/content/docs.v6/postgres/getting-started.mdx @@ -8,13 +8,19 @@ metaDescription: Learn how to quickly set up and start using Prisma Postgres. ## Quickstart -To **bootstrap a new Prisma ORM project with a Prisma Postgres database**, run the following command in your terminal: +To **bootstrap a new Prisma ORM project**, run the following command in your terminal: ```npm -npx prisma init --db +npx prisma init ``` -After running this command, the terminal will guide you with next steps. Follow [this page](/v6/prisma-postgres/from-the-cli) to complete the setup for your first Prisma Postgres project. +Then create a Prisma Postgres database and update your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + +Follow [this page](/v6/prisma-postgres/from-the-cli) to complete the setup for your first Prisma Postgres project. If you need a database quickly for testing, or want to try out Prisma Postgres, you can run the following command to spin up a temporary 24-hour database: diff --git a/apps/docs/content/docs/(index)/index.mdx b/apps/docs/content/docs/(index)/index.mdx index b5b9f86fa9..8bb68a9ddc 100644 --- a/apps/docs/content/docs/(index)/index.mdx +++ b/apps/docs/content/docs/(index)/index.mdx @@ -8,7 +8,7 @@ metaDescription: 'Build data-driven applications with ease using Prisma ORM, add [**Prisma ORM**](/orm) is an open-source ORM that provides fast, type-safe access to Postgres, MySQL, SQLite, and other databases, and runs smoothly across Node.js, Bun, and Deno. ```npm -npx prisma init --db +npx prisma init ``` diff --git a/apps/docs/content/docs/(index)/prisma-orm/quickstart/prisma-postgres.mdx b/apps/docs/content/docs/(index)/prisma-orm/quickstart/prisma-postgres.mdx index b5c6d93a36..c8a7ead748 100644 --- a/apps/docs/content/docs/(index)/prisma-orm/quickstart/prisma-postgres.mdx +++ b/apps/docs/content/docs/(index)/prisma-orm/quickstart/prisma-postgres.mdx @@ -68,7 +68,7 @@ Update `package.json` to enable ESM: } ``` -## 4. Initialize Prisma ORM and create a Prisma Postgres database +## 4. Initialize Prisma ORM You can now invoke the Prisma CLI by prefixing it with `npx`: @@ -79,21 +79,14 @@ npx prisma Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema/overview) file with the following command: ```npm -npx prisma init --db --output ../generated/prisma +npx prisma init --output ../generated/prisma ``` -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database. - -:::tip[Using local Prisma Postgres] - -If you want to use a local Prisma Postgres database instead of a cloud database, you can skip the `--db` flag and start a local Prisma Postgres instance by running `npx prisma dev`. For more details, see the [local Prisma Postgres documentation](/postgres/database/local-development#setting-up-local-development-for-prisma-postgres). - -::: +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. This command does a few things: - Creates a `prisma/` directory with a `schema.prisma` file containing your database connection and schema models -- Creates a new Prisma Postgres database (when using `--db` flag) - Creates a `.env` file in the root directory for environment variables - Creates a `prisma.config.ts` file for Prisma configuration @@ -127,6 +120,12 @@ datasource db { } ``` +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ## 5. Define your data model Open `prisma/schema.prisma` and add the following models: diff --git a/apps/docs/content/docs/(index)/prisma-postgres/from-the-cli.mdx b/apps/docs/content/docs/(index)/prisma-postgres/from-the-cli.mdx index ee9790caa2..7260c7b790 100644 --- a/apps/docs/content/docs/(index)/prisma-postgres/from-the-cli.mdx +++ b/apps/docs/content/docs/(index)/prisma-postgres/from-the-cli.mdx @@ -6,7 +6,7 @@ metaTitle: From the CLI metaDescription: Start building a Prisma application with a Prisma Postgres database from the CLI --- -This page provides a step-by-step guide for Prisma Postgres after setting it up with `prisma init --db`: +This page provides a step-by-step guide for Prisma Postgres after setting it up with `prisma init` and `npx create-db`: 1. Set up a TypeScript app with Prisma ORM 1. Migrate the schema of your database @@ -14,26 +14,26 @@ This page provides a step-by-step guide for Prisma Postgres after setting it up ## Prerequisites -This guide assumes you set up [Prisma Postgres](/postgres) instance with `prisma init --db`: +This guide assumes you initialized Prisma with `prisma init` and created a Prisma Postgres database with `npx create-db`: ```npm -npx prisma@latest init --db +npx prisma@latest init +npx create-db ``` -Once this command has terminated: +Once these commands have terminated: -- You're logged into Prisma Data Platform. -- A new Prisma Postgres instance was created. - The `prisma/` folder was created with an empty `schema.prisma` file. - The `DATABASE_URL` env var was set in a `.env` file. - The `prisma.config.ts` file was created with the default configuration. +- You have a Prisma Postgres connection string to paste into `.env`. ## 1. Organize your project directory :::note -If you ran the `prisma init --db` command inside a folder where you want your project to live, you can skip this step and [proceed to the next section](/prisma-postgres/from-the-cli#2-set-up-your-project). +If you ran the `prisma init` command inside a folder where you want your project to live, you can skip this step and [proceed to the next section](/prisma-postgres/from-the-cli#2-set-up-your-project). ::: @@ -122,7 +122,7 @@ Here's what each package does: ### 2.4. Review the generated prisma.config.ts -The `prisma init --db` command automatically created a `prisma.config.ts` file that looks like this: +The `prisma init` command automatically created a `prisma.config.ts` file that looks like this: ```typescript title="prisma.config.ts" import "dotenv/config"; diff --git a/apps/docs/content/docs/(index)/prisma-postgres/quickstart/prisma-orm.mdx b/apps/docs/content/docs/(index)/prisma-postgres/quickstart/prisma-orm.mdx index 5cf73549a8..9bc81ab10a 100644 --- a/apps/docs/content/docs/(index)/prisma-postgres/quickstart/prisma-orm.mdx +++ b/apps/docs/content/docs/(index)/prisma-postgres/quickstart/prisma-orm.mdx @@ -53,24 +53,23 @@ Update `package.json` to enable ESM: } ``` -## 4. Initialize Prisma ORM and create a Prisma Postgres database +## 4. Initialize Prisma ORM Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema/overview) file with the following command: ```npm -npx prisma init --db --output ../generated/prisma +npx prisma init --output ../generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database. +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, replace that value with a direct `postgres://...` connection string from Prisma Postgres. ::: This command does a few things: - Creates a `prisma/` directory with a `schema.prisma` file containing your database connection and schema models -- Creates a new Prisma Postgres database (when using `--db` flag) - Creates a `.env` file in the root directory for environment variables - Generates the Prisma Client in the `generated/prisma/` directory - Creates a `prisma.config.ts` file for Prisma configuration @@ -105,6 +104,12 @@ datasource db { } ``` +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ## 5. Define your data model Open `prisma/schema.prisma` and add the following models: diff --git a/apps/docs/content/docs/ai/prompts/astro.mdx b/apps/docs/content/docs/ai/prompts/astro.mdx index 76096af93d..e27e70f25e 100644 --- a/apps/docs/content/docs/ai/prompts/astro.mdx +++ b/apps/docs/content/docs/ai/prompts/astro.mdx @@ -82,7 +82,7 @@ export default prisma 5. You MUST wrap all database calls in try-catch blocks 6. You MUST import from `'../generated/prisma/client'` (not `'@prisma/client'`) 7. You MUST use `import.meta.env.DATABASE_URL` in Astro (not `process.env`) -8. You MUST ALWAYS use the full `npx prisma init` command with ALL flags: `npx prisma init --db --output ../src/generated/prisma --generator-provider prisma-client` +8. You MUST use `npx prisma init --output ../src/generated/prisma` before editing the Prisma schema. If you need Prisma Postgres, run `npx create-db` and update `.env` with the returned `postgres://...` value ## CORRECT INSTALLATION @@ -97,7 +97,7 @@ npm install @prisma/extension-accelerate @prisma/client ## CORRECT PRISMA INITIALIZATION ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` ## CORRECT SCHEMA CONFIGURATION diff --git a/apps/docs/content/docs/ai/prompts/nextjs.mdx b/apps/docs/content/docs/ai/prompts/nextjs.mdx index fb742e7f27..ff4fd5b8e8 100644 --- a/apps/docs/content/docs/ai/prompts/nextjs.mdx +++ b/apps/docs/content/docs/ai/prompts/nextjs.mdx @@ -164,7 +164,7 @@ export default prisma 10. You MUST create a test script at `scripts/test-database.ts` to verify setup 11. You MUST NOT include `url` in the datasource block of `schema.prisma` 12. You MUST NOT include `engine` property in `prisma.config.ts` -13. You MUST use `npx prisma init --db --output ../app/generated/prisma` to create a real cloud database +13. You MUST use `npx prisma init --output ../app/generated/prisma` to scaffold Prisma, then `npx create-db` to create a real cloud database 14. You MUST use standard TCP URLs (`postgres://...`) in .env 15. You MUST NOT use `accelerateUrl` or `withAccelerate` @@ -186,37 +186,35 @@ npm install @prisma/adapter-pg @prisma/client dotenv ## CORRECT PRISMA INITIALIZATION -> **FOR AI ASSISTANTS**: This command is **interactive** and requires user input. You **MUST ask the user to run this command manually** in their own terminal, then **wait for them to confirm completion** before proceeding with the next steps. Do NOT attempt to run this command yourself. +> **FOR AI ASSISTANTS**: `npx prisma init` is not interactive. Run it yourself if your environment allows it. If you need a real Prisma Postgres database, either run `npx create-db` or ask the user to run it and update `DATABASE_URL` before you continue. ```bash -# Initialize Prisma AND create a real Prisma Postgres cloud database -npx prisma init --db --output ../app/generated/prisma +# Initialize Prisma and scaffold the Prisma files +npx prisma init --output ../app/generated/prisma + +# Then create a Prisma Postgres database +npx create-db ``` -This command: +This step: -- Authenticates you with Prisma Console (if needed) -- Prompts for **region** and **project name** -- **Creates a cloud Prisma Postgres database** -- Generates: - - `prisma/schema.prisma` (with correct output path) - - `prisma.config.ts` (with dotenv import) - - **`.env` with a `DATABASE_URL`** +- Generates `prisma/schema.prisma` with the correct output path +- Generates `prisma.config.ts` +- Generates `.env` with a local `DATABASE_URL` +- Requires `npx create-db` if you want a real Prisma Postgres database -**IMPORTANT**: Ensure the generated `.env` uses a `postgres://` URL scheme. If it generates `prisma+postgres://`, replace it with the standard TCP connection string available in the Prisma Console. +**IMPORTANT**: After `npx create-db`, replace the generated `DATABASE_URL` in `.env` with the returned `postgres://...` connection string. ```text DATABASE_URL="postgres://..." ``` -**IMPORTANT**: Do NOT use `npx prisma init` without `--db` as this only creates local files without a database. - ## CORRECT PRISMA CONFIG (prisma.config.ts) -When using `npx prisma init --db`, the `prisma.config.ts` is **auto-generated** with the correct configuration: +When using `npx prisma init`, the `prisma.config.ts` is **auto-generated** with the correct configuration: ```typescript -import "dotenv/config"; // ✅ Auto-included by prisma init --db +import "dotenv/config"; // ✅ Auto-included by prisma init import { defineConfig, env } from "prisma/config"; export default defineConfig({ @@ -447,30 +445,26 @@ User should follow these steps (AI should provide these instructions): npm install @prisma/adapter-pg @prisma/client dotenv ``` -2. **Initialize Prisma AND create Prisma Postgres database** (⚠️ USER MUST RUN MANUALLY): +2. **Initialize Prisma, then create Prisma Postgres:** - > **AI ASSISTANT**: Ask the user to run this command in their own terminal. This is interactive and requires user input. Wait for the user to confirm completion before continuing. + > **AI ASSISTANT**: You can run `npx prisma init` yourself. If you should not provision cloud resources automatically, ask the user to run `npx create-db` and update `DATABASE_URL` before continuing. ```npm - npx prisma init --db --output ../app/generated/prisma + npx prisma init --output ../app/generated/prisma + npx create-db ``` - The user should follow the terminal prompts to: - - Authenticate with Prisma Console (if needed) - - Choose a region (e.g., us-east-1) - - Name your project - - Once complete, this creates `prisma/schema.prisma`, `prisma.config.ts`, AND `.env` with the `DATABASE_URL`. + This creates `prisma/schema.prisma`, `prisma.config.ts`, and `.env`, then returns a `postgres://...` connection string for Prisma Postgres. - **User should confirm when done** so the AI can proceed with the next steps. + **If you asked the user to run `npx create-db`, wait for them to share or paste the returned connection string before proceeding.** -3. **Verify `.env` was created** - Ensure `DATABASE_URL` uses `postgres://`. If it uses `prisma+postgres://`, change it to the TCP connection string. +3. **Verify `.env` was created** - Replace the generated `DATABASE_URL` with the `postgres://...` connection string returned by `npx create-db`. ```text DATABASE_URL="postgres://..." ``` - **Do NOT invent or manually change this URL. Use the one from Prisma Console.** + **Do NOT invent this URL. Use the one returned by `npx create-db`.** 4. **Update `prisma/schema.prisma`** - Add the User model (generator and datasource are already configured): @@ -529,7 +523,7 @@ Before generating any code, you MUST verify: 10. Did you add `db:test` and `db:studio` scripts to package.json? If not, STOP and FIX. 11. Did you remove `url` from the datasource block in `schema.prisma`? If not, STOP and FIX. 12. Did you remove `engine` property from `prisma.config.ts`? If not, STOP and FIX. -13. Are you using `npx prisma init --db` (not just `npx prisma init`)? If not, STOP and FIX. +13. Did you run `npx prisma init` with the documented output path? If not, STOP and FIX. 14. Is the DATABASE_URL a TCP URL (`postgres://...`)? If it's a `prisma+postgres://` URL, STOP and FIX. 15. Did Prisma generate the `.env` file? If you invented the URL manually, STOP and FIX. @@ -630,8 +624,8 @@ When asked about Prisma + Next.js implementation, you MUST: 11. ALWAYS use `@prisma/adapter-pg` and `adapter` property 12. NEVER include `url` in the datasource block of schema.prisma 13. NEVER include `engine` property in prisma.config.ts -14. ALWAYS ask the user to run `npx prisma init --db --output ../app/generated/prisma` **manually in their own terminal** (this command is interactive and requires user input for region and project name) -15. ALWAYS wait for user confirmation after they run the interactive `prisma init --db` command before proceeding +14. ALWAYS run `npx prisma init --output ../app/generated/prisma` before editing Prisma files. If you cannot provision cloud resources automatically, ask the user to run `npx create-db` and update `DATABASE_URL` before continuing +15. ALWAYS wait for user confirmation after they run `npx create-db` and share or apply the returned `postgres://...` connection string before proceeding 16. NEVER attempt to run interactive commands yourself - ask the user to do it 17. NEVER use `prisma+postgres://` URLs - ONLY `postgres://` TCP URLs 18. NEVER manually invent or fabricate DATABASE_URL values diff --git a/apps/docs/content/docs/ai/prompts/nuxt.mdx b/apps/docs/content/docs/ai/prompts/nuxt.mdx index f2bbb2c486..57da4d06e3 100644 --- a/apps/docs/content/docs/ai/prompts/nuxt.mdx +++ b/apps/docs/content/docs/ai/prompts/nuxt.mdx @@ -159,7 +159,7 @@ export { prisma } 10. You MUST create a test script at `scripts/test-database.ts` to verify setup 11. You MUST NOT include `url` in the datasource block of `schema.prisma` 12. You MUST NOT include `engine` property in `prisma.config.ts` -13. You MUST use `npx prisma init --db --output ./generated` to create a real cloud database +13. You MUST use `npx prisma init --output ./generated` to scaffold Prisma, then `npx create-db` to create a real cloud database 14. You MUST use standard TCP URLs (`postgres://...`) in .env 15. You MUST NOT use `accelerateUrl` or `withAccelerate` 16. You MUST install `pg` and `@types/pg` as dependencies @@ -182,37 +182,35 @@ npm install -D prisma @types/pg tsx ## CORRECT PRISMA INITIALIZATION -> **FOR AI ASSISTANTS**: This command is **interactive** and requires user input. You **MUST ask the user to run this command manually** in their own terminal, then **wait for them to confirm completion** before proceeding with the next steps. Do NOT attempt to run this command yourself. +> **FOR AI ASSISTANTS**: `npx prisma init` is not interactive. Run it yourself if your environment allows it. If you need a real Prisma Postgres database, either run `npx create-db` or ask the user to run it and update `DATABASE_URL` before you continue. ```bash -# Initialize Prisma AND create a real Prisma Postgres cloud database -npx prisma init --db --output ./generated +# Initialize Prisma and scaffold the Prisma files +npx prisma init --output ./generated + +# Then create a Prisma Postgres database +npx create-db ``` -This command: +This step: -- Authenticates you with Prisma Console (if needed) -- Prompts for **region** and **project name** -- **Creates a cloud Prisma Postgres database** -- Generates: - - `prisma/schema.prisma` (with correct output path) - - `prisma.config.ts` (with dotenv import) - - **`.env` with a `DATABASE_URL`** +- Generates `prisma/schema.prisma` with the correct output path +- Generates `prisma.config.ts` +- Generates `.env` with a local `DATABASE_URL` +- Requires `npx create-db` if you want a real Prisma Postgres database -**IMPORTANT**: Ensure the generated `.env` uses a `postgres://` URL scheme. If it generates `prisma+postgres://`, replace it with the standard TCP connection string available in the Prisma Console. +**IMPORTANT**: After `npx create-db`, replace the generated `DATABASE_URL` in `.env` with the returned `postgres://...` connection string. ```text DATABASE_URL="postgres://..." ``` -**IMPORTANT**: Do NOT use `npx prisma init` without `--db` as this only creates local files without a database. - ## CORRECT PRISMA CONFIG (prisma.config.ts) -When using `npx prisma init --db`, the `prisma.config.ts` is **auto-generated** with the correct configuration: +When using `npx prisma init`, the `prisma.config.ts` is **auto-generated** with the correct configuration: ```typescript -import "dotenv/config"; // ✅ Auto-included by prisma init --db +import "dotenv/config"; // ✅ Auto-included by prisma init import { defineConfig, env } from "prisma/config"; export default defineConfig({ @@ -451,28 +449,24 @@ User should follow these steps (AI should provide these instructions): 3. **Initialize Prisma AND create Prisma Postgres database** (⚠️ USER MUST RUN MANUALLY): - > **AI ASSISTANT**: Ask the user to run this command in their own terminal. This is interactive and requires user input. Wait for the user to confirm completion before continuing. + > **AI ASSISTANT**: You can run `npx prisma init` yourself. If you should not provision cloud resources automatically, ask the user to run `npx create-db` and update `DATABASE_URL` before continuing. ```bash - npx prisma init --db --output ./generated + npx prisma init --output ./generated + npx create-db ``` - The user should follow the terminal prompts to: - - Authenticate with Prisma Console (if needed) - - Choose a region (e.g., us-east-1) - - Name your project - - Once complete, this creates `prisma/schema.prisma`, `prisma.config.ts`, AND `.env` with the `DATABASE_URL`. + This creates `prisma/schema.prisma`, `prisma.config.ts`, and `.env`, then returns a `postgres://...` connection string for Prisma Postgres. - **User should confirm when done** so the AI can proceed with the next steps. + **If you asked the user to run `npx create-db`, wait for them to share or paste the returned connection string before proceeding.** -4. **Verify `.env` was created** — Ensure `DATABASE_URL` uses `postgres://`. If it uses `prisma+postgres://`, change it to the TCP connection string. +4. **Verify `.env` was created** — Replace the generated `DATABASE_URL` with the `postgres://...` connection string returned by `npx create-db`. ```text DATABASE_URL="postgres://..." ``` - **Do NOT invent or manually change this URL. Use the one from Prisma Console.** + **Do NOT invent this URL. Use the one returned by `npx create-db`.** 5. **Update `prisma/schema.prisma`** — Add the User and Post models (generator and datasource are already configured): @@ -546,7 +540,7 @@ Before generating any code, you MUST verify: 12. Did you add `db:test` and `db:studio` scripts to package.json? If not, STOP and FIX. 13. Did you remove `url` from the datasource block in `schema.prisma`? If not, STOP and FIX. 14. Did you remove `engine` property from `prisma.config.ts`? If not, STOP and FIX. -15. Are you using `npx prisma init --db` (not just `npx prisma init`)? If not, STOP and FIX. +15. Did you run `npx prisma init` with the documented output path? If not, STOP and FIX. 16. Is the DATABASE_URL a TCP URL (`postgres://...`)? If it's a `prisma+postgres://` URL, STOP and FIX. 17. Did Prisma generate the `.env` file? If you invented the URL manually, STOP and FIX. 18. Are you using Nuxt auto-imports (`defineEventHandler`, `readBody`, `createError`, `prisma`)? If not, STOP and FIX. @@ -651,8 +645,8 @@ When asked about Prisma + Nuxt implementation, you MUST: 12. ALWAYS use `@prisma/adapter-pg` with `PrismaPg` and `adapter` property 13. NEVER include `url` in the datasource block of schema.prisma 14. NEVER include `engine` property in prisma.config.ts -15. ALWAYS ask the user to run `npx prisma init --db --output ./generated` **manually in their own terminal** (this command is interactive and requires user input for region and project name) -16. ALWAYS wait for user confirmation after they run the interactive `prisma init --db` command before proceeding +15. ALWAYS run `npx prisma init --output ./generated` before editing Prisma files. If you cannot provision cloud resources automatically, ask the user to run `npx create-db` and update `DATABASE_URL` before continuing +16. ALWAYS wait for user confirmation after they run `npx create-db` and share or apply the returned `postgres://...` connection string before proceeding 17. NEVER attempt to run interactive commands yourself - ask the user to do it 18. NEVER use `prisma+postgres://` URLs - ONLY `postgres://` TCP URLs 19. NEVER manually invent or fabricate DATABASE_URL values diff --git a/apps/docs/content/docs/ai/tutorials/typefully-clone.mdx b/apps/docs/content/docs/ai/tutorials/typefully-clone.mdx index 0381a9f790..1207443cc1 100644 --- a/apps/docs/content/docs/ai/tutorials/typefully-clone.mdx +++ b/apps/docs/content/docs/ai/tutorials/typefully-clone.mdx @@ -512,24 +512,20 @@ npm install prisma tsx --save-dev npm install @prisma/adapter-pg @prisma/client dotenv ``` -### Initialize Prisma with a Cloud Database +### Initialize Prisma :::warning[User Action Required] -The following command is **interactive** and requires your input. Run it in your terminal and follow the prompts. +Run the following commands in your terminal. `prisma init` creates the project files, and `create-db` gives you the `postgres://...` connection string you need for Prisma Postgres. ::: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma +npx create-db ``` -This command will: -1. Authenticate you with Prisma Console (if needed) -2. Ask you to choose a **region** (pick one close to you) -3. Ask for a **project name** (e.g., "TweetSmith") -4. Create a cloud Prisma Postgres database -5. Generate `prisma/schema.prisma`, `prisma.config.ts`, and `.env` with your `DATABASE_URL` +Replace the generated `DATABASE_URL` in `.env` with the `postgres://...` connection string from `npx create-db`. :::info[Important: Check Your DATABASE_URL] @@ -539,7 +535,7 @@ Ensure your `.env` file uses a standard PostgreSQL URL format: DATABASE_URL="postgres://..." ``` -If it shows `prisma+postgres://...`, get the TCP connection string from the [Prisma Console](https://console.prisma.io). +If it still shows `prisma+postgres://...`, replace it with the `postgres://...` connection string from `npx create-db`. ::: @@ -950,4 +946,3 @@ Here are some ideas to extend your app: - [UploadThing Documentation](https://docs.uploadthing.com) - [Tailwind CSS Documentation](https://tailwindcss.com/docs) - [Lucide Icons](https://lucide.dev/icons) - diff --git a/apps/docs/content/docs/guides/authentication/authjs/nextjs.mdx b/apps/docs/content/docs/guides/authentication/authjs/nextjs.mdx index 9c343779c0..0695d41a97 100644 --- a/apps/docs/content/docs/guides/authentication/authjs/nextjs.mdx +++ b/apps/docs/content/docs/guides/authentication/authjs/nextjs.mdx @@ -69,21 +69,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Auth.js Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. - A schema configuration that specifies where the Prisma Client will be generated (`../app/generated/prisma`). +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, swap the provider to `prisma-client` and add the runtime `vercel-edge` to the generator: diff --git a/apps/docs/content/docs/guides/authentication/better-auth/astro.mdx b/apps/docs/content/docs/guides/authentication/better-auth/astro.mdx index 4e2c787997..ff47d677b6 100644 --- a/apps/docs/content/docs/guides/authentication/better-auth/astro.mdx +++ b/apps/docs/content/docs/guides/authentication/better-auth/astro.mdx @@ -67,21 +67,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../prisma/generated +npx prisma init --output ../prisma/generated ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Better Auth Astro Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file -- A Prisma Postgres database -- A `.env` file containing the `DATABASE_URL` at the project root +- A `.env` file containing a local `DATABASE_URL` at the project root - A `prisma.config.ts` file for configuring Prisma - An `output` directory for the generated Prisma Client as `prisma/generated` +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Configure Prisma to load environment variables To get access to the variables in the `.env` file, update your `prisma.config.ts` to import `dotenv`: diff --git a/apps/docs/content/docs/guides/authentication/better-auth/nextjs.mdx b/apps/docs/content/docs/guides/authentication/better-auth/nextjs.mdx index 6656649a7d..e6e3d8963a 100644 --- a/apps/docs/content/docs/guides/authentication/better-auth/nextjs.mdx +++ b/apps/docs/content/docs/guides/authentication/better-auth/nextjs.mdx @@ -73,20 +73,27 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Better Auth Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file -- A Prisma Postgres database -- A `.env` file containing the `DATABASE_URL` at the project root +- A `.env` file containing a local `DATABASE_URL` at the project root - An `output` directory for the generated Prisma Client as `better-auth/generated/prisma` +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Configure Prisma Create a `prisma.config.ts` file in the root of your project with the following content: diff --git a/apps/docs/content/docs/guides/authentication/clerk/astro.mdx b/apps/docs/content/docs/guides/authentication/clerk/astro.mdx index 611620126d..3671c10bef 100644 --- a/apps/docs/content/docs/guides/authentication/clerk/astro.mdx +++ b/apps/docs/content/docs/guides/authentication/clerk/astro.mdx @@ -174,18 +174,26 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db +npx prisma init ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for the database like "My Clerk Astro Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file with your Prisma configuration -- A `.env` file with a `DATABASE_URL` already set +- A `.env` file with a local `DATABASE_URL` already set + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 3.2. Define your Prisma Schema diff --git a/apps/docs/content/docs/guides/authentication/clerk/nextjs.mdx b/apps/docs/content/docs/guides/authentication/clerk/nextjs.mdx index 0df351064a..6217e930f4 100644 --- a/apps/docs/content/docs/guides/authentication/clerk/nextjs.mdx +++ b/apps/docs/content/docs/guides/authentication/clerk/nextjs.mdx @@ -235,16 +235,24 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for the database like "My Clerk NextJS Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file -- A `DATABASE_URL` in `.env` +- A local `DATABASE_URL` in `.env` + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 3.2. Define your Prisma Schema diff --git a/apps/docs/content/docs/guides/database/multiple-databases.mdx b/apps/docs/content/docs/guides/database/multiple-databases.mdx index aa992e0297..655320ffee 100644 --- a/apps/docs/content/docs/guides/database/multiple-databases.mdx +++ b/apps/docs/content/docs/guides/database/multiple-databases.mdx @@ -162,10 +162,11 @@ Your user database schema is now ready. Repeat the initialization for the post database: ```npm -npx prisma init --db +npx prisma init +npx create-db ``` -After following the prompts, rename the new `prisma` folder to `prisma-post-database`: +Replace the generated `DATABASE_URL` in your `.env` file with the value from `npx create-db`, then rename the new `prisma` folder to `prisma-post-database`: ```bash mv prisma prisma-post-database diff --git a/apps/docs/content/docs/guides/deployment/bun-workspaces.mdx b/apps/docs/content/docs/guides/deployment/bun-workspaces.mdx index dce91fa2a8..948f57237b 100644 --- a/apps/docs/content/docs/guides/deployment/bun-workspaces.mdx +++ b/apps/docs/content/docs/guides/deployment/bun-workspaces.mdx @@ -73,23 +73,27 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Initialize Prisma ORM with an instance of [Prisma Postgres](/postgres) in the `database` package by running the following command: ```bash -bunx prisma init --db +bunx --bun prisma init ``` -Enter a name for your project and choose a database region. - :::info -We're going to be using [Prisma Postgres](/postgres) in this guide. If you're not using a Prisma Postgres database, you won't need to add the `--db` flag. +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. ::: This command: -- Connects your CLI to your [Prisma Data Platform](https://console.prisma.io) account. If you're not logged in or don't have an account, your browser will open to guide you through creating a new account or signing into your existing one. - Creates a `prisma` directory containing a `schema.prisma` file for your database models. -- Creates a `prisma.config.ts` file (which uses `process.env["DATABASE_URL"]` and expects `dotenv`). -- Creates a `.env` file with your `DATABASE_URL` (e.g., for Prisma Postgres it should have something similar to `DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=eyJhbGciOiJIUzI..."`). +- Creates a `prisma.config.ts` file for configuring Prisma. +- Creates a `.env` file with a local `DATABASE_URL`. + + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```bash +npx create-db +``` Edit the `schema.prisma` file to add a `User` model. The default generator already sets `output = "../generated/prisma"`: diff --git a/apps/docs/content/docs/guides/deployment/cloudflare-workers.mdx b/apps/docs/content/docs/guides/deployment/cloudflare-workers.mdx index a0a9a258ff..a386f5a8d6 100644 --- a/apps/docs/content/docs/guides/deployment/cloudflare-workers.mdx +++ b/apps/docs/content/docs/guides/deployment/cloudflare-workers.mdx @@ -55,18 +55,26 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db +npx prisma init ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Cloudflare Workers Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file with your Prisma configuration -- A `.env` file with a `DATABASE_URL` already set +- A `.env` file with a local `DATABASE_URL` already set + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 2.2. Enable Node.js compatibility in Cloudflare Workers diff --git a/apps/docs/content/docs/guides/deployment/pnpm-workspaces.mdx b/apps/docs/content/docs/guides/deployment/pnpm-workspaces.mdx index 2bf078aaad..9e3698501e 100644 --- a/apps/docs/content/docs/guides/deployment/pnpm-workspaces.mdx +++ b/apps/docs/content/docs/guides/deployment/pnpm-workspaces.mdx @@ -107,22 +107,26 @@ pnpm tsc --init Initialize Prisma ORM with an instance of [Prisma Postgres](/postgres) in the `database` package by running the following command: ```bash -pnpm prisma init --db +pnpm dlx prisma init ``` -Enter a name for your project and choose a database region. - :::info -We're going to be using [Prisma Postgres](/postgres) in this guide. If you're not using a Prisma Postgres database, you won't need to add the `--db` flag. +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. ::: This command: -- Connects your CLI to your [Prisma Data Platform](https://console.prisma.io) account. If you're not logged in or don't have an account, your browser will open to guide you through creating a new account or signing into your existing one. - Creates a `prisma` directory containing a `schema.prisma` file for your database models. -- Creates a `.env` file with your `DATABASE_URL` (e.g., for Prisma Postgres it should have something similar to `DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=eyJhbGciOiJIUzI..."`). +- Creates a `.env` file with a local `DATABASE_URL`. + + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```bash +npx create-db +``` Edit the `schema.prisma` file to define a `User` model in your database and specify a [custom `output` directory](/orm/reference/prisma-schema-reference#fields-for-prisma-client-provider) to generate the Prisma Client. This ensures that generated types are resolved correctly: diff --git a/apps/docs/content/docs/guides/deployment/turborepo.mdx b/apps/docs/content/docs/guides/deployment/turborepo.mdx index 1bbe8216b0..a0181517ac 100644 --- a/apps/docs/content/docs/guides/deployment/turborepo.mdx +++ b/apps/docs/content/docs/guides/deployment/turborepo.mdx @@ -82,17 +82,20 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Inside the `database` directory, initialize Prisma by running: ```npm -npx prisma init --db +npx prisma init ``` -You'll be prompted to authenticate in Prisma Console, choose a project name, and pick a region for your Prisma Postgres database. - This will create several files inside `packages/database`: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma. -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` in the `packages/database` directory. +- A `.env` file containing a local `DATABASE_URL` in the `packages/database` directory. + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```bash +npx create-db +``` In the `packages/database/prisma/schema.prisma` file, add the following models: diff --git a/apps/docs/content/docs/guides/frameworks/astro.mdx b/apps/docs/content/docs/guides/frameworks/astro.mdx index f71b78e3f1..855a803f1a 100644 --- a/apps/docs/content/docs/guides/frameworks/astro.mdx +++ b/apps/docs/content/docs/guides/frameworks/astro.mdx @@ -64,17 +64,25 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../prisma/generated +npx prisma init --output ../prisma/generated ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Astro Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file for configuring Prisma -- A `.env` file with a `DATABASE_URL` already set +- A `.env` file with a local `DATABASE_URL` already set + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 2.2. Define your Prisma Schema diff --git a/apps/docs/content/docs/guides/frameworks/elysia.mdx b/apps/docs/content/docs/guides/frameworks/elysia.mdx index c8540e2226..214c2b2d3a 100644 --- a/apps/docs/content/docs/guides/frameworks/elysia.mdx +++ b/apps/docs/content/docs/guides/frameworks/elysia.mdx @@ -51,18 +51,26 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```bash -bunx --bun prisma init --db --output ../src/generated/prisma +bunx --bun prisma init --output ../src/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Elysia Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file for configuring Prisma -- A `.env` file with a `DATABASE_URL` already set +- A `.env` file with a local `DATABASE_URL` already set + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 2.2. Define your Prisma Schema diff --git a/apps/docs/content/docs/guides/frameworks/hono.mdx b/apps/docs/content/docs/guides/frameworks/hono.mdx index 43073be498..109a55ef60 100644 --- a/apps/docs/content/docs/guides/frameworks/hono.mdx +++ b/apps/docs/content/docs/guides/frameworks/hono.mdx @@ -56,17 +56,25 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Hono Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` with your Prisma configuration -- A `.env` file with a `DATABASE_URL` already set +- A `.env` file with a local `DATABASE_URL` already set + +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` ### 2.2. Define your Prisma Schema diff --git a/apps/docs/content/docs/guides/frameworks/nestjs.mdx b/apps/docs/content/docs/guides/frameworks/nestjs.mdx index 126d0948e8..f1cfbd3d75 100644 --- a/apps/docs/content/docs/guides/frameworks/nestjs.mdx +++ b/apps/docs/content/docs/guides/frameworks/nestjs.mdx @@ -74,7 +74,7 @@ If you are using a different database provider (MySQL, SQL Server), install the Initialize Prisma in your project: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` This creates a new `prisma` directory with the following contents: @@ -83,6 +83,12 @@ This creates a new `prisma` directory with the following contents: - `prisma.config.ts`: A configuration file for your projects - `.env`: A [dotenv](https://github.com/motdotla/dotenv) file, typically used to store your database credentials in a group of environment variables +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.3. Set the generator output path Specify your output `path` for the generated Prisma client by either passing `--output ../src/generated/prisma` during `prisma init` or directly in your Prisma schema: @@ -112,7 +118,7 @@ datasource db { Now, open up `.env` and you should see a `DATABASE_URL` already specified: ```text title=".env" -DATABASE_URL="" +DATABASE_URL="postgres://..." ``` :::note diff --git a/apps/docs/content/docs/guides/frameworks/nextjs.mdx b/apps/docs/content/docs/guides/frameworks/nextjs.mdx index 9dbc79e877..9e8e551c68 100644 --- a/apps/docs/content/docs/guides/frameworks/nextjs.mdx +++ b/apps/docs/content/docs/guides/frameworks/nextjs.mdx @@ -72,22 +72,29 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My \***\*\_\_\*\*** Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma. -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. The `app/generated/prisma` output directory for the generated Prisma Client will be created when you run `prisma generate` or `prisma migrate dev` in a later step. +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models: diff --git a/apps/docs/content/docs/guides/frameworks/react-router-7.mdx b/apps/docs/content/docs/guides/frameworks/react-router-7.mdx index 8c4eb8e6e0..8bc7f56270 100644 --- a/apps/docs/content/docs/guides/frameworks/react-router-7.mdx +++ b/apps/docs/content/docs/guides/frameworks/react-router-7.mdx @@ -62,21 +62,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My React Router 7 Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. - An `output` directory for the generated Prisma Client as `app/generated/prisma`. +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models and change the generator to use the `prisma-client` provider: diff --git a/apps/docs/content/docs/guides/frameworks/solid-start.mdx b/apps/docs/content/docs/guides/frameworks/solid-start.mdx index 7cae2215d9..5d5a49ed91 100644 --- a/apps/docs/content/docs/guides/frameworks/solid-start.mdx +++ b/apps/docs/content/docs/guides/frameworks/solid-start.mdx @@ -83,21 +83,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My SolidStart Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. - An `output` directory for the generated Prisma Client as `src/generated/prisma`. +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models and change the generator to use the `prisma-client` provider: diff --git a/apps/docs/content/docs/guides/frameworks/sveltekit.mdx b/apps/docs/content/docs/guides/frameworks/sveltekit.mdx index 8f988cc7eb..4ed497703e 100644 --- a/apps/docs/content/docs/guides/frameworks/sveltekit.mdx +++ b/apps/docs/content/docs/guides/frameworks/sveltekit.mdx @@ -73,21 +73,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output src/generated/prisma +npx prisma init --output src/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My SvelteKit Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. - An `output` directory for the generated Prisma Client as `src/generated/prisma`. +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models and change the generator to use the `prisma-client` provider: diff --git a/apps/docs/content/docs/guides/integrations/ai-sdk.mdx b/apps/docs/content/docs/guides/integrations/ai-sdk.mdx index dc23d4c59b..3bd3af5184 100644 --- a/apps/docs/content/docs/guides/integrations/ai-sdk.mdx +++ b/apps/docs/content/docs/guides/integrations/ai-sdk.mdx @@ -69,21 +69,28 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Next.js AI SDK Project" + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A Prisma Postgres database. -- A `.env` file containing the `DATABASE_URL` at the project root. +- A `.env` file containing a local `DATABASE_URL` at the project root. - The `output` field specifies where the generated Prisma Client will be stored. +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models: diff --git a/apps/docs/content/docs/guides/integrations/datadog.mdx b/apps/docs/content/docs/guides/integrations/datadog.mdx index 3a8b8c4ea7..ac26131e60 100644 --- a/apps/docs/content/docs/guides/integrations/datadog.mdx +++ b/apps/docs/content/docs/guides/integrations/datadog.mdx @@ -71,15 +71,15 @@ Run the following commands to install Prisma and a minimal TypeScript runner: npm install -D prisma tsx ``` -Then initialize Prisma with the `--db` flag to create a [new Prisma Postgres](/postgres) instance: +Then initialize Prisma: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` -:::note +:::info -You will be prompted to name your database and select the closest region. For clarity, choose a memorable name (e.g., `My Datadog Project`). +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. ::: @@ -112,6 +112,12 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst ::: +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define models Now, open `prisma/schema.prisma` and update your generator block and models. Replace the `generator` block with the following, and add a `User` and a `Post` model: diff --git a/apps/docs/content/docs/guides/integrations/embed-studio.mdx b/apps/docs/content/docs/guides/integrations/embed-studio.mdx index 58f4a460fc..dc91bef7ba 100644 --- a/apps/docs/content/docs/guides/integrations/embed-studio.mdx +++ b/apps/docs/content/docs/guides/integrations/embed-studio.mdx @@ -102,12 +102,12 @@ For more information, see [Database drivers](/orm/core-concepts/supported-databa ### 2.2. Initialize Prisma with Prisma Postgres -Initialize Prisma in your project and create a Prisma Postgres database: +Initialize Prisma in your project: ### Prisma Postgres (PostgreSQL) ```npm -npx prisma init --db --output ../app/generated/prisma +npx prisma init --output ../app/generated/prisma ``` ### SQLite @@ -124,7 +124,7 @@ npx prisma init --datasource-provider mysql --output ../app/generated/prisma :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My \***\*\_\_\*\*** Project" +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. If you choose Prisma Postgres below, create a database in the next step and replace that value with a direct `postgres://...` connection string. ::: @@ -132,10 +132,15 @@ The `prisma init` command creates: - A `prisma/` directory with your `schema.prisma` file - A `prisma.config.ts` file for configuring Prisma -- A new Prisma Postgres database or local SQLite database file - A `.env` file with your `DATABASE_URL` - An output directory at `app/generated/prisma` for the Prisma Client +If you're using Prisma Postgres, create a database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.3. Define your database schema Open `prisma/schema.prisma` and replace the content with: diff --git a/apps/docs/content/docs/guides/integrations/github-actions.mdx b/apps/docs/content/docs/guides/integrations/github-actions.mdx index 4f7187ace5..89da518edf 100644 --- a/apps/docs/content/docs/guides/integrations/github-actions.mdx +++ b/apps/docs/content/docs/guides/integrations/github-actions.mdx @@ -59,7 +59,7 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma: ```npm -npx prisma init --db --output ../src/generated/prisma +npx prisma init --output ../src/generated/prisma ``` This creates: @@ -68,6 +68,12 @@ This creates: - A `.env` file with `DATABASE_URL` - A generated client in `src/generated/prisma` +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma schema Edit `prisma/schema.prisma` to: diff --git a/apps/docs/content/docs/guides/integrations/shopify.mdx b/apps/docs/content/docs/guides/integrations/shopify.mdx index 9dd125c974..c1d614679c 100644 --- a/apps/docs/content/docs/guides/integrations/shopify.mdx +++ b/apps/docs/content/docs/guides/integrations/shopify.mdx @@ -148,33 +148,33 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst ::: -Prisma Postgres allows you to create a new database on the fly, you can create a new database at the same time you initialize your project by adding the `--db` flag: +Initialize Prisma in your project: ```npm -npx prisma init --db +npx prisma init ``` -Once you've completed the prompts, it's time to access your new database: +Then create a Prisma Postgres database: + +```npm +npx create-db +``` + +Copy the connection string from the CLI output. It should look similar to this: -1. **Open the [Prisma Console](https://console.prisma.io):** - - Log in and select your newly created database project. -2. **Get your database connection string:** - - Click the **Connect** button. - - Copy the connection string that appears. It should look similar to this: ```text DATABASE_URL="postgresql://user:password@host:5432/database?sslmode=require" ``` -3. **Configure your environment:** - - Create a new `.env` file in the root of your project. - - Paste the `DATABASE_URL` you just copied into this file. -4. **Apply your database schema:** - - Run the following command to create your tables and get your database ready: + +Replace the generated `DATABASE_URL` in your `.env` file with the value from `npx create-db`. + +Apply your database schema: ```npm npx prisma migrate dev --name init ``` - Then generate Prisma Client: +Then generate Prisma Client: ```npm npx prisma generate diff --git a/apps/docs/content/docs/guides/making-guides.mdx b/apps/docs/content/docs/guides/making-guides.mdx index c09815febc..21d0690c5e 100644 --- a/apps/docs/content/docs/guides/making-guides.mdx +++ b/apps/docs/content/docs/guides/making-guides.mdx @@ -309,11 +309,13 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --db --output ../generated/prisma +npx prisma init --output ../generated/prisma ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database. + +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. + ::: This will create: @@ -323,6 +325,12 @@ This will create: - A `.env` file containing the `DATABASE_URL` - A `prisma.config.ts` file for configuration +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: + +```npm +npx create-db +``` + ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add your models: diff --git a/apps/docs/content/docs/guides/runtimes/bun.mdx b/apps/docs/content/docs/guides/runtimes/bun.mdx index 5cc85c8572..52a1c396fa 100644 --- a/apps/docs/content/docs/guides/runtimes/bun.mdx +++ b/apps/docs/content/docs/guides/runtimes/bun.mdx @@ -58,7 +58,7 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Initialize Prisma ORM with Prisma Postgres in your project: ```bash -bunx --bun prisma init --db +bunx --bun prisma init ``` :::note @@ -69,32 +69,28 @@ The `--bun` flag is required to ensure Prisma runs with the Bun runtime. Without :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Bun Project" +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. ::: This command creates: - A `prisma/` directory with your `schema.prisma` file -- A new Prisma Postgres database - A `prisma.config.ts` file - A `.env` file with your `DATABASE_URL` -### 2.3. Configure environment variables for direct connection +### 2.3. Create a Prisma Postgres database -We're going to use a direct connection string for connecting to Prisma Postgres. To get it, follow [Connecting to your database](/postgres/database/connecting-to-your-database): +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: -1. Navigate to your recently created Prisma Postgres project dashboard (e.g. "My Bun Project") -2. Click the **Connection Strings** tab in the project's sidebar -3. Click the **Create connection string** button -4. Provide a name for the connection string and click **Create** -5. Copy the connection string starting with `postgres://` +```bash +npx create-db +``` -Update your `.env` file to replace the `DATABASE_URL` with the new connection string: +Update your `.env` file: ```bash title=".env" -DATABASE_URL="your_database_url_here" # [!code --] -DATABASE_URL="your_direct_connection_string_here" # [!code ++] +DATABASE_URL="postgres://..." ``` ### 2.4. Update your Prisma schema diff --git a/apps/docs/content/docs/guides/runtimes/deno.mdx b/apps/docs/content/docs/guides/runtimes/deno.mdx index f9410ccf7f..8f992db508 100644 --- a/apps/docs/content/docs/guides/runtimes/deno.mdx +++ b/apps/docs/content/docs/guides/runtimes/deno.mdx @@ -75,19 +75,18 @@ The `nodeModulesDir: "auto"` setting allows Deno to automatically manage a `node Initialize Prisma ORM with Prisma Postgres in your project: ```bash -deno run -A npm:prisma init --db +deno run -A npm:prisma init ``` :::info -You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Deno Project". +`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. ::: This command creates: - A `prisma/` directory with your `schema.prisma` file -- A new Prisma Postgres database - A `prisma.config.ts` file - A `.env` file with your `DATABASE_URL` @@ -110,21 +109,18 @@ export default defineConfig({ }); ``` -### 2.3. Configure environment variables for direct connection +### 2.3. Create a Prisma Postgres database -We're going to use a direct connection string for connecting to Prisma Postgres. To get it, follow [Connecting to your database](/postgres/database/connecting-to-your-database): +Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: -1. Navigate to your recently created Prisma Postgres project dashboard (e.g. "My Deno Project") -2. Click the **Connection Strings** tab in the project's sidebar -3. Click the **Create connection string** button -4. Provide a name for the connection string and click **Create** -5. Copy the connection string starting with `postgres://` +```bash +npx create-db +``` -Update your `.env` file to replace the `DATABASE_URL` with the new connection string: +Update your `.env` file: ```bash title=".env" -DATABASE_URL="your_database_url_here" # [!code --] -DATABASE_URL="your_direct_connection_string_here" # [!code ++] +DATABASE_URL="postgres://..." ``` ### 2.4. Update your Prisma schema From 51dc4ce8908a0b2d6d3dc987947a97ed55679563 Mon Sep 17 00:00:00 2001 From: Aman Varshney Date: Tue, 24 Mar 2026 18:20:24 +0530 Subject: [PATCH 2/2] revert: drop v6 docs changes --- apps/docs/content/docs.v6/(index)/index.mdx | 2 +- .../prisma-orm/quickstart/prisma-postgres.mdx | 11 +-- .../(index)/prisma-postgres/from-the-cli.mdx | 70 ++++++++++++++++--- .../prisma-postgres/quickstart/prisma-orm.mdx | 13 ++-- .../docs/content/docs.v6/ai/prompts/astro.mdx | 4 +- .../content/docs.v6/ai/prompts/nextjs.mdx | 58 ++++++++------- .../content/docs.v6/guides/ai-sdk-nextjs.mdx | 15 ++-- apps/docs/content/docs.v6/guides/astro.mdx | 14 +--- .../content/docs.v6/guides/authjs-nextjs.mdx | 15 ++-- .../docs.v6/guides/betterauth-astro.mdx | 15 ++-- .../docs.v6/guides/betterauth-nextjs.mdx | 15 ++-- apps/docs/content/docs.v6/guides/bun.mdx | 22 +++--- .../content/docs.v6/guides/clerk-astro.mdx | 14 +--- .../content/docs.v6/guides/clerk-nextjs.mdx | 14 +--- .../docs.v6/guides/cloudflare-workers.mdx | 14 +--- apps/docs/content/docs.v6/guides/data-dog.mdx | 14 ++-- apps/docs/content/docs.v6/guides/elysia.mdx | 14 +--- .../docs.v6/guides/embed-studio-nextjs.mdx | 15 ++-- .../content/docs.v6/guides/github-actions.mdx | 8 +-- apps/docs/content/docs.v6/guides/hono.mdx | 14 +--- .../docs.v6/guides/multiple-databases.mdx | 5 +- apps/docs/content/docs.v6/guides/nestjs.mdx | 10 +-- apps/docs/content/docs.v6/guides/nextjs.mdx | 15 ++-- .../content/docs.v6/guides/react-router-7.mdx | 15 ++-- apps/docs/content/docs.v6/guides/shopify.mdx | 28 ++++---- .../content/docs.v6/guides/solid-start.mdx | 15 ++-- .../docs/content/docs.v6/guides/sveltekit.mdx | 15 ++-- .../docs/content/docs.v6/guides/turborepo.mdx | 15 ++-- .../guides/use-prisma-in-pnpm-workspaces.mdx | 18 ++--- .../orm/overview/databases/postgresql.mdx | 2 +- .../prisma-studio/embedding-studio.mdx | 2 +- .../docs.v6/postgres/getting-started.mdx | 12 +--- 32 files changed, 211 insertions(+), 302 deletions(-) diff --git a/apps/docs/content/docs.v6/(index)/index.mdx b/apps/docs/content/docs.v6/(index)/index.mdx index 1c3650d6d4..42479025ad 100644 --- a/apps/docs/content/docs.v6/(index)/index.mdx +++ b/apps/docs/content/docs.v6/(index)/index.mdx @@ -11,7 +11,7 @@ metaDescription: 'Build data-driven applications with ease using Prisma ORM, add [**Prisma ORM**](/v6/orm/overview/introduction/what-is-prisma) is an open-source ORM that provides fast, type-safe access to Postgres, MySQL, SQLite, and more databases. ```npm -npx prisma init +npx prisma init --db ``` ## Prisma Postgres diff --git a/apps/docs/content/docs.v6/(index)/prisma-orm/quickstart/prisma-postgres.mdx b/apps/docs/content/docs.v6/(index)/prisma-orm/quickstart/prisma-postgres.mdx index 1f9df35aa6..d7009d7758 100644 --- a/apps/docs/content/docs.v6/(index)/prisma-orm/quickstart/prisma-postgres.mdx +++ b/apps/docs/content/docs.v6/(index)/prisma-orm/quickstart/prisma-postgres.mdx @@ -69,18 +69,19 @@ npx prisma Next, set up your Prisma ORM project by creating your [Prisma Schema](/v6/orm/prisma-schema/overview) file with the following command: ```npm -npx prisma init --output ../generated/prisma +npx prisma init --db --output ../generated/prisma ``` :::info -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database. ::: This command does a few things: - Creates a `prisma/` directory with a `schema.prisma` file containing your database connection and schema models +- Creates a new Prisma Postgres database (when using `--db` flag) - Creates a `.env` file in the root directory for environment variables - Creates a `prisma.config.ts` file for Prisma configuration @@ -114,12 +115,6 @@ datasource db { } ``` -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ## 5. Define your data model Open `prisma/schema.prisma` and add the following models: diff --git a/apps/docs/content/docs.v6/(index)/prisma-postgres/from-the-cli.mdx b/apps/docs/content/docs.v6/(index)/prisma-postgres/from-the-cli.mdx index d1462ffafc..d12d9d8a13 100644 --- a/apps/docs/content/docs.v6/(index)/prisma-postgres/from-the-cli.mdx +++ b/apps/docs/content/docs.v6/(index)/prisma-postgres/from-the-cli.mdx @@ -6,7 +6,7 @@ metaTitle: From the CLI metaDescription: Start building a Prisma application with a Prisma Postgres database from the CLI --- -This page provides a step-by-step guide for Prisma Postgres after setting it up with `prisma init` and `npx create-db`: +This page provides a step-by-step guide for Prisma Postgres after setting it up with `prisma init --db`: 1. Set up a TypeScript app with Prisma ORM 1. Migrate the schema of your database @@ -14,27 +14,79 @@ This page provides a step-by-step guide for Prisma Postgres after setting it up ## Prerequisites -This guide assumes you initialized Prisma with `prisma init` and created a Prisma Postgres database with `npx create-db`: +This guide assumes you set up [Prisma Postgres](/v6/postgres) instance with `prisma init --db`: ```npm -npx prisma@latest init -npx create-db +npx prisma@latest init --db ``` -Replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from `npx create-db` before continuing. +```text no-copy wrap +✓ Select an authentication method Google +Authenticating to Prisma Platform via browser. -Once these commands terminated: +Visit the following URL in your browser to authenticate: +https://console.prisma.io/auth/cli?state=eyJjb6ll... +Successfully authenticated as jon@doe.com. +Let's set up your Prisma Postgres database! +✓ Select your region: ap-southeast-1 - Asia Pacific (Singapore) +✓ Enter a project name: My Prisma Project +✓ Success! Your Prisma Postgres database is ready ✅ + +We found an existing schema.prisma file in your current project directory. + +--- Database URL --- + +Connect Prisma ORM to your Prisma Postgres database with this URL: + +--- Next steps --- + +Go to https://pris.ly/ppg-init for detailed instructions. + +1. Install the Postgres adapter +npm install @prisma/adapter-pg + +...and add it to your Prisma Client instance: + +import { PrismaClient } from "./generated/prisma/client"; +import { PrismaPg } from "@prisma/adapter-pg"; + +const connectionString = `${process.env.DATABASE_URL}`; + +const adapter = new PrismaPg({ connectionString }); +const prisma = new PrismaClient({ adapter }); + +2. Apply migrations +Run the following command to create and apply a migration: +npx prisma migrate dev + +3. Manage your data +View and edit your data locally by running this command: +npx prisma studio + +...or online in Console: +https://console.prisma.io/$path + +4. Send queries from your app +If you already have an existing app with Prisma ORM, you can now run it and it will send queries against your newly created Prisma Postgres instance. + +5. Learn more +For more info, visit the Prisma Postgres docs: https://pris.ly/ppg-docs +``` + +Once this command terminated: + +- You're logged into Prisma Data Platform. +- A new Prisma Postgres instance was created. - The `prisma/` folder was created with an empty `schema.prisma` file. - The `DATABASE_URL` env var was set in a `.env` file. - The `prisma.config.ts` file was created with the default configuration. -- You have a Prisma Postgres connection string to paste into `.env`. ## 1. Organize your project directory :::note -If you ran the `prisma init` command inside a folder where you want your project to live, you can skip this step and [proceed to the next section](/v6/prisma-postgres/from-the-cli#2-set-up-your-project). +If you ran the `prisma init --db` command inside a folder where you want your project to live, you can skip this step and [proceed to the next section](/v6/prisma-postgres/from-the-cli#2-set-up-your-project). ::: @@ -126,7 +178,7 @@ Here's what each package does: ### 2.4. Review the generated prisma.config.ts -The `prisma init` command automatically created a `prisma.config.ts` file that looks like this: +The `prisma init --db` command automatically created a `prisma.config.ts` file that looks like this: ```typescript title="prisma.config.ts" import "dotenv/config"; diff --git a/apps/docs/content/docs.v6/(index)/prisma-postgres/quickstart/prisma-orm.mdx b/apps/docs/content/docs.v6/(index)/prisma-postgres/quickstart/prisma-orm.mdx index b4c3deb04f..16599db3e1 100644 --- a/apps/docs/content/docs.v6/(index)/prisma-postgres/quickstart/prisma-orm.mdx +++ b/apps/docs/content/docs.v6/(index)/prisma-postgres/quickstart/prisma-orm.mdx @@ -56,23 +56,24 @@ Update `package.json` to enable ESM: } ``` -## 4. Initialize Prisma ORM +## 4. Initialize Prisma ORM and create a Prisma Postgres database Next, set up your Prisma ORM project by creating your [Prisma Schema](/v6/orm/prisma-schema/overview) file with the following command: ```npm -npx prisma init --output ../generated/prisma +npx prisma init --db --output ../generated/prisma ``` :::info -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, replace that value with a direct `postgres://...` connection string from Prisma Postgres. +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database. ::: This command does a few things: - Creates a `prisma/` directory with a `schema.prisma` file containing your database connection and schema models +- Creates a new Prisma Postgres database (when using `--db` flag) - Creates a `.env` file in the root directory for environment variables - Generates the Prisma Client in the `generated/prisma/` directory - Creates a `prisma.config.ts` file for Prisma configuration @@ -107,12 +108,6 @@ datasource db { } ``` -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ## 5. Define your data model Open `prisma/schema.prisma` and add the following models: diff --git a/apps/docs/content/docs.v6/ai/prompts/astro.mdx b/apps/docs/content/docs.v6/ai/prompts/astro.mdx index e186d2b794..7229d21b7e 100644 --- a/apps/docs/content/docs.v6/ai/prompts/astro.mdx +++ b/apps/docs/content/docs.v6/ai/prompts/astro.mdx @@ -82,7 +82,7 @@ export default prisma 5. You MUST wrap all database calls in try-catch blocks 6. You MUST import from `'../generated/prisma/client'` (not `'@prisma/client'`) 7. You MUST use `import.meta.env.DATABASE_URL` in Astro (not `process.env`) -8. You MUST use `npx prisma init --output ../src/generated/prisma` before editing the Prisma schema. If you need Prisma Postgres, run `npx create-db` and update `.env` with the returned `postgres://...` value +8. You MUST ALWAYS use the full `npx prisma init` command with ALL flags: `npx prisma init --db --output ../src/generated/prisma --generator-provider prisma-client` ## CORRECT INSTALLATION @@ -97,7 +97,7 @@ npm install @prisma/extension-accelerate @prisma/client ## CORRECT PRISMA INITIALIZATION ```npm -npx prisma init --output ../src/generated/prisma +npx prisma init --db --output ../src/generated/prisma ``` ## CORRECT SCHEMA CONFIGURATION diff --git a/apps/docs/content/docs.v6/ai/prompts/nextjs.mdx b/apps/docs/content/docs.v6/ai/prompts/nextjs.mdx index 0b997f864c..64abe95d8b 100644 --- a/apps/docs/content/docs.v6/ai/prompts/nextjs.mdx +++ b/apps/docs/content/docs.v6/ai/prompts/nextjs.mdx @@ -164,7 +164,7 @@ export default prisma 10. You MUST create a test script at `scripts/test-database.ts` to verify setup 11. You MUST NOT include `url` in the datasource block of `schema.prisma` 12. You MUST NOT include `engine` property in `prisma.config.ts` -13. You MUST use `npx prisma init --output ../app/generated/prisma` to scaffold Prisma, then `npx create-db` to create a real cloud database +13. You MUST use `npx prisma init --db --output ../app/generated/prisma` to create a real cloud database 14. You MUST use standard TCP URLs (`postgres://...`) in .env 15. You MUST NOT use `accelerateUrl` or `withAccelerate` @@ -186,35 +186,37 @@ npm install @prisma/adapter-pg @prisma/client dotenv ## CORRECT PRISMA INITIALIZATION -> **FOR AI ASSISTANTS**: `npx prisma init` is not interactive. Run it yourself if your environment allows it. If you need a real Prisma Postgres database, either run `npx create-db` or ask the user to run it and update `DATABASE_URL` before you continue. +> **FOR AI ASSISTANTS**: This command is **interactive** and requires user input. You **MUST ask the user to run this command manually** in their own terminal, then **wait for them to confirm completion** before proceeding with the next steps. Do NOT attempt to run this command yourself. ```bash -# Initialize Prisma and scaffold the Prisma files -npx prisma init --output ../app/generated/prisma - -# Then create a Prisma Postgres database -npx create-db +# Initialize Prisma AND create a real Prisma Postgres cloud database +npx prisma init --db --output ../app/generated/prisma ``` -This step: +This command: -- Generates `prisma/schema.prisma` with the correct output path -- Generates `prisma.config.ts` -- Generates `.env` with a local `DATABASE_URL` -- Requires `npx create-db` if you want a real Prisma Postgres database +- Authenticates you with Prisma Console (if needed) +- Prompts for **region** and **project name** +- **Creates a cloud Prisma Postgres database** +- Generates: + - `prisma/schema.prisma` (with correct output path) + - `prisma.config.ts` (with dotenv import) + - **`.env` with a `DATABASE_URL`** -**IMPORTANT**: After `npx create-db`, replace the generated `DATABASE_URL` in `.env` with the returned `postgres://...` connection string. +**IMPORTANT**: Ensure the generated `.env` uses a `postgres://` URL scheme. If it generates `prisma+postgres://`, replace it with the standard TCP connection string available in the Prisma Console. ```text DATABASE_URL="postgres://..." ``` +**IMPORTANT**: Do NOT use `npx prisma init` without `--db` as this only creates local files without a database. + ## CORRECT PRISMA CONFIG (prisma.config.ts) -When using `npx prisma init`, the `prisma.config.ts` is **auto-generated** with the correct configuration: +When using `npx prisma init --db`, the `prisma.config.ts` is **auto-generated** with the correct configuration: ```typescript -import "dotenv/config"; // ✅ Auto-included by prisma init +import "dotenv/config"; // ✅ Auto-included by prisma init --db import { defineConfig, env } from "prisma/config"; export default defineConfig({ @@ -440,26 +442,30 @@ User should follow these steps (AI should provide these instructions): npm install @prisma/adapter-pg @prisma/client dotenv ``` -2. **Initialize Prisma, then create Prisma Postgres:** +2. **Initialize Prisma AND create Prisma Postgres database** (⚠️ USER MUST RUN MANUALLY): - > **AI ASSISTANT**: You can run `npx prisma init` yourself. If you should not provision cloud resources automatically, ask the user to run `npx create-db` and update `DATABASE_URL` before continuing. + > **AI ASSISTANT**: Ask the user to run this command in their own terminal. This is interactive and requires user input. Wait for the user to confirm completion before continuing. ```npm - npx prisma init --output ../app/generated/prisma - npx create-db + npx prisma init --db --output ../app/generated/prisma ``` - This creates `prisma/schema.prisma`, `prisma.config.ts`, and `.env`, then returns a `postgres://...` connection string for Prisma Postgres. + The user should follow the terminal prompts to: + - Authenticate with Prisma Console (if needed) + - Choose a region (e.g., us-east-1) + - Name your project + + Once complete, this creates `prisma/schema.prisma`, `prisma.config.ts`, AND `.env` with the `DATABASE_URL`. - **If you asked the user to run `npx create-db`, wait for them to share or paste the returned connection string before proceeding.** + **User should confirm when done** so the AI can proceed with the next steps. -3. **Verify `.env` was created** - Replace the generated `DATABASE_URL` with the `postgres://...` connection string returned by `npx create-db`. +3. **Verify `.env` was created** - Ensure `DATABASE_URL` uses `postgres://`. If it uses `prisma+postgres://`, change it to the TCP connection string. ```text DATABASE_URL="postgres://..." ``` - **Do NOT invent this URL. Use the one returned by `npx create-db`.** + **Do NOT invent or manually change this URL. Use the one from Prisma Console.** 4. **Update `prisma/schema.prisma`** - Add the User model (generator and datasource are already configured): @@ -518,7 +524,7 @@ Before generating any code, you MUST verify: 10. Did you add `db:test` and `db:studio` scripts to package.json? If not, STOP and FIX. 11. Did you remove `url` from the datasource block in `schema.prisma`? If not, STOP and FIX. 12. Did you remove `engine` property from `prisma.config.ts`? If not, STOP and FIX. -13. Did you run `npx prisma init` with the documented output path? If not, STOP and FIX. +13. Are you using `npx prisma init --db` (not just `npx prisma init`)? If not, STOP and FIX. 14. Is the DATABASE_URL a TCP URL (`postgres://...`)? If it's a `prisma+postgres://` URL, STOP and FIX. 15. Did Prisma generate the `.env` file? If you invented the URL manually, STOP and FIX. @@ -619,8 +625,8 @@ When asked about Prisma + Next.js implementation, you MUST: 11. ALWAYS use `@prisma/adapter-pg` and `adapter` property 12. NEVER include `url` in the datasource block of schema.prisma 13. NEVER include `engine` property in prisma.config.ts -14. ALWAYS run `npx prisma init --output ../app/generated/prisma` before editing Prisma files. If you cannot provision cloud resources automatically, ask the user to run `npx create-db` and update `DATABASE_URL` before continuing -15. ALWAYS wait for user confirmation after they run `npx create-db` and share or apply the returned `postgres://...` connection string before proceeding +14. ALWAYS ask the user to run `npx prisma init --db --output ../app/generated/prisma` **manually in their own terminal** (this command is interactive and requires user input for region and project name) +15. ALWAYS wait for user confirmation after they run the interactive `prisma init --db` command before proceeding 16. NEVER attempt to run interactive commands yourself - ask the user to do it 17. NEVER use `prisma+postgres://` URLs - ONLY `postgres://` TCP URLs 18. NEVER manually invent or fabricate DATABASE_URL values diff --git a/apps/docs/content/docs.v6/guides/ai-sdk-nextjs.mdx b/apps/docs/content/docs.v6/guides/ai-sdk-nextjs.mdx index 81d34601f7..cfd2a4adfe 100644 --- a/apps/docs/content/docs.v6/guides/ai-sdk-nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/ai-sdk-nextjs.mdx @@ -69,28 +69,21 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --output ../app/generated/prisma +npx prisma init --db --output ../app/generated/prisma ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Next.js AI SDK Project" ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A `.env` file containing a local `DATABASE_URL` at the project root. +- A Prisma Postgres database. +- A `.env` file containing the `DATABASE_URL` at the project root. - The `output` field specifies where the generated Prisma Client will be stored. -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models: diff --git a/apps/docs/content/docs.v6/guides/astro.mdx b/apps/docs/content/docs.v6/guides/astro.mdx index 277a2416a0..d010b9902b 100644 --- a/apps/docs/content/docs.v6/guides/astro.mdx +++ b/apps/docs/content/docs.v6/guides/astro.mdx @@ -73,25 +73,17 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --output ../prisma/generated +npx prisma init --db --output ../prisma/generated ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Astro Project" ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file for configuring Prisma -- A `.env` file with a local `DATABASE_URL` already set - -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` +- A `.env` file with a `DATABASE_URL` already set ### 2.2. Define your Prisma Schema diff --git a/apps/docs/content/docs.v6/guides/authjs-nextjs.mdx b/apps/docs/content/docs.v6/guides/authjs-nextjs.mdx index f62533931b..7f77c873c9 100644 --- a/apps/docs/content/docs.v6/guides/authjs-nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/authjs-nextjs.mdx @@ -69,28 +69,21 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --output ../app/generated/prisma +npx prisma init --db --output ../app/generated/prisma ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Auth.js Project" ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A `.env` file containing a local `DATABASE_URL` at the project root. +- A Prisma Postgres database. +- A `.env` file containing the `DATABASE_URL` at the project root. - A schema configuration that specifies where the Prisma Client will be generated (`../app/generated/prisma`). -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, swap the provider to `prisma-client` and add the runtime `vercel-edge` to the generator: diff --git a/apps/docs/content/docs.v6/guides/betterauth-astro.mdx b/apps/docs/content/docs.v6/guides/betterauth-astro.mdx index 5ed151e962..9342dee934 100644 --- a/apps/docs/content/docs.v6/guides/betterauth-astro.mdx +++ b/apps/docs/content/docs.v6/guides/betterauth-astro.mdx @@ -67,28 +67,21 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --output ../prisma/generated +npx prisma init --db --output ../prisma/generated ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Better Auth Astro Project" ::: This will create: - A `prisma` directory with a `schema.prisma` file -- A `.env` file containing a local `DATABASE_URL` at the project root +- A Prisma Postgres database +- A `.env` file containing the `DATABASE_URL` at the project root - A `prisma.config.ts` file for configuring Prisma - An `output` directory for the generated Prisma Client as `prisma/generated` -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.2. Configure Prisma to load environment variables To get access to the variables in the `.env` file, update your `prisma.config.ts` to import `dotenv`: diff --git a/apps/docs/content/docs.v6/guides/betterauth-nextjs.mdx b/apps/docs/content/docs.v6/guides/betterauth-nextjs.mdx index 524fe42bcb..a69685d7a5 100644 --- a/apps/docs/content/docs.v6/guides/betterauth-nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/betterauth-nextjs.mdx @@ -73,27 +73,20 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --output ../src/generated/prisma +npx prisma init --db --output ../src/generated/prisma ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Better Auth Project" ::: This will create: - A `prisma` directory with a `schema.prisma` file -- A `.env` file containing a local `DATABASE_URL` at the project root +- A Prisma Postgres database +- A `.env` file containing the `DATABASE_URL` at the project root - An `output` directory for the generated Prisma Client as `better-auth/generated/prisma` -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.2. Configure Prisma Create a `prisma.config.ts` file in the root of your project with the following content: diff --git a/apps/docs/content/docs.v6/guides/bun.mdx b/apps/docs/content/docs.v6/guides/bun.mdx index 18f5fde2c1..d28a2371f6 100644 --- a/apps/docs/content/docs.v6/guides/bun.mdx +++ b/apps/docs/content/docs.v6/guides/bun.mdx @@ -56,7 +56,7 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Initialize Prisma ORM with Prisma Postgres in your project: ```bash -bunx --bun prisma init +bunx --bun prisma init --db ``` :::note @@ -67,28 +67,32 @@ The `--bun` flag is required to ensure Prisma runs with the Bun runtime. Without :::info -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Bun Project" ::: This command creates: - A `prisma/` directory with your `schema.prisma` file +- A new Prisma Postgres database - A `prisma.config.ts` file - A `.env` file with your `DATABASE_URL` -### 2.3. Create a Prisma Postgres database +### 2.3. Configure environment variables for direct connection -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: +We're going to use a direct connection string for connecting to Prisma Postgres. To get your [direct connection string](/v6/postgres/database/direct-connections#how-to-connect-to-prisma-postgres-via-direct-tcp): -```bash -npx create-db -``` +1. Navigate to your recently created Prisma Postgres project dashboard (e.g. "My Bun Project") +2. Click the **API Keys** tab in the project's sidebar +3. Click the **Create API key** button +4. Provide a name for the API key and click **Create** +5. Copy the connection string starting with `postgres://` -Update your `.env` file: +Update your `.env` file to replace the `DATABASE_URL` with the new connection string: ```bash title=".env" -DATABASE_URL="postgres://..." +DATABASE_URL="your_database_url_here" # [!code --] +DATABASE_URL="your_direct_connection_string_here" # [!code ++] ``` ### 2.4. Update your Prisma schema diff --git a/apps/docs/content/docs.v6/guides/clerk-astro.mdx b/apps/docs/content/docs.v6/guides/clerk-astro.mdx index d88e45f62e..db86762c85 100644 --- a/apps/docs/content/docs.v6/guides/clerk-astro.mdx +++ b/apps/docs/content/docs.v6/guides/clerk-astro.mdx @@ -174,26 +174,18 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init +npx prisma init --db ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for the database like "My Clerk Astro Project" ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file with your Prisma configuration -- A `.env` file with a local `DATABASE_URL` already set - -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` +- A `.env` file with a `DATABASE_URL` already set ### 3.2. Define your Prisma Schema diff --git a/apps/docs/content/docs.v6/guides/clerk-nextjs.mdx b/apps/docs/content/docs.v6/guides/clerk-nextjs.mdx index a1c70d449f..2cf142ca10 100644 --- a/apps/docs/content/docs.v6/guides/clerk-nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/clerk-nextjs.mdx @@ -233,24 +233,16 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --output ../app/generated/prisma +npx prisma init --db --output ../app/generated/prisma ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for the database like "My Clerk NextJS Project" ::: This will create: - A `prisma/` directory with a `schema.prisma` file -- A local `DATABASE_URL` in `.env` - -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` +- A `DATABASE_URL` in `.env` ### 3.2. Define your Prisma Schema diff --git a/apps/docs/content/docs.v6/guides/cloudflare-workers.mdx b/apps/docs/content/docs.v6/guides/cloudflare-workers.mdx index 16d1cca272..52b14c66fd 100644 --- a/apps/docs/content/docs.v6/guides/cloudflare-workers.mdx +++ b/apps/docs/content/docs.v6/guides/cloudflare-workers.mdx @@ -55,26 +55,18 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init +npx prisma init --db ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Cloudflare Workers Project" ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file with your Prisma configuration -- A `.env` file with a local `DATABASE_URL` already set - -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` +- A `.env` file with a `DATABASE_URL` already set ### 2.2. Enable Node.js compatibility in Cloudflare Workers diff --git a/apps/docs/content/docs.v6/guides/data-dog.mdx b/apps/docs/content/docs.v6/guides/data-dog.mdx index 9d118fe65e..75179a0d33 100644 --- a/apps/docs/content/docs.v6/guides/data-dog.mdx +++ b/apps/docs/content/docs.v6/guides/data-dog.mdx @@ -71,15 +71,15 @@ Run the following commands to install Prisma and a minimal TypeScript runner: npm install -D prisma tsx ``` -Then initialize Prisma: +Then initialize Prisma with the `--db` flag to create a [new Prisma Postgres](/v6/postgres) instance: ```npm -npx prisma init --output ../src/generated/prisma +npx prisma init --db --output ../src/generated/prisma ``` -:::info +:::note -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. +You will be prompted to name your database and select the closest region. For clarity, choose a memorable name (e.g., `My Datadog Project`). ::: @@ -112,12 +112,6 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst ::: -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.2. Define models Now, open `prisma/schema.prisma` and update your generator block and models. Replace the `generator` block with the following, and add a `User` and a `Post` model: diff --git a/apps/docs/content/docs.v6/guides/elysia.mdx b/apps/docs/content/docs.v6/guides/elysia.mdx index 097bd9944d..4b7c718501 100644 --- a/apps/docs/content/docs.v6/guides/elysia.mdx +++ b/apps/docs/content/docs.v6/guides/elysia.mdx @@ -51,26 +51,18 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```bash -bunx --bun prisma init --output ../src/generated/prisma +bunx --bun prisma init --db --output ../src/generated/prisma ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Elysia Project" ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` file for configuring Prisma -- A `.env` file with a local `DATABASE_URL` already set - -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` +- A `.env` file with a `DATABASE_URL` already set ### 2.2. Define your Prisma Schema diff --git a/apps/docs/content/docs.v6/guides/embed-studio-nextjs.mdx b/apps/docs/content/docs.v6/guides/embed-studio-nextjs.mdx index e454c99041..6cd748d532 100644 --- a/apps/docs/content/docs.v6/guides/embed-studio-nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/embed-studio-nextjs.mdx @@ -89,31 +89,26 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst ### 2.2. Initialize Prisma with Prisma Postgres -Initialize Prisma in your project: +Initialize Prisma in your project and create a Prisma Postgres database: ```npm -npx prisma init --output ../app/generated/prisma +npx prisma init --db --output ../app/generated/prisma ``` :::info -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. If you choose Prisma Postgres below, create a database in the next step and replace that value with a direct `postgres://...` connection string. +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My \***\*\_\_\*\*** Project" ::: -The `prisma init` command creates: +The `prisma init --db` command creates: - A `prisma/` directory with your `schema.prisma` file - A `prisma.config.ts` file for configuring Prisma +- A new Prisma Postgres database - A `.env` file with your `DATABASE_URL` - An output directory at `app/generated/prisma` for the Prisma Client -If you're using Prisma Postgres, create a database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.3. Define your database schema Open `prisma/schema.prisma` and replace the content with: diff --git a/apps/docs/content/docs.v6/guides/github-actions.mdx b/apps/docs/content/docs.v6/guides/github-actions.mdx index b436a40148..35da8b0801 100644 --- a/apps/docs/content/docs.v6/guides/github-actions.mdx +++ b/apps/docs/content/docs.v6/guides/github-actions.mdx @@ -59,7 +59,7 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma: ```npm -npx prisma init --output ../src/generated/prisma +npx prisma init --db --output ../src/generated/prisma ``` This creates: @@ -68,12 +68,6 @@ This creates: - A `.env` file with `DATABASE_URL` - A generated client in `src/generated/prisma` -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.2. Define your Prisma schema Edit `prisma/schema.prisma` to: diff --git a/apps/docs/content/docs.v6/guides/hono.mdx b/apps/docs/content/docs.v6/guides/hono.mdx index 59dddf1229..529747df6f 100644 --- a/apps/docs/content/docs.v6/guides/hono.mdx +++ b/apps/docs/content/docs.v6/guides/hono.mdx @@ -56,25 +56,17 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --output ../src/generated/prisma +npx prisma init --db --output ../src/generated/prisma ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Hono Project" ::: This will create: - A `prisma/` directory with a `schema.prisma` file - A `prisma.config.ts` with your Prisma configuration -- A `.env` file with a local `DATABASE_URL` already set - -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` +- A `.env` file with a `DATABASE_URL` already set ### 2.2. Define your Prisma Schema diff --git a/apps/docs/content/docs.v6/guides/multiple-databases.mdx b/apps/docs/content/docs.v6/guides/multiple-databases.mdx index 3edbfbc713..f4006ee246 100644 --- a/apps/docs/content/docs.v6/guides/multiple-databases.mdx +++ b/apps/docs/content/docs.v6/guides/multiple-databases.mdx @@ -162,11 +162,10 @@ Your user database schema is now ready. Repeat the initialization for the post database: ```npm -npx prisma init -npx create-db +npx prisma init --db ``` -Replace the generated `DATABASE_URL` in your `.env` file with the value from `npx create-db`, then rename the new `prisma` folder to `prisma-post-database`: +After following the prompts, rename the new `prisma` folder to `prisma-post-database`: ```bash mv prisma prisma-post-database diff --git a/apps/docs/content/docs.v6/guides/nestjs.mdx b/apps/docs/content/docs.v6/guides/nestjs.mdx index a600e8c102..f9fe20dc50 100644 --- a/apps/docs/content/docs.v6/guides/nestjs.mdx +++ b/apps/docs/content/docs.v6/guides/nestjs.mdx @@ -74,7 +74,7 @@ If you are using a different database provider (PostgreSQL, MySQL, SQL Server), Initialize Prisma in your project: ```npm -npx prisma init --output ../src/generated/prisma +npx prisma init --db --output ../src/generated/prisma ``` This creates a new `prisma` directory with the following contents: @@ -83,12 +83,6 @@ This creates a new `prisma` directory with the following contents: - `prisma.config.ts`: A configuration file for your projects - `.env`: A [dotenv](https://github.com/motdotla/dotenv) file, typically used to store your database credentials in a group of environment variables -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.3. Set the generator output path Specify your output `path` for the generated Prisma client by either passing `--output ../src/generated/prisma` during `prisma init` or directly in your Prisma schema: @@ -118,7 +112,7 @@ datasource db { Now, open up `.env` and you should see a `DATABASE_URL` already specified: ```bash title=".env" -DATABASE_URL="postgres://..." +DATABASE_URL="" ``` :::note diff --git a/apps/docs/content/docs.v6/guides/nextjs.mdx b/apps/docs/content/docs.v6/guides/nextjs.mdx index 72d11a00e1..a3d4953c5b 100644 --- a/apps/docs/content/docs.v6/guides/nextjs.mdx +++ b/apps/docs/content/docs.v6/guides/nextjs.mdx @@ -80,29 +80,22 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --output ../app/generated/prisma +npx prisma init --db --output ../app/generated/prisma ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My \***\*\_\_\*\*** Project" ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma. -- A `.env` file containing a local `DATABASE_URL` at the project root. +- A Prisma Postgres database. +- A `.env` file containing the `DATABASE_URL` at the project root. The `app/generated/prisma` output directory for the generated Prisma Client will be created when you run `prisma generate` or `prisma migrate dev` in a later step. -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models: diff --git a/apps/docs/content/docs.v6/guides/react-router-7.mdx b/apps/docs/content/docs.v6/guides/react-router-7.mdx index 10d02136d3..9f87150a01 100644 --- a/apps/docs/content/docs.v6/guides/react-router-7.mdx +++ b/apps/docs/content/docs.v6/guides/react-router-7.mdx @@ -62,28 +62,21 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --output ../app/generated/prisma +npx prisma init --db --output ../app/generated/prisma ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My React Router 7 Project" ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A `.env` file containing a local `DATABASE_URL` at the project root. +- A Prisma Postgres database. +- A `.env` file containing the `DATABASE_URL` at the project root. - An `output` directory for the generated Prisma Client as `app/generated/prisma`. -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models and change the generator to use the `prisma-client` provider: diff --git a/apps/docs/content/docs.v6/guides/shopify.mdx b/apps/docs/content/docs.v6/guides/shopify.mdx index ca867c3836..1cffaedf25 100644 --- a/apps/docs/content/docs.v6/guides/shopify.mdx +++ b/apps/docs/content/docs.v6/guides/shopify.mdx @@ -148,33 +148,33 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst ::: -Initialize Prisma in your project: +Prisma Postgres allows you to create a new database on the fly, you can create a new database at the same time you initialize your project by adding the `--db` flag: ```npm -npx prisma init +npx prisma init --db ``` -Then create a Prisma Postgres database: - -```npm -npx create-db -``` - -Copy the connection string from the CLI output. It should look similar to this: +Once you've completed the prompts, it's time to access your new database: +1. **Open the [Prisma Console](https://console.prisma.io):** + - Log in and select your newly created database project. +2. **Get your database connection string:** + - Click the **Connect** button. + - Copy the connection string that appears. It should look similar to this: ```text DATABASE_URL="postgresql://user:password@host:5432/database?sslmode=require" ``` - -Replace the generated `DATABASE_URL` in your `.env` file with the value from `npx create-db`. - -Apply your database schema: +3. **Configure your environment:** + - Create a new `.env` file in the root of your project. + - Paste the `DATABASE_URL` you just copied into this file. +4. **Apply your database schema:** + - Run the following command to create your tables and get your database ready: ```npm npx prisma migrate dev --name init ``` -Then generate Prisma Client: + Then generate Prisma Client: ```npm npx prisma generate diff --git a/apps/docs/content/docs.v6/guides/solid-start.mdx b/apps/docs/content/docs.v6/guides/solid-start.mdx index 01383263c5..76a86935d5 100644 --- a/apps/docs/content/docs.v6/guides/solid-start.mdx +++ b/apps/docs/content/docs.v6/guides/solid-start.mdx @@ -83,28 +83,21 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --output ../src/generated/prisma +npx prisma init --db --output ../src/generated/prisma ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My SolidStart Project" ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A `.env` file containing a local `DATABASE_URL` at the project root. +- A Prisma Postgres database. +- A `.env` file containing the `DATABASE_URL` at the project root. - An `output` directory for the generated Prisma Client as `src/generated/prisma`. -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models and change the generator to use the `prisma-client` provider: diff --git a/apps/docs/content/docs.v6/guides/sveltekit.mdx b/apps/docs/content/docs.v6/guides/sveltekit.mdx index 599353179b..4688bc2c86 100644 --- a/apps/docs/content/docs.v6/guides/sveltekit.mdx +++ b/apps/docs/content/docs.v6/guides/sveltekit.mdx @@ -73,28 +73,21 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Once installed, initialize Prisma in your project: ```npm -npx prisma init --output src/generated/prisma +npx prisma init --db --output src/generated/prisma ``` :::info - -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, you will create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. - +You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My SvelteKit Project" ::: This will create: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A `.env` file containing a local `DATABASE_URL` at the project root. +- A Prisma Postgres database. +- A `.env` file containing the `DATABASE_URL` at the project root. - An `output` directory for the generated Prisma Client as `src/generated/prisma`. -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - ### 2.2. Define your Prisma Schema In the `prisma/schema.prisma` file, add the following models and change the generator to use the `prisma-client` provider: diff --git a/apps/docs/content/docs.v6/guides/turborepo.mdx b/apps/docs/content/docs.v6/guides/turborepo.mdx index 2a3ffa6140..6842fb5251 100644 --- a/apps/docs/content/docs.v6/guides/turborepo.mdx +++ b/apps/docs/content/docs.v6/guides/turborepo.mdx @@ -100,30 +100,25 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst Inside the `database` directory, initialize prisma by running: ```npm tab="npm" -npx prisma init --output ../generated/prisma +npx prisma init --db --output ../generated/prisma ``` ```bash tab="yarn" -yarn dlx prisma init --output ../generated/prisma +yarn prisma init --db --output ../generated/prisma ``` ```bash tab="pnpm" -pnpm dlx prisma init --output ../generated/prisma +pnpm prisma init --db --output ../generated/prisma ``` This will create several files inside `packages/database`: - A `prisma` directory with a `schema.prisma` file. - A `prisma.config.ts` file for configuring Prisma -- A `.env` file containing a local `DATABASE_URL` at the project root. +- A Prisma Postgres database. +- A `.env` file containing the `DATABASE_URL` at the project root. - An `output` directory for the generated Prisma Client as `generated/prisma`. -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```bash -npx create-db -``` - In the `packages/database/prisma/schema.prisma` file, add the following models: ```prisma title="packages/database/prisma/schema.prisma" diff --git a/apps/docs/content/docs.v6/guides/use-prisma-in-pnpm-workspaces.mdx b/apps/docs/content/docs.v6/guides/use-prisma-in-pnpm-workspaces.mdx index 7016aea6e3..6d87d0df61 100644 --- a/apps/docs/content/docs.v6/guides/use-prisma-in-pnpm-workspaces.mdx +++ b/apps/docs/content/docs.v6/guides/use-prisma-in-pnpm-workspaces.mdx @@ -107,28 +107,24 @@ pnpm tsc --init Initialize Prisma ORM with an instance of [Prisma Postgres](/v6/postgres) in the `database` package by running the following command: ```bash -pnpm dlx prisma init +pnpm prisma init --db ``` +Enter a name for your project and choose a database region. + :::info -`prisma init` creates the Prisma scaffolding and a local `DATABASE_URL`. In the next step, create a Prisma Postgres database and replace that value with a direct `postgres://...` connection string. +We're going to be using [Prisma Postgres](/v6/postgres/getting-started) in this guide. If you're not using a Prisma Postgres database, you won't need to add the `--db` flag. ::: This command: +- Connects your CLI to your [Prisma Data Platform](https://console.prisma.io) account. If you're not logged in or don't have an account, your browser will open to guide you through creating a new account or signing into your existing one. - Creates a `prisma` directory containing a `schema.prisma` file for your database models. -- Creates a `.env` file with a local `DATABASE_URL`. - - -Create a Prisma Postgres database and replace the generated `DATABASE_URL` in your `.env` file with the `postgres://...` connection string from the CLI output: - -```bash -npx create-db -``` +- Creates a `.env` file with your `DATABASE_URL` (e.g., for Prisma Postgres it should have something similar to `DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=eyJhbGciOiJIUzI..."`). -Edit the `schema.prisma` file to define a `User` model in your database and specify a [custom `output` directory](/orm/reference/prisma-schema-reference#fields-for-prisma-client-provider) to generate the Prisma Client. This ensures that generated types are resolved correctly: +Edit the `schema.prisma` file to define a `User` model in your database and specify a [custom `output` directory](/v6/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path) to generate the Prisma Client. This ensures that generated types are resolved correctly: ```prisma title="prisma/schema.prisma" generator client { diff --git a/apps/docs/content/docs.v6/orm/overview/databases/postgresql.mdx b/apps/docs/content/docs.v6/orm/overview/databases/postgresql.mdx index 80dedfa288..37c31c28ee 100644 --- a/apps/docs/content/docs.v6/orm/overview/databases/postgresql.mdx +++ b/apps/docs/content/docs.v6/orm/overview/databases/postgresql.mdx @@ -16,7 +16,7 @@ Need a Postgres instance yesterday? With [Prisma Postgres](https://www.prisma.io/postgres?utm_source=docs&utm_campaign=postgresql) you can get a database running on bare-metal in three clicks. Connection pooling, query caching, and automated backups are all included. [Visit the Console](https://console.prisma.io?utm_source=docs&utm_campaign=postgresql) to get started today. -Want an even faster way to get started with Prisma Postgres? Run `npx prisma init`, then `npx create-db` in your terminal. 🚀 +Want any even faster way to get started with Prisma Postgres? Just run `npx prisma init --db` in your terminal. 🚀 ::: diff --git a/apps/docs/content/docs.v6/postgres/database/prisma-studio/embedding-studio.mdx b/apps/docs/content/docs.v6/postgres/database/prisma-studio/embedding-studio.mdx index 6fbabf02ab..030e5edd8a 100644 --- a/apps/docs/content/docs.v6/postgres/database/prisma-studio/embedding-studio.mdx +++ b/apps/docs/content/docs.v6/postgres/database/prisma-studio/embedding-studio.mdx @@ -29,7 +29,7 @@ You can embed Prisma Studio in your own app in various scenarios: - Frontend: A React application - Backend: - A server-side application to expose the `/studio` endpoint (e.g. with Express or Hono) - - A Prisma Postgres instance (you can create one with `npx create-db`) + - A Prisma Postgres instance (you can create one with `npx prisma init --db`) :::note The embeddable version of Prisma Studio will be available for other databases in combination with Prisma ORM soon. diff --git a/apps/docs/content/docs.v6/postgres/getting-started.mdx b/apps/docs/content/docs.v6/postgres/getting-started.mdx index 8968591b31..390c0aa3ac 100644 --- a/apps/docs/content/docs.v6/postgres/getting-started.mdx +++ b/apps/docs/content/docs.v6/postgres/getting-started.mdx @@ -8,19 +8,13 @@ metaDescription: Learn how to quickly set up and start using Prisma Postgres. ## Quickstart -To **bootstrap a new Prisma ORM project**, run the following command in your terminal: +To **bootstrap a new Prisma ORM project with a Prisma Postgres database**, run the following command in your terminal: ```npm -npx prisma init +npx prisma init --db ``` -Then create a Prisma Postgres database and update your `.env` file with the `postgres://...` connection string from the CLI output: - -```npm -npx create-db -``` - -Follow [this page](/v6/prisma-postgres/from-the-cli) to complete the setup for your first Prisma Postgres project. +After running this command, the terminal will guide you with next steps. Follow [this page](/v6/prisma-postgres/from-the-cli) to complete the setup for your first Prisma Postgres project. If you need a database quickly for testing, or want to try out Prisma Postgres, you can run the following command to spin up a temporary 24-hour database: