Skip to content

Commit 14d0cb3

Browse files
docs: list database options where a missing or unreachable database stops you, and in deploy guides
- Prisma ORM 7 and 6 error references: a "No database yet?" tip at P1001 and at P1012's missing environment variable. - Prisma ORM 7 environment variables page and reference: the same tip next to DATABASE_URL. - Prisma ORM 7 Vercel, Cloudflare and migrate deploy guides, and the Docker guide: a local database is not reachable from production, with hosted options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Gregory Boch <boch@prisma.io>
1 parent b6f6b2f commit 14d0cb3

9 files changed

Lines changed: 74 additions & 1 deletion

File tree

‎apps/docs/content/docs/guides/deployment/docker.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ The prompt above runs [`npx prisma@latest init`](/cli/init) in its first step. I
582582

583583
## Next steps
584584

585+
- Deploy the image to a server with a database it can reach: a PostgreSQL that runs on your own machine is not reachable from a server elsewhere. Set `DATABASE_URL` in `.env.prod` to a hosted PostgreSQL, such as [Prisma Postgres](/postgres) or another provider, or keep the `postgres_db` service from step 3 on the same server.
585586
- Change the schema in `src/prisma/contract.prisma`, run `npm run contract:emit`, then `npx prisma migration plan --name <change>`. Start the standalone database from step 2 again and run `npx prisma db migrate`, so your next `migration plan` starts after this change. The next `docker compose up --build` applies the new migration to the app's database. See [Generating a migration](/orm/migrations/generating-a-migration) and [Applying a migration](/orm/migrations/applying-a-migration).
586587
- [Learn the fundamentals](/orm/fundamentals/reading-data): filtering, sorting, pagination, and writes.
587588
- [Read the Prisma ORM overview](/orm) for the concepts behind contracts and typed queries.

‎apps/docs/content/docs/orm/v6/reference/error-reference.mdx‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ Prisma Client throws a `PrismaClientValidationError` exception if validation fai
8686

8787
"Can't reach database server at `{database_host}`:`{database_port}` Please make sure your database server is running at `{database_host}`:`{database_port}`."
8888

89+
:::tip[No database yet?]
90+
91+
If there is no database server to reach yet, any of these gives you one:
92+
93+
- **On your machine:** run `npx prisma dev` to start a local Prisma Postgres, and set `DATABASE_URL` to the connection string it shows.
94+
- **Hosted, without an account:** run [`npx create-db@latest`](/postgres/npx-create-db) for a temporary Prisma Postgres database. It is deleted after 72 hours unless you claim it with a free Prisma account.
95+
- **Your own server:** set `DATABASE_URL` to the connection string of a database server you already run.
96+
97+
:::
98+
8999
#### `P1002`
90100

91101
"The database server at `{database_host}`:`{database_port}` was reached but timed out. Please try again. Please make sure your database server is running at `{database_host}`:`{database_port}`. "
@@ -158,6 +168,16 @@ Possible P1012 error messages:
158168
- "Error validating enum `{}`: {}"
159169
- "Error validating: {}"
160170

171+
:::tip[No database yet?]
172+
173+
If the message is `Environment variable not found: DATABASE_URL.` because you have no database yet, any of these gives you one:
174+
175+
- **On your machine:** run `npx prisma dev` to start a local Prisma Postgres, and set `DATABASE_URL` to the connection string it shows.
176+
- **Hosted, without an account:** run [`npx create-db@latest`](/postgres/npx-create-db) for a temporary Prisma Postgres database. It is deleted after 72 hours unless you claim it with a free Prisma account.
177+
- **Your own server:** set `DATABASE_URL` to the connection string of a database server you already run.
178+
179+
:::
180+
161181
#### `P1013`
162182

163183
"The provided database string is invalid. \{details}"

‎apps/docs/content/docs/orm/v7/more/dev-environment/environment-variables.mdx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ Prisma ORM always reads environment variables from the system's environment.
2828

