Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/lsp-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"ws": "^8.21.2"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion apps/telemetry-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"evlog": "^2.24.0"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@prisma/compute-sdk": "^0.43.0",
"@prisma/management-api-sdk": "^1.76.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
Expand Down
16 changes: 12 additions & 4 deletions docs/architecture docs/subsystems/7. Migration System.md
Original file line number Diff line number Diff line change
Expand Up @@ -742,22 +742,30 @@ There is no core sandbox-execution verb. An earlier design proposed `migration p

### Removed-verb redirects

The CLI maintains a small lookup table for removed verbs and for the Prisma 7 `migrate` commands, and emits a targeted suggestion when one is invoked. Each redirect also gives a short reason. The reasons for `migrate dev`, `migrate deploy`, `migrate status`, `migrate reset` and `migrate resolve` also say to run the Prisma 7 command with Prisma 7's CLI while Prisma 7 still owns the project's migrations; `migrate diff` does not, because its replacement, `db update --dry-run`, only reads:
The CLI maintains a small lookup table for removed verbs and for the Prisma 7 commands the ORM owns, and emits a targeted suggestion when one is invoked. Each redirect also gives a short reason. Every Prisma 7 command's reason ends with how to install Prisma 7's CLI (`npm install --save-dev @prisma/prisma7@7`) and run the command with it, as a command line that runs once its placeholders are filled in: `prisma7 <path>`, with a placeholder for every value Prisma 7 requires, such as `prisma7 migrate resolve --applied <migration>`, `prisma7 db execute --file <path>` and `prisma7 migrate diff --from-config-datasource --to-schema <path>`. For `migrate dev`, `migrate deploy`, `migrate status`, `migrate reset` and `migrate resolve` that sentence applies while Prisma 7 still owns the project's migrations. `migrate diff` gives it without the condition, because its replacement, `db update --dry-run`, only reads; the other Prisma 7 commands give it without the condition too:

| Old invocation | Replacement |
|---|---|
| `prisma migration apply` (with or without flags) | `prisma db migrate --to <contract>` |
| `prisma migration status` with `--graph` | `prisma migration graph` |
| `prisma migration status` with `--all` or `--limit` | `prisma migration log --db <url>` |
| `prisma migration status` with `--ref X` | `prisma migration status --to X` |
| `prisma migrate dev` (Prisma 7) | `prisma contract emit`; the reason names the next steps, `migration plan --name <name>` and `db migrate --advance-ref db` |
| `prisma migrate dev` (Prisma 7) | three steps: `prisma contract emit`, `prisma migration plan --name <name>`, then `prisma db migrate --advance-ref db` |
| `prisma migrate deploy` (Prisma 7) | `prisma db migrate` |
| `prisma migrate status` (Prisma 7) | `prisma migration status` |
| `prisma migrate diff` (Prisma 7) | `prisma db update --dry-run`, which applies nothing; the reason names `migration plan` for a migration package |
| `prisma migrate reset` (Prisma 7) | `prisma db update`; the reason says Prisma 8 has no reset, and that a database that changes only through migrations is moved with `db migrate` instead |
| `prisma migrate resolve` (Prisma 7) | `prisma db sign <migration>` (moves the marker; `migration status` shows no applied mark) |

The table lives in [`family.ts`](../../../packages/1-framework/3-tooling/cli/src/orm/family.ts). The CLI engine intercepts each retired invocation before it runs, exits `2` with `CLI.COMMAND_MOVED`, and names the replacement as a next action, with the shell's own binary name in place of `prisma`.
| `prisma generate` (Prisma 7) | `prisma contract emit` |
| `prisma validate` (Prisma 7) | none; the CLI docs, and the reason says `contract emit` reports an invalid schema |
| `prisma format` (Prisma 7) | `prisma contract format` |
| `prisma studio` (Prisma 7) | none; the CLI docs |
| `prisma db pull` (Prisma 7) | `prisma contract infer` |
| `prisma db push` (Prisma 7) | `prisma db update`; the reason names `db init` for a new database |
| `prisma db seed` (Prisma 7) | none; the CLI docs |
| `prisma db execute` (Prisma 7) | none; the CLI docs |

The table is in [`family.ts`](../../../packages/1-framework/3-tooling/cli/src/orm/family.ts). The CLI engine intercepts each retired invocation before it runs, exits `2` with `CLI.COMMAND_MOVED` for a removed verb or `CLI.V7_COMMAND` for a Prisma 7 command, and names the replacement as a next action, with the shell's own binary name in place of `prisma`. A Prisma 7 command also names the replacement's `--help`, or links the CLI docs when it has no replacement.

### `--advance-ref` flag family

Expand Down
4 changes: 4 additions & 0 deletions docs/reference/error-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ Catch-all for an unanticipated failure inside a CLI command: an unclassified exc

The migration-file CLI (`prisma migration`) received a flag it does not recognise; wraps clipanion's unknown-syntax error at the parser boundary so consumers can build "did you mean" suggestions from meta instead of parsing the message. Payload: `flag`, `knownFlags`.

### CLI.V7_COMMAND

Settled by `@prisma/cli-engine` from the redirect table in `family.ts`, not raised by a command: the user typed a Prisma 7 command path that Prisma 8 does not have, such as `prisma generate`, `prisma db push` or `prisma migrate dev`; instead of failing as unknown, the run settles with the summary "`prisma <path>` is a Prisma 7 command and is not available in Prisma 8". `why` says what the suggested Prisma 8 commands do and what they do not cover, and ends with how to install Prisma 7's CLI (`npm install --save-dev @prisma/prisma7@7`) and run the same command as `prisma7 <path>`, with a placeholder for every value Prisma 7 requires (for example `prisma7 db execute --file <path>`); for the `migrate` commands except `migrate diff`, that sentence applies while Prisma 7 still owns the project's migrations. Next actions, in order: the replacement commands as run-command actions (labelled "Use the replacement" for one, "Step 1", "Step 2", … for several), a run-command pointing at the suggested command's `--help`, and an open-url action to the CLI docs when Prisma 8 has no equivalent. The engine's entry is the reference: [CLI.V7_COMMAND](https://docs.prisma.io/docs/cli/error-reference#CLI.V7_COMMAND). Exits 2. Payload: none.

## CONTRACT

### CONTRACT.ARGUMENT_INVALID
Expand Down
2 changes: 1 addition & 1 deletion examples/bundle-size/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"pg": "catalog:"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@prisma/dev": "catalog:",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/test-utils": "workspace:8.0.0-rc.23",
Expand Down
2 changes: 1 addition & 1 deletion examples/mongo-blog-leaderboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"mongodb": "catalog:"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/mongo-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"react-dom": "^19.2.8"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/test-utils": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-extension-monorepo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@prisma/orm-postgres": "workspace:8.0.0-rc.23"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/test-utils": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
Expand Down
2 changes: 1 addition & 1 deletion examples/paradedb-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"pg": "catalog:"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/test-utils": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma-8-cloudflare-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"devDependencies": {
"@cloudflare/vitest-pool-workers": "0.20.3",
"@cloudflare/workers-types": "5.20260804.1",
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma-8-demo-mariadb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@prisma/orm-mariadb": "workspace:8.0.0-rc.23"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma-8-demo-mysql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@prisma/orm-mysql": "workspace:8.0.0-rc.23"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma-8-demo-sqlite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dotenv": "^17.4.2"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma-8-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"react-dom": "^19.2.8"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@prisma/dev": "catalog:",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/test-utils": "workspace:8.0.0-rc.23",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma-8-postgis-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"react-leaflet": "^5.0.0"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/test-utils": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma7-adoption/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"pg": "catalog:"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@prisma/dev": "catalog:",
"@prisma/prisma7": "7.10.0",
"@repo/test-utils": "workspace:8.0.0-rc.23",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-router-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"react-router": "^8.1.0"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@prisma/dev": "catalog:",
"@react-router/dev": "^8.1.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
Expand Down
2 changes: 1 addition & 1 deletion examples/retail-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"tailwindcss": "^4.3.3"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/test-utils": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
Expand Down
2 changes: 1 addition & 1 deletion examples/supabase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"pg": "catalog:"
},
"devDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/prisma-bin": "workspace:8.0.0-rc.23",
"@repo/test-utils": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
Expand Down
4 changes: 2 additions & 2 deletions packages/1-framework/3-tooling/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@internal/sql-contract-ts": "workspace:8.0.0-rc.23",
"@internal/sql-operations": "workspace:8.0.0-rc.23",
"@internal/sql-runtime": "workspace:8.0.0-rc.23",
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"@repo/test-utils": "workspace:8.0.0-rc.23",
"@repo/tsconfig": "workspace:8.0.0-rc.23",
"@repo/tsdown": "workspace:8.0.0-rc.23",
Expand All @@ -62,7 +62,7 @@
"vitest": "catalog:"
},
"peerDependencies": {
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"typescript": ">=5.9"
},
"peerDependenciesMeta": {
Expand Down
131 changes: 104 additions & 27 deletions packages/1-framework/3-tooling/cli/src/orm/family.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,34 @@ const commands: Readonly<Record<string, AnyCommand>> = {
'orm init': initCommand,
};

const CLI_DOCS_URL = 'https://www.prisma.io/docs/cli';

const PRISMA_7_INSTALL = 'install its CLI with `npm install --save-dev @prisma/prisma7@7`';

function v7Command(
from: string,
entry: Omit<RedirectSpec, 'from' | 'flag' | 'code' | 'summary' | 'reason'> & {
readonly reason: string;
readonly whileMigrationsStayOnPrisma7?: boolean;
readonly prisma7Invocation?: string;
},
): RedirectSpec {
const { whileMigrationsStayOnPrisma7, prisma7Invocation, reason, ...rest } = entry;
const invocation = `prisma7 ${prisma7Invocation ?? from}`;
const prisma7 = whileMigrationsStayOnPrisma7
? `While Prisma 7 still owns this project's migrations, ${PRISMA_7_INSTALL} and run \`${invocation}\` instead.`
: `To keep using Prisma 7, ${PRISMA_7_INSTALL} and run \`${invocation}\`.`;
return {
from,
code: 'CLI.V7_COMMAND',
summary: `\`{bin} ${from}\` is a Prisma 7 command and is not available in Prisma 8`,
reason: `${reason} ${prisma7}`,
...rest,
};
}

