# Upgrade to v7 (/docs/guides/upgrade-prisma-orm/v7)

Location: Guides > Upgrade Prisma ORM > Upgrade to v7

Prisma ORM v7 introduces **breaking changes** when you upgrade from an earlier Prisma ORM version. This guide explains how this upgrade might affect your application and gives instructions on how to handle any changes.

<details>
  <summary>
    Questions answered in this page
  </summary>

  * What changed in Prisma v7?
  * How do I upgrade safely?
  * Which breaking changes affect my app?
</details>

For developers using AI Agents, we have a [migration prompt](/ai/prompts/prisma-7) that you can
add to your project for automatic migrations.

> [!NOTE]
> If you are using MongoDB, please note that Prisma ORM v7 does not yet support MongoDB. You should continue using Prisma ORM v6 for now. Support for MongoDB is coming soon in v7.

Update packages [#update-packages]

To upgrade to Prisma ORM v7 from an earlier version, you need to update both the `prisma` and `@prisma/client` packages:

  

#### npm

```bash
npm install @prisma/client@7
npm install -D prisma@7
```

#### pnpm

```bash
pnpm add @prisma/client@7
pnpm add -D prisma@7
```

#### yarn

```bash
yarn add @prisma/client@7
yarn add --dev prisma@7
```

#### bun

```bash
bun add @prisma/client@7
bun add --dev prisma@7
```

> [!CAUTION]
> Before you upgrade, check each breaking change below to see how the upgrade might affect your application.

Breaking changes [#breaking-changes]

This section gives an overview of breaking changes in Prisma ORM v7.

Prerequisites [#prerequisites]

|            | Minimum Version | Recommended |
| ---------- | --------------- | ----------- |
| Node       | 20.19.0         | 22.x        |
| TypeScript | 5.4.0           | 5.9.x       |

ESM support [#esm-support]

Prisma ORM now ships as an ES module, the module format supported in Bun, Deno, and Node. Set the
`type` field in your `package.json` to `module`

```json
{
  "type": "module",
  "scripts": {...},
}
```

If you are using TypeScript, you need to configure your `tsconfig.json` to be able to consume ES modules

```json
{
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "bundler",
    "target": "ES2023",
    "strict": true,
    "esModuleInterop": true
  }
}
```

Schema changes [#schema-changes]

The older `prisma-client-js` provider will be removed in future releases of Prisma ORM. Upgrade to
the new `prisma-client` provider which uses the new Rust-free client. This will give you faster
queries, smaller bundle size, and require less system resources when deployed to your server.

Additionally, the `output` field is now **required** in the generator block. Prisma Client will no longer be generated in `node_modules` by default. You must specify a custom output path.

  

#### Before

```prisma
generator client {
  provider = "prisma-client-js"
  engineType = "binary"
}
```

#### After

```prisma
generator client {
  provider = "prisma-client"
  output   = "./generated/prisma"
}
```

After running `npx prisma generate`, you'll need to update your imports to use the new generated path:

```ts
// Before
import { PrismaClient } from "@prisma/client";

// After
import { PrismaClient } from "./generated/prisma/client";
```

> [!NOTE]
> The import path depends on where you place your generated client. Adjust the path based on your `output` configuration and the location of the file you're importing from.

Additionally other fields such as `url`, `directUrl`, and `shadowDatabaseUrl` in the `datasource` block are deprecated. You can configure them in the [Prisma Config](/orm/reference/prisma-config-reference).

If you were previously using `directUrl` to run migrations then you need to pass the `directUrl` value in the `url` field of `prisma.config.ts` instead as the connection string defined in `url` is used by Prisma CLI for migrations.

```ts title="prisma.config.ts"
import "dotenv/config";
import { defineConfig, env } from "prisma/config";

export default defineConfig({
  datasource: {
    url: env("DATABASE_URL"),
    shadowDatabaseUrl: env("SHADOW_DATABASE_URL"),
  },
});
```

Driver adapters [#driver-adapters]

The way to create a new Prisma Client has changed to require a driver adapter for all databases.
This change aligns with the move to make the main Prisma Client as lean and open as possible. For
instance, if you are using Prisma Postgres, you now need the `@prisma/adapter-pg` adapter. This also
means the signature for creating a new Prisma Client has changed slightly:

> [!WARNING]
> Connection pools have changed.
> 
> Driver adapters use the connection pool settings from the underlying Node.js database driver, which may differ significantly from Prisma ORM v6 defaults. For example, the `pg` driver has no connection timeout by default (`0`), while Prisma ORM v6 used a 5-second timeout.
> 
> **If you experience timeout issues after upgrading**, configure your driver adapter to match v6 behavior. See the [connection pool guide](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool#prisma-orm-v7-driver-adapter-defaults) for detailed configuration examples for each database.

Before [#before]

```ts
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient({
  datasources: {
    db: { url: process.env.DATABASE_URL },
  },
  datasourceUrl: process.env.DATABASE_URL,
});
```

After [#after]

```ts
import { PrismaClient } from "./generated/prisma/client";
import { PrismaPg } from "@prisma/adapter-pg";

const adapter = new PrismaPg({
  connectionString: process.env.DATABASE_URL,
});
export const prisma = new PrismaClient({ adapter });
```

If you are using SQLite, you can use the `@prisma/adapter-better-sqlite3`:

```ts
import { PrismaClient } from "./generated/prisma/client";
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";

const adapter = new PrismaBetterSqlite3({
  url: process.env.DATABASE_URL || "file:./dev.db",
});

export const prisma = new PrismaClient({ adapter });
```

Prisma Accelerate [#prisma-accelerate]

If you used Prisma Accelerate (including Prisma Postgres' `prisma+postgres://` URLs) in v6, keep using the Accelerate URL with the Accelerate extension. Do **not** pass the Accelerate URL to a driver adapter—`PrismaPg` expects a direct database connection string and will fail with `prisma://` or `prisma+postgres://`.

1. Keep your Accelerate URL in `.env` (for example `DATABASE_URL="prisma://..."` or `prisma+postgres://...`).
2. You can point `prisma.config.ts` directly to that same Accelerate URL for CLI operations:

```ts title="prisma.config.ts"
import "dotenv/config";
import { defineConfig, env } from "prisma/config";

export default defineConfig({
  schema: "prisma/schema.prisma",
  datasource: {
    url: env("DATABASE_URL"),
  },
});
```

* If you prefer a separate direct URL for migrations, you can still use `DIRECT_DATABASE_URL` as above—but it's optional for Accelerate users.

3. Instantiate Prisma Client with the Accelerate URL and extension (no adapter):

```ts
import { PrismaClient } from "./generated/prisma/client";
import { withAccelerate } from "@prisma/extension-accelerate";

export const prisma = new PrismaClient({
  accelerateUrl: process.env.DATABASE_URL,
}).$extends(withAccelerate());
```

If you later switch away from Accelerate to direct TCP, provide the direct URL to the appropriate driver adapter (for example `PrismaPg`) instead of `accelerateUrl`.

SSL certificate validation changes [#ssl-certificate-validation-changes]

Since Prisma ORM v7 uses `node-pg` instead of the Rust-based query engine, SSL certificate defaults have changed. Previously, invalid SSL certificates were ignored. In v7, you may encounter the following error:

```bash
Error: P1010: User was denied access on the database <database>
```

To fix this, either keep the previous behavior:

```ts
const adapter = new PrismaPg({
  connectionString: process.env.DATABASE_URL,
  ssl: { rejectUnauthorized: false },
});
```

Or properly configure your database certificates using `node --use-openssl-ca` or by setting the `NODE_EXTRA_CA_CERTS` environment variable.

For more details, see [GitHub issue #28795](https://github.com/prisma/prisma/issues/28795).

Environment variables [#environment-variables]

In Prisma ORM 7.0.0, environment variables are not loaded by default. Instead developers need to
explicitly load the variables when calling the `prisma` CLI. Libraries like [`dotenv`](https://github.com/motdotla/dotenv) can be used to manage loading environment variables by reading the appropriate `.env` file.

  

#### npm

```bash
npm install dotenv
```

#### pnpm

```bash
pnpm add dotenv
```

#### yarn

```bash
yarn add dotenv
```

#### bun

```bash
bun add dotenv
```

For bun users, no action is required as bun will automatically load `.env` files.

Prisma config [#prisma-config]

Prisma Config is now the default place for configuring how the Prisma CLI interacts with your
database. You now configure your database URL, schema location, migration output, and custom seed
scripts.

> [!NOTE]
> The `prisma.config.ts` file should be placed at the **root of your project** (where your `package.json` is located).

```ts
import "dotenv/config";
import { defineConfig, env } from "prisma/config";

export default defineConfig({
  // the main entry for your schema
  schema: "prisma/schema.prisma",
  // where migrations should be generated
  // what script to run for "prisma db seed"
  migrations: {
    path: "prisma/migrations",
    seed: "tsx prisma/seed.ts",
  },
  // The database URL
  datasource: {
    // Type Safe env() helper
    // Does not replace the need for dotenv
    url: env("DATABASE_URL"),
  },
});
```

Metrics removed [#metrics-removed]

The Metrics preview feature was deprecated in [Prisma ORM 6.14.0](https://github.com/prisma/prisma/releases/tag/6.14.0) and has been removed for Prisma ORM 7.0.0.
If you need this feature, you can use the underlying driver adapter for your database, or Client Extensions to make this information available.

For example, a basic `totalQueries` counter:

```ts
let total = 0;
const prisma = new PrismaClient().$extends({
  client: {
    $log: (s: string) => console.log(s),
    async $totalQueries() {
      return total;
    },
  },
  query: {
    $allModels: {
      async $allOperations({ query, args }) {
        total += 1;
        return query(args);
      },
    },
  },
});

async function main() {
  prisma.$log("Hello world");
  const totalQueries = await prisma.$totalQueries();
  console.log(totalQueries);
}
```

Mapped enum values in generated TypeScript [#mapped-enum-values-in-generated-typescript]

> [!NOTE]
> Reversion to Prisma 6 behavior
> 
> The mapped enum implementation that was initially planned for Prisma ORM v7 has been reverted. Mapped enum behavior now matches Prisma ORM v6 to avoid breaking changes. We plan to implement a similar feature in the future with different syntax.

In Prisma ORM v7, the generated TypeScript enum values use the **schema names**, not the mapped values. This maintains compatibility with Prisma ORM v6 behavior.

Prisma ORM v6 behavior [#prisma-orm-v6-behavior]

Given this Prisma schema:

```prisma
enum SuggestionStatus {
  PENDING  @map("pending")
  ACCEPTED @map("accepted")
  REJECTED @map("rejected")
}
```

In v6, the generated TypeScript enum was:

```ts
export const SuggestionStatus = {
  PENDING: "PENDING",
  ACCEPTED: "ACCEPTED",
  REJECTED: "REJECTED",
} as const;
```

Prisma ORM v7 (reverted behavior) [#prisma-orm-v7-reverted-behavior]

In v7, the same schema generates the same TypeScript as v6:

```ts
export const SuggestionStatus = {
  PENDING: "PENDING",
  ACCEPTED: "ACCEPTED",
  REJECTED: "REJECTED",
} as const;
```

This means that `SuggestionStatus.PENDING` evaluates to `"PENDING"`, not `"pending"`. The mapping is handled at the database level only.

Migration steps [#migration-steps]

No migration is required for this change. The behavior now matches Prisma ORM v6, so existing code will continue to work as expected.

Client middleware removed [#client-middleware-removed]

The client middleware API has been removed. If possible, use [Client Extensions](/orm/prisma-client/client-extensions).

```ts
// ❌ Old (removed)
prisma.$use(async (params, next) => {
  // middleware logic
  return next(params);
});
// ✅ New (use extensions)
const prisma = new PrismaClient().$extends({
  query: {
    user: {
      async findMany({ args, query }) {
        // extension logic
        return query(args);
      },
    },
  },
});
```

Seeding changes [#seeding-changes]

In Prisma ORM v6 and earlier, running `prisma migrate dev` or `prisma migrate reset` would automatically execute your seed script after applying migrations. This automatic seeding behavior has been removed in Prisma ORM v7.

To seed your database in v7, you must explicitly run:

  

#### npm

```bash
npx prisma db seed
```

#### pnpm

```bash
pnpm dlx prisma db seed
```

#### yarn

```bash
yarn dlx prisma db seed
```

#### bun

```bash
bunx --bun prisma db seed
```

Removed CLI flags [#removed-cli-flags]

The `--skip-generate` flag was removed from `prisma migrate dev` and `prisma db push`. The `--skip-seed` flag was removed from `prisma migrate dev`.

`migrate dev` and `db push` no longer run `prisma generate` automatically. You must run `prisma generate` explicitly to generate Prisma Client.

Removed db execute flags [#removed-db-execute-flags]

The `--schema` and `--url` flags have been removed from the `prisma db execute` command. Previously, you could use `--schema` to specify the path to your Prisma schema file, or `--url` to specify the database URL directly. Now, the database connection must be configured in `prisma.config.ts`.

Before (v6) [#before-v6]

```bash
# Using --schema
prisma db execute --file ./script.sql --schema prisma/schema.prisma

# Using --url
prisma db execute --file ./script.sql --url "$DATABASE_URL"
```

After (v7) [#after-v7]

Configure your database connection in `prisma.config.ts` instead:

```ts
import "dotenv/config";
import { defineConfig, env } from "prisma/config";

export default defineConfig({
  schema: "prisma/schema.prisma",
  datasource: {
    url: env("DATABASE_URL"),
  },
});
```

Then run the command without `--schema` or `--url`:

```bash
prisma db execute --file ./script.sql
```

Migrate diff changes [#migrate-diff-changes]

Several options have been removed from `prisma migrate diff` and replaced with new options that use `prisma.config.ts`:

| Removed Option             | Replacement                     |
| -------------------------- | ------------------------------- |
| `--from-url`               | `--from-config-datasource`      |
| `--to-url`                 | `--to-config-datasource`        |
| `--from-schema-datasource` | `--from-config-datasource`      |
| `--to-schema-datasource`   | `--to-config-datasource`        |
| `--shadow-database-url`    | Configure in `prisma.config.ts` |

Before (v6) [#before-v6-1]

```bash
prisma migrate diff \
  --from-url "$DATABASE_URL" \
  --to-schema schema.prisma \
  --script
```

After (v7) [#after-v7-1]

Configure your database connection in `prisma.config.ts`, then use `--from-config-datasource` or `--to-config-datasource`:

```bash
prisma migrate diff \
  --from-config-datasource \
  --to-schema schema.prisma \
  --script
```

Various environment variables have been removed [#various-environment-variables-have-been-removed]

We've removed a small selection of Prisma-specific environment variables.

* `PRISMA_CLI_QUERY_ENGINE_TYPE`
* `PRISMA_CLIENT_ENGINE_TYPE`
* `PRISMA_QUERY_ENGINE_BINARY`
* `PRISMA_QUERY_ENGINE_LIBRARY`
* `PRISMA_GENERATE_SKIP_AUTOINSTALL`
* `PRISMA_SKIP_POSTINSTALL_GENERATE`
* `PRISMA_GENERATE_IN_POSTINSTALL`
* `PRISMA_GENERATE_DATAPROXY`
* `PRISMA_GENERATE_NO_ENGINE`
* `PRISMA_CLIENT_NO_RETRY`
* `PRISMA_MIGRATE_SKIP_GENERATE`
* `PRISMA_MIGRATE_SKIP_SEED`

## Related pages

- [`Upgrade to v1`](https://www.prisma.io/docs/guides/upgrade-prisma-orm/v1): Comprehensive guide for upgrading from Prisma 1 to Prisma ORM v1
- [`Upgrade to v3`](https://www.prisma.io/docs/guides/upgrade-prisma-orm/v3): Comprehensive guide for upgrading to Prisma ORM v3
- [`Upgrade to v4`](https://www.prisma.io/docs/guides/upgrade-prisma-orm/v4): Comprehensive guide for upgrading to Prisma ORM v4
- [`Upgrade to v5`](https://www.prisma.io/docs/guides/upgrade-prisma-orm/v5): Comprehensive guide for upgrading to Prisma ORM v5
- [`Upgrade to v6`](https://www.prisma.io/docs/guides/upgrade-prisma-orm/v6): Comprehensive guide for upgrading to Prisma ORM v6