2929
When you initialize Prisma ORM in your project with `prisma init`, it creates a convenience `.env` file for you to set your [`connection url`](/orm/v7/reference/connection-urls) as an environment variable. When you use Prisma CLI or Prisma Client, the `.env` file content and the variables defined in it are added to the [`process.env` object](https://nodejs.org/api/process.html#processenv), where Prisma ORM can read it and use it.
3030

31+
:::tip[No database yet?]
32+
33+
If you have no database to point `DATABASE_URL` at yet, any of these gives you one:
34+
35+
- **On your machine:** run `npx prisma dev` to start a local Prisma Postgres, and set `DATABASE_URL` to the connection string it shows.
36+
- **Hosted, without an account:** run [`npx create-db@latest`](/postgres/npx-create-db) for a temporary Prisma Postgres database. It is deleted after 72 hours unless you claim it with a free Prisma account.
37+
- **Your own server:** set `DATABASE_URL` to the connection string of a database server you already run.
38+
39+
:::
40+
3141
### Using an `.env` file
3242

3343
:::warning

‎apps/docs/content/docs/orm/v7/prisma-client/deployment/deploy-database-changes-with-prisma-migrate.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Exactly when to run `prisma migrate deploy` depends on your platform. For exampl
2626

2727
Ideally, `migrate deploy` should be part of an automated CI/CD pipeline, and we do not generally recommend running this command locally to deploy changes to a production database (for example, by temporarily changing the `DATABASE_URL` environment variable). It is not generally considered good practice to store the production database URL locally.
2828

29+
The production database has to be one your pipeline and your app can reach. A database that runs on your machine, such as `npx prisma dev`, PostgreSQL in Docker or a SQLite file, is not. Use a hosted database, such as Prisma Postgres or another hosted PostgreSQL provider.
30+
2931
Beware that in order to run the `prisma migrate deploy` command, you need access to the `prisma` dependency that is typically added to the `devDependencies`. Some platforms like Vercel, prune development dependencies during the build, thereby preventing you from calling the command. This can be worked around by making the `prisma` a production dependency, by moving it to `dependencies` in your `package.json`.
3032
For more information about the `migrate deploy` command, see:
3133

‎apps/docs/content/docs/orm/v7/prisma-client/deployment/edge/deploy-to-cloudflare.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ If you're using an approach that requires `dotenv`, you need to have the [`doten
124124

125125
#### Production
126126

127+
A database that runs on your machine, such as `npx prisma dev`, PostgreSQL in Docker or a SQLite file, is not reachable from Cloudflare Workers. Use a hosted database, such as Prisma Postgres ([`npx create-db@latest`](/postgres/npx-create-db), then claim it to keep it), Cloudflare D1 or another hosted PostgreSQL provider.
128+
127129
When deploying your Worker to **production**, you'll need to set the database connection using the `wrangler` CLI:
128130

129131
```npm

‎apps/docs/content/docs/orm/v7/prisma-client/deployment/edge/deploy-to-vercel.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ When in **development**, you can configure your database connection via the `DAT
8787

8888
#### Production
8989

90+
A database that runs on your machine, such as `npx prisma dev`, PostgreSQL in Docker or a SQLite file, is not reachable from Vercel. Use a hosted database, such as Prisma Postgres ([`npx create-db@latest`](/postgres/npx-create-db), then claim it to keep it) or another hosted PostgreSQL provider.
91+
9092
When deploying your Edge Function to **production**, you'll need to set the database connection using the `vercel` CLI:
9193

9294
```npm

‎apps/docs/content/docs/orm/v7/prisma-client/deployment/serverless/deploy-to-vercel.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ metaDescription: Learn how to deploy a Next.js application based on Prisma Clien
88

99
This guide takes you through the steps to set up and deploy a serverless application that uses Prisma to [Vercel](https://vercel.com/).
1010

11-
Need a production database? Add Prisma Postgres from the [Vercel Marketplace](/guides/postgres/vercel). The integration sets `DATABASE_URL` and `DATABASE_URL_POOLED` on the Vercel environments you connect, which by default are Production, Preview and Development, so preview deployments share the production database. To give previews their own database, connect the integration to Production only and follow [Add a separate database for preview deployments](#add-a-separate-database-for-preview-deployments).
11+
A database that runs on your machine, such as `npx prisma dev`, PostgreSQL in Docker or a SQLite file, is not reachable from Vercel, so production needs a hosted database. Need one? Add Prisma Postgres from the [Vercel Marketplace](/guides/postgres/vercel). The integration sets `DATABASE_URL` and `DATABASE_URL_POOLED` on the Vercel environments you connect, which by default are Production, Preview and Development, so preview deployments share the production database. To give previews their own database, connect the integration to Production only and follow [Add a separate database for preview deployments](#add-a-separate-database-for-preview-deployments).
1212

1313
Vercel is a cloud platform that hosts static sites, serverless, and edge functions. You can integrate a Vercel project with a GitHub repository to allow you to deploy automatically when you make new commits.
1414

‎apps/docs/content/docs/orm/v7/reference/environment-variables-reference.mdx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ metaDescription: This page gives an overview of all environment variables availa
88

99
This document describes different environment variables and their use cases.
1010

11+
## Database connection
12+
13+
### `DATABASE_URL`
14+
15+
The connection string of your database. Prisma ORM does not read it on its own: the `prisma.config.ts` that `prisma init` writes reads it, and so does the driver adapter you set up in your app. See [Connection URLs](/orm/v7/reference/connection-urls).
16+
17+
:::tip[No database yet?]
18+
19+
If you have no database to point `DATABASE_URL` at yet, any of these gives you one:
20+
21+
- **On your machine:** run `npx prisma dev` to start a local Prisma Postgres, and set `DATABASE_URL` to the connection string it shows.
22+
- **Hosted, without an account:** run [`npx create-db@latest`](/postgres/npx-create-db) for a temporary Prisma Postgres database. It is deleted after 72 hours unless you claim it with a free Prisma account.
23+
- **Your own server:** set `DATABASE_URL` to the connection string of a database server you already run.
24+
25+
:::
26+
1127
## Prisma Client
1228

1329
### `DEBUG`

‎apps/docs/content/docs/orm/v7/reference/error-reference.mdx‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ Prisma Client throws a `PrismaClientValidationError` exception if validation fai
8686

8787
"Can't reach database server at `{database_host}`:`{database_port}` Please make sure your database server is running at `{database_host}`:`{database_port}`."
8888

89+
:::tip[No database yet?]
90+
91+
If there is no database server to reach yet, any of these gives you one:
92+
93+
- **On your machine:** run `npx prisma dev` to start a local Prisma Postgres, and set `DATABASE_URL` to the connection string it shows.
94+
- **Hosted, without an account:** run [`npx create-db@latest`](/postgres/npx-create-db) for a temporary Prisma Postgres database. It is deleted after 72 hours unless you claim it with a free Prisma account.
95+
- **Your own server:** set `DATABASE_URL` to the connection string of a database server you already run.
96+
97+
:::
98+
8999
#### `P1002`
90100

91101
"The database server at `{database_host}`:`{database_port}` was reached but timed out. Please try again. Please make sure your database server is running at `{database_host}`:`{database_port}`. "
@@ -160,6 +170,16 @@ Possible P1012 error messages:
160170
- "Error validating enum `{}`: {}"
161171
- "Error validating: {}"
162172

173+
:::tip[No database yet?]
174+
175+
If the message is `Environment variable not found: DATABASE_URL.` because you have no database yet, any of these gives you one:
176+
177+
- **On your machine:** run `npx prisma dev` to start a local Prisma Postgres, and set `DATABASE_URL` to the connection string it shows.
178+
- **Hosted, without an account:** run [`npx create-db@latest`](/postgres/npx-create-db) for a temporary Prisma Postgres database. It is deleted after 72 hours unless you claim it with a free Prisma account.
179+
- **Your own server:** set `DATABASE_URL` to the connection string of a database server you already run.
180+
181+
:::
182+
163183
#### `P1013`
164184

165185
"The provided database string is invalid. \{details}"

0 commit comments

Comments
 (0)