From 58be6c767ad186bfed6ea1f117bf1004f3051d1d Mon Sep 17 00:00:00 2001 From: Mike Hartington Date: Tue, 21 Oct 2025 13:06:36 -0400 Subject: [PATCH 1/5] docs(): update for new release --- .../325-prisma-config-reference.mdx | 125 ++++++++++++++---- .../100-introduction/250-overview.mdx | 9 ++ 2 files changed, 108 insertions(+), 26 deletions(-) diff --git a/content/200-orm/500-reference/325-prisma-config-reference.mdx b/content/200-orm/500-reference/325-prisma-config-reference.mdx index 0c8ec29c23..f2cbcd68ef 100644 --- a/content/200-orm/500-reference/325-prisma-config-reference.mdx +++ b/content/200-orm/500-reference/325-prisma-config-reference.mdx @@ -14,18 +14,22 @@ You can define your config in either of two ways: - Using the `defineConfig` helper: ```ts import path from "node:path"; - import { defineConfig } from "prisma/config"; + import { defineConfig, env } from "prisma/config"; export default defineConfig({ schema: path.join("prisma", "schema.prisma"), - migrations: { + migrations: { path: path.join("db", "migrations"), }, - views: { + views: { path: path.join("db", "views"), }, - typedSql: { - path: path.join("db", "queries"), + typedSql: { + path: path.join("db", "queries"), + }, + engine: "classic", + datasource: { + url: env("DATABASE_URL") } }); ``` @@ -45,6 +49,10 @@ You can define your config in either of two ways: }, typedSql: { path: path.join("db", "queries"), + }, + engine: "classic", + datasource: { + url: env("DATABASE_URL") } } satisfies PrismaConfig; ``` @@ -90,6 +98,8 @@ export declare type PrismaConfig = { typedSql?: { path: string; }; + // Depending on the choice, you must provide either a `datasource` object or driver adapter + engine: 'classic': 'js' }; ``` @@ -131,9 +141,6 @@ import path from "node:path"; import type { PrismaConfig } from "prisma"; import { PrismaD1 } from "@prisma/adapter-d1"; -// import your .env file -import "dotenv/config"; - export default { experimental: { adapter: true @@ -332,6 +339,55 @@ Failed to load config file "~" as a TypeScript/JavaScript module. Error: Error: ::: + +### `engine` + +Configure the schema engine your project should use. + +| Property | Type | Required | Default | +| -------- | ------------------ | -------- | ----------------- | +| `engine` | `classic` or `js` | No | `classic` | + + By default it is set to use the Rust-based schema engine, which requires that `datasource` be set + in your `prisma.config.ts`. + +```ts +import path from "node:path"; +import { defineConfig, env } from "@prisma/config"; +export default defineConfig({ + engine: "classic", + datasource: { + url: env('DATABASE_URL'), + }, + schema: path.join("prisma", "schema.prisma"), +}); +``` + +Alternatively, if you are opting to use the newer Rust-free schema engine, set the engine to `js` and +provide the adapter you wish to use + +```ts +import path from "node:path"; +import { defineConfig, env } from "@prisma/config"; +import { PrismaD1 } from "@prisma/adapter-d1"; +export default defineConfig({ + experimental: { + adapter: true + }, + engine: "js", + async adapter() { + return new PrismaD1({ + CLOUDFLARE_D1_TOKEN: process.env.CLOUDFLARE_D1_TOKEN, + CLOUDFLARE_ACCOUNT_ID: process.env.CLOUDFLARE_ACCOUNT_ID, + CLOUDFLARE_DATABASE_ID: process.env.CLOUDFLARE_DATABASE_ID, + }); + }, + schema: path.join("prisma", "schema.prisma"), +}); + +``` + + ## Common patterns ### Setting up your project @@ -356,27 +412,37 @@ export default {} satisfies PrismaConfig; ### Using environment variables -When using `prisma.config.ts`, environment variables from `.env` files are not automatically loaded. If you're using node or deno, you'll need to: +When using `prisma.config.ts`, environment variables from `.env` files are not automatically loaded. Using `tsx`, you can pass a `--env-file` flag and that will automatically add those values to `process.env` -1. Pass a `--env-file` flag to the command line +If using Node or Deno: - - ```terminal -node --env-file=.env index.js -node --env-file=.env --env-file=.local.env index.js +tsx --env-file=.env src/index.ts +tsx watch --env-file=.env --env-file=.local.env src/index.ts +tsx --env-file=.env ./prisma/seed.ts ``` - - -```terminal -deno run --env-file main.ts -deno run --env-file=.env --env-file=.local.env main.ts -``` - - For Bun, `.env` files are automatically loaded. +For accessing environment variables within `prisma.config.ts`, use the `env()` helper function to +provide a type-safe way of accessing that variable: + +```tsx +import path from "node:path"; +import { defineConfig, env } from "@prisma/config"; + +type Env = { + DATABASE_URL: string +} +export default defineConfig({ + engine: "classic", + datasource: { + url: env('DATABASE_URL'), + }, + schema: path.join("prisma", "schema.prisma"), +}); +``` + For releases of Node before v20, you'll need to: 1. Install the `dotenv` package: @@ -389,11 +455,18 @@ npm install dotenv ```ts import "dotenv/config"; -import type { PrismaConfig } from "prisma"; +import { defineConfig, env } from "@prisma/config"; -export default { - // now you can use process.env variables -} satisfies PrismaConfig; +type Env = { + DATABASE_URL: string +} +export default defineConfig({ + engine: "classic", + datasource: { + url: env('DATABASE_URL'), + }, + schema: path.join("prisma", "schema.prisma"), +}); ``` ### Using multi-file schemas diff --git a/content/250-postgres/100-introduction/250-overview.mdx b/content/250-postgres/100-introduction/250-overview.mdx index e3d8035024..380533dfee 100644 --- a/content/250-postgres/100-introduction/250-overview.mdx +++ b/content/250-postgres/100-introduction/250-overview.mdx @@ -27,6 +27,15 @@ You can view the following usage metrics in your Console Dashboard: - Cumulative operations - Operations per day +For details into individual databases in your workspace, each database has it's own metrics report +as well. You can view the following: + +- Average response size +- Average query duration +- Total egress +- Total Operations +- Cache utilisation + ## Billing ### Usage-based pricing From 7406f287ff88ffd4d8f2392c5f7c64ba3a489cf5 Mon Sep 17 00:00:00 2001 From: Mike Hartington Date: Tue, 21 Oct 2025 13:26:29 -0400 Subject: [PATCH 2/5] update with feedback --- .../500-reference/325-prisma-config-reference.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/200-orm/500-reference/325-prisma-config-reference.mdx b/content/200-orm/500-reference/325-prisma-config-reference.mdx index f2cbcd68ef..123d9afb69 100644 --- a/content/200-orm/500-reference/325-prisma-config-reference.mdx +++ b/content/200-orm/500-reference/325-prisma-config-reference.mdx @@ -353,7 +353,7 @@ Configure the schema engine your project should use. ```ts import path from "node:path"; -import { defineConfig, env } from "@prisma/config"; +import { defineConfig, env } from "prisma/config"; export default defineConfig({ engine: "classic", datasource: { @@ -368,7 +368,7 @@ provide the adapter you wish to use ```ts import path from "node:path"; -import { defineConfig, env } from "@prisma/config"; +import { defineConfig, env } from "prisma/config"; import { PrismaD1 } from "@prisma/adapter-d1"; export default defineConfig({ experimental: { @@ -429,7 +429,7 @@ provide a type-safe way of accessing that variable: ```tsx import path from "node:path"; -import { defineConfig, env } from "@prisma/config"; +import { defineConfig, env } from "prisma/config"; type Env = { DATABASE_URL: string @@ -455,7 +455,7 @@ npm install dotenv ```ts import "dotenv/config"; -import { defineConfig, env } from "@prisma/config"; +import { defineConfig, env } from "prisma/config"; type Env = { DATABASE_URL: string @@ -569,7 +569,7 @@ If Prisma is installed globally (`npm i -g prisma`), it may not find your `prism To avoid issues: - Prefer local Prisma installations in your project. -- Or use `@prisma/config` locally and pass `--config` to point to your config file. +- Or use `prisma/config` locally and pass `--config` to point to your config file. ### Monorepos From daabff43ac66fb8b1f69e7488092fd50cb749867 Mon Sep 17 00:00:00 2001 From: Mike Hartington Date: Tue, 21 Oct 2025 21:20:43 -0400 Subject: [PATCH 3/5] updates with feedback --- content/200-orm/500-reference/325-prisma-config-reference.mdx | 2 +- content/250-postgres/100-introduction/250-overview.mdx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/200-orm/500-reference/325-prisma-config-reference.mdx b/content/200-orm/500-reference/325-prisma-config-reference.mdx index 123d9afb69..681e77b564 100644 --- a/content/200-orm/500-reference/325-prisma-config-reference.mdx +++ b/content/200-orm/500-reference/325-prisma-config-reference.mdx @@ -99,7 +99,7 @@ export declare type PrismaConfig = { path: string; }; // Depending on the choice, you must provide either a `datasource` object or driver adapter - engine: 'classic': 'js' + engine: 'classic' | 'js' }; ``` diff --git a/content/250-postgres/100-introduction/250-overview.mdx b/content/250-postgres/100-introduction/250-overview.mdx index 380533dfee..8b5300dc91 100644 --- a/content/250-postgres/100-introduction/250-overview.mdx +++ b/content/250-postgres/100-introduction/250-overview.mdx @@ -33,8 +33,8 @@ as well. You can view the following: - Average response size - Average query duration - Total egress -- Total Operations -- Cache utilisation +- Total operations +- Cache utilization ## Billing From 5597ef3cef4b7d97d8f1b8f388d698183e3eebb2 Mon Sep 17 00:00:00 2001 From: Mike Hartington Date: Wed, 22 Oct 2025 08:53:12 -0400 Subject: [PATCH 4/5] upate based on feedback --- .../200-orm/050-overview/500-databases/900-turso.mdx | 1 + .../500-reference/325-prisma-config-reference.mdx | 2 +- content/500-platform/10-about.mdx | 11 +++++++++++ content/800-guides/070-cloudflare-d1.mdx | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/content/200-orm/050-overview/500-databases/900-turso.mdx b/content/200-orm/050-overview/500-databases/900-turso.mdx index d4bdb03925..b9b59a0d89 100644 --- a/content/200-orm/050-overview/500-databases/900-turso.mdx +++ b/content/200-orm/050-overview/500-databases/900-turso.mdx @@ -147,6 +147,7 @@ export default defineConfig({ adapter: true, }, schema: path.join('prisma', 'schema.prisma'), + engine: 'js', async adapter() { return new PrismaLibSQL({ url: process.env.LIBSQL_DATABASE_URL, diff --git a/content/200-orm/500-reference/325-prisma-config-reference.mdx b/content/200-orm/500-reference/325-prisma-config-reference.mdx index 681e77b564..611dcc7c2b 100644 --- a/content/200-orm/500-reference/325-prisma-config-reference.mdx +++ b/content/200-orm/500-reference/325-prisma-config-reference.mdx @@ -348,7 +348,7 @@ Configure the schema engine your project should use. | -------- | ------------------ | -------- | ----------------- | | `engine` | `classic` or `js` | No | `classic` | - By default it is set to use the Rust-based schema engine, which requires that `datasource` be set + By default it is set to use the classic engine, which requires that `datasource` be set in your `prisma.config.ts`. ```ts diff --git a/content/500-platform/10-about.mdx b/content/500-platform/10-about.mdx index a26901a6b7..12208f0cae 100644 --- a/content/500-platform/10-about.mdx +++ b/content/500-platform/10-about.mdx @@ -45,6 +45,17 @@ In each workspace, you can: - invite other users to collaborate in the workspace. - access the [Optimize dashboard](https://console.prisma.io/optimize?utm_source=docs&utm_medium=optimize-docs) to measure query performance and receive AI-powered recommendations. +### Database Metrics + +You can have a single workspace that hosts several database. Within each database, you can view +detailed reports on how your database is performing, with various metrics like: + +- Average response size +- Average query duration +- Total egress +- Total operations +- Cache utilization + #### Optimize You can access Optimize within your [Prisma Data Platform account](https://console.prisma.io/optimize) workspace. diff --git a/content/800-guides/070-cloudflare-d1.mdx b/content/800-guides/070-cloudflare-d1.mdx index 7264a75355..07f0e53970 100644 --- a/content/800-guides/070-cloudflare-d1.mdx +++ b/content/800-guides/070-cloudflare-d1.mdx @@ -191,6 +191,7 @@ export default { adapter: true, }, schema: 'prisma/schema.prisma', + engine: 'js', async adapter() { return new PrismaD1({ CLOUDFLARE_D1_TOKEN: process.env.CLOUDFLARE_D1_TOKEN!, From 4c863bd8ce946adca73bdfcd0c9ce66434fbe12d Mon Sep 17 00:00:00 2001 From: Mike Hartington Date: Wed, 22 Oct 2025 08:56:56 -0400 Subject: [PATCH 5/5] update based on feedback --- content/200-orm/050-overview/500-databases/900-turso.mdx | 1 - content/800-guides/070-cloudflare-d1.mdx | 1 - 2 files changed, 2 deletions(-) diff --git a/content/200-orm/050-overview/500-databases/900-turso.mdx b/content/200-orm/050-overview/500-databases/900-turso.mdx index b9b59a0d89..d4bdb03925 100644 --- a/content/200-orm/050-overview/500-databases/900-turso.mdx +++ b/content/200-orm/050-overview/500-databases/900-turso.mdx @@ -147,7 +147,6 @@ export default defineConfig({ adapter: true, }, schema: path.join('prisma', 'schema.prisma'), - engine: 'js', async adapter() { return new PrismaLibSQL({ url: process.env.LIBSQL_DATABASE_URL, diff --git a/content/800-guides/070-cloudflare-d1.mdx b/content/800-guides/070-cloudflare-d1.mdx index 07f0e53970..7264a75355 100644 --- a/content/800-guides/070-cloudflare-d1.mdx +++ b/content/800-guides/070-cloudflare-d1.mdx @@ -191,7 +191,6 @@ export default { adapter: true, }, schema: 'prisma/schema.prisma', - engine: 'js', async adapter() { return new PrismaD1({ CLOUDFLARE_D1_TOKEN: process.env.CLOUDFLARE_D1_TOKEN!,