/**
* The invocations the ORM retired, and the Prisma 7 `migrate` commands, so an old command line gets the replacement rather than a spelling suggestion. Replacements name the binary as `{bin}`; the engine substitutes the shell's own name.
* The invocations the ORM retired, and the Prisma 7 commands, so an old command line gets the replacement or a link to the docs rather than a spelling suggestion. Replacements name the binary as `{bin}`; the engine substitutes the shell's own name.
*
* The four flag redirects name `migration status`, which the engine requires to be a mounted command.
*/
Expand Down Expand Up @@ -93,42 +119,93 @@ const redirects: readonly RedirectSpec[] = [
replacement: '{bin} migration status --to <contract>',
reason: 'One flag names the target contract, whether it is a ref, a hash or a migration.',
},
{
from: 'migrate dev',
replacement: '{bin} contract emit',
v7Command('migrate dev', {
replacement: [
'{bin} contract emit',
'{bin} migration plan --name <name>',
'{bin} db migrate --advance-ref db',
],
reason:
"Prisma 8 emits the contract, plans the migration and applies it in separate steps: run `contract emit`, then `migration plan --name <name>` (for `--create-only`, stop here), then `db migrate --advance-ref db`; while Prisma 7 still owns this project's migrations, run `migrate dev` with Prisma 7's CLI instead.",
},
{
from: 'migrate deploy',
'Prisma 8 emits the contract, plans the migration and applies it in separate steps: run `contract emit`, then `migration plan --name <name>` (for `--create-only`, stop here), then `db migrate --advance-ref db`.',
whileMigrationsStayOnPrisma7: true,
help: 'contract emit',
}),
v7Command('migrate deploy', {
replacement: '{bin} db migrate',
reason:
"`db migrate` applies the planned migrations; while Prisma 7 still owns this project's migrations, run `migrate deploy` with Prisma 7's CLI instead.",
},
{
from: 'migrate status',
reason: '`db migrate` applies the planned migrations.',
whileMigrationsStayOnPrisma7: true,
help: 'db migrate',
}),
v7Command('migrate status', {
replacement: '{bin} migration status',
reason:
"`migration status` reports which planned migrations the database has applied; while Prisma 7 still owns this project's migrations, run `migrate status` with Prisma 7's CLI instead.",
},
{
from: 'migrate diff',
reason: '`migration status` reports which planned migrations the database has applied.',
whileMigrationsStayOnPrisma7: true,
help: 'migration status',
}),
v7Command('migrate diff', {
replacement: '{bin} db update --dry-run',
reason:
'`db update --dry-run` prints the changes between the contract and a live database without applying them; to write the changes between two contracts as a migration package use `migration plan`, and to report drift use `db verify`.',
},
{
from: 'migrate reset',
prisma7Invocation: 'migrate diff --from-config-datasource --to-schema <path>',
help: 'db update',
}),
v7Command('migrate reset', {
replacement: '{bin} db update',
reason:
"Prisma 8 has no reset: `db update` moves the database to the contract without a reset and asks before losing data, on a database whose migration history does not need to be kept; a database that changes only through migrations is moved with `db migrate`; while Prisma 7 still owns this project's migrations, run `migrate reset` with Prisma 7's CLI instead.",
},
{
from: 'migrate resolve',
'Prisma 8 has no reset: `db update` moves the database to the contract without a reset and asks before losing data, on a database whose migration history does not need to be kept; a database that changes only through migrations is moved with `db migrate`.',
whileMigrationsStayOnPrisma7: true,
help: 'db update',
}),
v7Command('migrate resolve', {
replacement: '{bin} db sign <migration>',
reason:
"`db sign <migration>` checks that the database already has that migration's schema and moves the database marker to that migration's contract, so `db migrate` continues after it; `migration status` does not list the migration as applied. Use it where you would run `migrate resolve --applied` after applying a migration's changes by hand. While Prisma 7 still owns this project's migrations, run `migrate resolve` with Prisma 7's CLI instead.",
},
"`db sign <migration>` checks that the database already has that migration's schema and moves the database marker to that migration's contract, so `db migrate` continues after it; `migration status` does not list the migration as applied. Use it where you would run `migrate resolve --applied` after applying a migration's changes by hand.",
whileMigrationsStayOnPrisma7: true,
prisma7Invocation: 'migrate resolve --applied <migration>',
help: 'db sign',
}),
v7Command('generate', {
replacement: '{bin} contract emit',
help: 'contract emit',
reason:
'Prisma 8 has no client generation step. `contract emit` reads your schema and writes contract.json and contract.d.ts, the contract files the ORM reads to know your data model and its types.',
}),
v7Command('validate', {
docsUrl: CLI_DOCS_URL,
reason:
'Prisma 8 has no separate validate command. `contract emit` reports an invalid schema when it runs, and writes the contract files when the schema is valid.',
}),
v7Command('format', {
replacement: '{bin} contract format',
help: 'contract format',
reason:
'`contract format` formats the PSL schema files your prisma.config.ts names as the contract source, in place. It leaves a schema written in TypeScript untouched.',
}),
v7Command('studio', {
docsUrl: CLI_DOCS_URL,
reason: 'Prisma 8 has no Studio command for browsing and editing your data in a browser.',
}),
v7Command('db pull', {
replacement: '{bin} contract infer',
help: 'contract infer',
reason:
'`contract infer` reads the live database, named with `--db <url>`, and writes its schema as a PSL contract file. Run `contract emit` afterwards to write the contract files the ORM reads, then `db sign` to record that the database matches the contract, so queries can run against it.',
}),
v7Command('db push', {
replacement: '{bin} db update',
help: 'db update',
reason:
'`db update` changes the database to match the contract directly, without migration files, and asks before any change that would lose data. On a new database, `db init` creates what the contract declares and never removes or changes anything already there. Both read the contract files `contract emit` writes, so run `contract emit` after changing the schema.',
}),
v7Command('db seed', {
docsUrl: CLI_DOCS_URL,
reason: 'Prisma 8 has no seed command. Run your seed script directly, for example with node.',
}),
v7Command('db execute', {
docsUrl: CLI_DOCS_URL,
prisma7Invocation: 'db execute --file <path>',
reason: 'Prisma 8 has no command that runs a script file of statements against the database.',
}),
];

/**
Expand Down
Loading
Loading