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