# Older versions (Prisma ORM v6) (/docs/orm/v6/more/upgrades/older-versions)

Upgrade guides for Prisma ORM versions 3, 4, 5, and 6

Location: ORM > v6 > More > Upgrades > Older versions

This page provides upgrade guidance for older Prisma ORM versions. For upgrading to the current version, see [Upgrade to v7](/guides/more-4-v6-more-upgrades-to-v7).

## Upgrading to v6

Prisma ORM v6 introduced breaking changes related to Node.js versions, TypeScript versions, and schema changes for PostgreSQL.

### Key breaking changes

- **Minimum Node.js**: 18.18.0, 20.9.0, or 22.11.0
- **Minimum TypeScript**: 5.1.0
- **PostgreSQL implicit m-n relations**: Changed from unique index to primary key
- **Full-text search on PostgreSQL**: Now requires `fullTextSearchPostgres` preview feature
- **`Buffer` replaced with `Uint8Array`**: For `Bytes` fields
- **`NotFoundError` removed**: Use `PrismaClientKnownRequestError` with code `P2025` instead

### Upgrade command

#### bun

```bash
bun add prisma@6 @prisma/client@6
```

#### pnpm

```bash
pnpm add prisma@6 @prisma/client@6
```

#### yarn

```bash
yarn add prisma@6 @prisma/client@6
```

#### npm

```bash
npm install prisma@6 @prisma/client@6
```

After upgrading, run `prisma migrate dev --name upgrade-to-v6` to apply schema changes for implicit m-n relations.

***

## Upgrading to v5

Prisma ORM v5 introduced the JSON Protocol for improved performance and removed deprecated APIs.

### Key breaking changes

- **Minimum Node.js**: 16.13.0
- **Minimum TypeScript**: 4.7
- **Minimum PostgreSQL**: 9.6
- **`rejectOnNotFound` removed**: Use `findFirstOrThrow()` or `findUniqueOrThrow()` instead
- **Array shortcuts removed**: `OR`, `in`, `notIn`, and `path` now require array values
- **CockroachDB**: Requires `cockroachdb` provider (not `postgresql`)

### Example: Replacing `rejectOnNotFound`

```js
// Before (v4 and earlier)
prisma.user.findFirst({
  where: { name: "Alice" },
  rejectOnNotFound: true,
});

// After (v5+)
prisma.user.findFirstOrThrow({
  where: { name: "Alice" },
});
```

### Example: Array values required

```js
// Before (v4 and earlier)
prisma.user.findMany({
  where: { OR: { email: "foo@example.com" } },
});

// After (v5+)
prisma.user.findMany({
  where: { OR: [{ email: "foo@example.com" }] },
});
```

### Upgrade command

#### bun

```bash
bun add prisma@5 @prisma/client@5
```

#### pnpm

```bash
pnpm add prisma@5 @prisma/client@5
```

#### yarn

```bash
yarn add prisma@5 @prisma/client@5
```

#### npm

```bash
npm install prisma@5 @prisma/client@5
```

***

## Upgrading to v4

Prisma ORM v4 made extended indexes generally available and introduced changes to raw queries and JSON null handling.

### Key breaking changes

- **Minimum Node.js**: 14.17.x
- **Extended indexes GA**: `extendedIndexes` preview feature removed
- **Explicit `@unique` required**: For 1:1 relations
- **Raw query type mapping**: `DateTime` returns `Date`, `Numeric` returns `Decimal`
- **`DbNull`, `JsonNull`, `AnyNull`**: Now objects instead of strings

### Example: JSON null values

```js
// Before (v3 and earlier)
prisma.log.findMany({
  where: { data: { meta: { equals: null } } },
});

// After (v4+)
import { Prisma } from "@prisma/client";
prisma.log.findMany({
  where: { data: { meta: { equals: Prisma.AnyNull } } },
});
```

### Upgrade command

#### bun

```bash
bun add prisma@4 @prisma/client@4
```

#### pnpm

```bash
pnpm add prisma@4 @prisma/client@4
```

#### yarn

```bash
yarn add prisma@4 @prisma/client@4
```

#### npm

```bash
npm install prisma@4 @prisma/client@4
```

After upgrading, run `npx prisma db pull` to retrieve existing index configurations before creating new migrations.

***

## Upgrading to v3

Prisma ORM v3 introduced referential actions and named constraints, with significant changes to cascade delete behavior.

### Key breaking changes

- **Referential actions**: Runtime cascade prevention removed; now handled at database level
- **Named constraints**: New naming convention for constraints and indexes
- **`$queryRaw` changes**: Only supports template literals (use `$queryRawUnsafe` for strings)
- **JSON null types**: Introduced `Prisma.DbNull`, `Prisma.JsonNull`, `Prisma.AnyNull`

### Referential actions

In v2.x, Prisma Client prevented cascading deletes at runtime. In v3+, this is handled by the database. Review your schema's `onDelete` settings:

```prisma
model Post {
  id       Int  @id
  author   User @relation(fields: [authorId], references: [id], onDelete: Cascade)
  authorId Int
}
```

### Named constraints

After upgrading, run `npx prisma db pull` to sync constraint names, or run `npx prisma migrate dev` to update to Prisma's default naming convention.

### Upgrade command

#### bun

```bash
bun add prisma@3 @prisma/client@3
```

#### pnpm

```bash
pnpm add prisma@3 @prisma/client@3
```

#### yarn

```bash
yarn add prisma@3 @prisma/client@3
```

#### npm

```bash
npm install prisma@3 @prisma/client@3
```

***

## Codemods

The `@prisma/codemods` package helps automate code changes when upgrading:

#### bun

```bash
bunx @prisma/codemods <transform> <path>
```

#### pnpm

```bash
pnpm dlx @prisma/codemods <transform> <path>
```

#### yarn

```bash
yarn dlx @prisma/codemods <transform> <path>
```

#### npm

```bash
npx @prisma/codemods <transform> <path>
```

Available transforms:

- `namespace` - Update `@prisma/client` namespace changes
- `findUnique` - Convert `findOne` to `findUnique`
- `to$` - Convert deprecated methods to `$` prefixed versions
- `update-2.12` - Apply all transforms for 2.12 upgrade

See the [codemods repository](https://github.com/prisma/codemods) for more details.

## Related pages

- [`From v1`](/guides/more-4-v6-more-upgrades-from-v1): Upgrading your project from Prisma 1 to Prisma ORM 2 and later
- [`Preview features`](/guides/more-4-v6-more-upgrades-preview-features): Upgrading your project to use a Preview feature.
- [`To v7`](/guides/more-4-v6-more-upgrades-to-v7): Guide on how to upgrade to Prisma ORM 7

## Related pages

- [Authentication & Tools](./authentication-tools-index.md)
- [Build](./build-index.md)
- [Changelog](../changelog.md)
- [Concepts](./concepts-index.md)
- [Console commands](./console-commands-index.md)
- [Contract Authoring](./contract-authoring-index.md)
- [Core Concepts](./core-concepts-index.md)
- [Data Modeling](./data-modeling-index.md)
- [Database](./database-index.md)
- [DB commands](./db-commands-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
