@prisma/orm-mongo 8.0.1-dev.2 → 8.0.1-dev.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/contract-builder.d.mts +10 -12
- package/dist/contract-builder.d.mts.map +1 -1
- package/dist/contract-types.d.mts +3 -3
- package/dist/init-quick-reference.md +1 -1
- package/dist/{mongo-static-BrplLPTr-DGOk19X8.mjs → mongo-static-JFa7nOlW-B0ToYN9K.mjs} +4 -4
- package/dist/mongo-static-JFa7nOlW-B0ToYN9K.mjs.map +1 -0
- package/dist/runtime.d.mts +2 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +6 -6
- package/dist/runtime.mjs.map +1 -1
- package/dist/static.mjs +1 -1
- package/package.json +12 -81
- package/skills/prisma-8/SKILL.md +2 -2
- package/skills/prisma-8/references/contract.md +6 -6
- package/skills/prisma-8/references/debug.md +1 -1
- package/skills/prisma-8/references/migration-review.md +1 -1
- package/skills/prisma-8/references/migrations.md +8 -6
- package/skills/prisma-8/references/queries-postgres.md +2 -2
- package/skills/prisma-8/references/quickstart.md +1 -1
- package/skills/prisma-8/references/supabase.md +2 -2
- package/skills/prisma-8/references/upgrade-app.md +54 -17
- package/skills/prisma-8/references/upgrade-extension.md +34 -11
- package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/instructions.md +1 -1
- package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/instructions.md +1 -1
- package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/instructions.md +1 -1
- package/dist/adapter.d.mts +0 -1
- package/dist/adapter.mjs +0 -2
- package/dist/adapter__control.d.mts +0 -3
- package/dist/adapter__control.mjs +0 -3
- package/dist/adapter__runtime.d.mts +0 -3
- package/dist/adapter__runtime.mjs +0 -3
- package/dist/components.d.mts +0 -1
- package/dist/components.mjs +0 -2
- package/dist/components__authoring.d.mts +0 -1
- package/dist/components__authoring.mjs +0 -2
- package/dist/components__codec.d.mts +0 -1
- package/dist/components__codec.mjs +0 -2
- package/dist/components__components.d.mts +0 -1
- package/dist/components__components.mjs +0 -2
- package/dist/components__control.d.mts +0 -1
- package/dist/components__control.mjs +0 -2
- package/dist/components__emission.d.mts +0 -1
- package/dist/components__emission.mjs +0 -2
- package/dist/components__execution.d.mts +0 -1
- package/dist/components__execution.mjs +0 -2
- package/dist/components__ir.d.mts +0 -1
- package/dist/components__ir.mjs +0 -2
- package/dist/components__psl-ast.d.mts +0 -1
- package/dist/components__psl-ast.mjs +0 -2
- package/dist/components__utils.d.mts +0 -1
- package/dist/components__utils.mjs +0 -2
- package/dist/contract.d.mts +0 -1
- package/dist/contract.mjs +0 -2
- package/dist/contract__apply-specifier-default-control-policy.d.mts +0 -1
- package/dist/contract__apply-specifier-default-control-policy.mjs +0 -2
- package/dist/contract__contract-validation-error.d.mts +0 -1
- package/dist/contract__contract-validation-error.mjs +0 -2
- package/dist/contract__default-namespace.d.mts +0 -1
- package/dist/contract__default-namespace.mjs +0 -2
- package/dist/contract__enum-accessor.d.mts +0 -1
- package/dist/contract__enum-accessor.mjs +0 -2
- package/dist/contract__format-version.d.mts +0 -1
- package/dist/contract__format-version.mjs +0 -2
- package/dist/contract__hashing-utils.d.mts +0 -1
- package/dist/contract__hashing-utils.mjs +0 -2
- package/dist/contract__hashing.d.mts +0 -1
- package/dist/contract__hashing.mjs +0 -2
- package/dist/contract__internal__format-version.d.mts +0 -1
- package/dist/contract__internal__format-version.mjs +0 -2
- package/dist/contract__is-plain-record.d.mts +0 -1
- package/dist/contract__is-plain-record.mjs +0 -2
- package/dist/contract__resolve-domain-model.d.mts +0 -1
- package/dist/contract__resolve-domain-model.mjs +0 -2
- package/dist/contract__validate-domain.d.mts +0 -1
- package/dist/contract__validate-domain.mjs +0 -2
- package/dist/contract__validate-once.d.mts +0 -1
- package/dist/contract__validate-once.mjs +0 -2
- package/dist/contract__validate-storage.d.mts +0 -1
- package/dist/contract__validate-storage.mjs +0 -2
- package/dist/driver.d.mts +0 -1
- package/dist/driver.mjs +0 -2
- package/dist/driver__control.d.mts +0 -3
- package/dist/driver__control.mjs +0 -3
- package/dist/driver__runtime.d.mts +0 -3
- package/dist/driver__runtime.mjs +0 -3
- package/dist/family-contract__canonicalization-hooks.d.mts +0 -1
- package/dist/family-contract__canonicalization-hooks.mjs +0 -2
- package/dist/family-contract__data-type.d.mts +0 -1
- package/dist/family-contract__data-type.mjs +0 -2
- package/dist/family-contract__entity-kinds.d.mts +0 -1
- package/dist/family-contract__entity-kinds.mjs +0 -2
- package/dist/family__control-adapter.d.mts +0 -1
- package/dist/family__control-adapter.mjs +0 -2
- package/dist/family__ir.d.mts +0 -1
- package/dist/family__ir.mjs +0 -2
- package/dist/family__migration.d.mts +0 -1
- package/dist/family__migration.mjs +0 -2
- package/dist/family__pack.d.mts +0 -3
- package/dist/family__pack.mjs +0 -3
- package/dist/family__runtime.d.mts +0 -1
- package/dist/family__runtime.mjs +0 -2
- package/dist/family__schema-verify.d.mts +0 -1
- package/dist/family__schema-verify.mjs +0 -2
- package/dist/migration-tools__contract-snapshot-store.d.mts +0 -1
- package/dist/migration-tools__contract-snapshot-store.mjs +0 -2
- package/dist/mongo-static-BrplLPTr-DGOk19X8.mjs.map +0 -1
- package/dist/query-ast.d.mts +0 -1
- package/dist/query-ast.mjs +0 -2
- package/dist/query-ast__control.d.mts +0 -1
- package/dist/query-ast__control.mjs +0 -2
- package/dist/query-builder__contract-free.d.mts +0 -1
- package/dist/query-builder__contract-free.mjs +0 -2
- package/dist/target__codecs.d.mts +0 -1
- package/dist/target__codecs.mjs +0 -2
- package/dist/target__control.d.mts +0 -1
- package/dist/target__control.mjs +0 -2
- package/dist/target__data-types.d.mts +0 -1
- package/dist/target__data-types.mjs +0 -2
- package/dist/target__pack.d.mts +0 -3
- package/dist/target__pack.mjs +0 -3
- package/dist/target__server-version.d.mts +0 -1
- package/dist/target__server-version.mjs +0 -2
- package/dist/utils.d.mts +0 -1
- package/dist/utils.mjs +0 -2
- package/dist/utils__abortable.d.mts +0 -1
- package/dist/utils__abortable.mjs +0 -2
- package/dist/utils__array-equal.d.mts +0 -1
- package/dist/utils__array-equal.mjs +0 -2
- package/dist/utils__assertions.d.mts +0 -1
- package/dist/utils__assertions.mjs +0 -2
- package/dist/utils__canonical-stringify.d.mts +0 -1
- package/dist/utils__canonical-stringify.mjs +0 -2
- package/dist/utils__casts.d.mts +0 -1
- package/dist/utils__casts.mjs +0 -2
- package/dist/utils__defined.d.mts +0 -1
- package/dist/utils__defined.mjs +0 -2
- package/dist/utils__guards.d.mts +0 -1
- package/dist/utils__guards.mjs +0 -2
- package/dist/utils__hash-content.d.mts +0 -1
- package/dist/utils__hash-content.mjs +0 -2
- package/dist/utils__internal-error.d.mts +0 -1
- package/dist/utils__internal-error.mjs +0 -2
- package/dist/utils__json.d.mts +0 -1
- package/dist/utils__json.mjs +0 -2
- package/dist/utils__promise.d.mts +0 -1
- package/dist/utils__promise.mjs +0 -2
- package/dist/utils__redact-db-url.d.mts +0 -1
- package/dist/utils__redact-db-url.mjs +0 -2
- package/dist/utils__result.d.mts +0 -1
- package/dist/utils__result.mjs +0 -2
- package/dist/utils__simplify-deep.d.mts +0 -1
- package/dist/utils__simplify-deep.mjs +0 -2
- package/dist/utils__structured-error.d.mts +0 -1
- package/dist/utils__structured-error.mjs +0 -2
- package/dist/utils__suppress-idle-connection-errors.d.mts +0 -1
- package/dist/utils__suppress-idle-connection-errors.mjs +0 -2
- package/dist/utils__text.d.mts +0 -1
- package/dist/utils__text.mjs +0 -2
- package/dist/utils__types.d.mts +0 -1
- package/dist/utils__types.mjs +0 -2
- package/dist/utils__upgrade-guides.d.mts +0 -1
- package/dist/utils__upgrade-guides.mjs +0 -2
- package/dist/value__mongodb-types.d.mts +0 -1
- package/dist/value__mongodb-types.mjs +0 -2
|
@@ -45,10 +45,10 @@ Once the contract changes, you choose how the change reaches the database. This
|
|
|
45
45
|
- **`this.dataTransform(contract, name, { check, run })`.** The Postgres data-transform factory. `check` is a rowset query whose presence-of-any-row signals "work remains"; `run` is one or more mutation queries that perform the backfill. Both are lazy closures returning query plans built with the SQL query builder over the end contract. `contract` is the `contract` that `postgres({ contract: contractFromJson<End>(endContract) })` returns, not the imported `endContract` JSON the planner renders (see *Fill a placeholder*). The runner wraps `check` as `EXISTS(...)` for precheck and `NOT EXISTS(...)` for postcheck, so the same closure asserts both "there is work" and "the work is done".
|
|
46
46
|
- **`pendingPlaceholders`.** A boolean field on the JSON result of `migration plan`. `true` means the package was written but contains unfilled placeholders — `db migrate` will throw `MIGRATION.UNFILLED_PLACEHOLDER` until you edit `migration.ts` and self-emit.
|
|
47
47
|
- **`migrationHash`.** Content-addressed identity of a migration package. `MIGRATION.HASH_MISMATCH` fires when the stored hash in `migration.json` disagrees with the hash recomputed from the on-disk files (almost always: someone edited `migration.ts` without self-emitting).
|
|
48
|
-
- **Marker.** Records "this database is at contract hash X for space Y". **Postgres:** a row in `
|
|
48
|
+
- **Marker.** Records "this database is at contract hash X for space Y". **Postgres:** a row in `prisma.signatures`. **Mongo:** a document in the `_prisma_migrations` collection (keyed by space). Each successful migration advances the marker once schema verification passes for that space. `db sign` writes the marker from the current contract hash, but only after a schema-verification pass succeeds (it will not sign a database whose live schema disagrees with the contract).
|
|
49
49
|
- **Apply atomicity.** **Postgres:** one `db migrate` run is one transaction — the runner issues a single `BEGIN`, applies every pending migration for every contract space, then one `COMMIT`; any failure issues `ROLLBACK` for the whole run, so the marker stays where it was before the command. **Mongo:** DDL ops (`createCollection`, `createIndex`, `collMod`, `setValidation`, …) are not wrapped in a multi-document transaction; the runner applies ops, verifies the live schema against the destination contract, and advances the marker only on verify-pass (resumable across spaces — see the MongoDB family doc). Ordinary DDL + `dataTransform` flows stay consistent; partial state from failed mid-migration runs is diagnosed with `db verify` / `db schema`, not assumed away.
|
|
50
50
|
- **Changed foreign key actions and primary keys (Postgres).** A changed `onDelete`/`onUpdate` plans a drop and an add of the foreign key. A moved or removed primary key plans a drop (and an add), and the foreign keys that reference the old key are dropped first and added back after it. These ask no data-loss question.
|
|
51
|
-
- **Policies.** A database records
|
|
51
|
+
- **Policies.** A database records how it may be changed (**Postgres:** in the one row of `prisma.config`; **Mongo** and the other SQL targets: in the application space's marker, under `meta.policies`): its *change policy* (`migrate`, `reconcile` or both; `reconcile` is what `db update` and `db sign` do) and its *data protection policy* (`dataLoss` and `accessWidening`, each `forbidden`, `with-consent` or `permitted`). Every command that changes a database obeys both. A ref declares the policies its database should have in a `policies` field. See *Policies: what a database says about how it may change* below.
|
|
52
52
|
- **Operation classes.** Every operation declares an `operationClass`: `additive`, `widening`, `data`, or `destructive`. `additive` adds structure and leaves existing structure and data as they are. `widening` changes existing structure without losing data; an operation that cannot keep every value fails instead, so a tightened constraint such as `SET NOT NULL` is widening. `destructive` can lose rows or values: dropping a table or column, or a type change that can change values. `data` reads and writes rows as its author wrote them, such as a backfill or a type conversion; a `dataTransform` is always `data`. Each operation factory sets its own class (`this.alterColumnType` is `data` with `using` and `destructive` without it, unless you pass `operationClass`). A `rawSql` step you write takes the class of the factory that would express it, or the class the definitions above give. The CLI surfaces these in the plan preview and in JSON output. There is no `long-running` class and the framework does not emit `CREATE INDEX CONCURRENTLY` — operations stay transactional.
|
|
53
53
|
|
|
54
54
|
## `migration.ts` is framework-rendered, not hand-authored
|
|
@@ -77,7 +77,9 @@ Treat the rendered import lines as framework-managed on both targets:
|
|
|
77
77
|
| `CLI.CONSENT_REQUIRED` | `migration plan` / `db update` run with nobody to answer (`--no-interactive`, CI, `--yes`) | The plan would lose data or (on `db update`) widen access. `meta.unanswered` and `nextActions` list each question with the flags that answer it: `--delete <subject>`, `--rename <subject>:<new name>`, `--allow <Model>`. Re-run with the ones you mean. `--confirm` and `--yes` answer none of them. |
|
|
78
78
|
| `CLI.CONSENT_UNUSED` | `migration plan` / `db update` | Every question was answered, and a `--delete` or `--allow` was left over: a typo, a subject the plan does not touch, or a `--confirm` (which consents to nothing). Fix or drop the flag. A typo next to a question nobody answered is reported as `CLI.CONSENT_REQUIRED` instead, which names the flag that matched nothing. On `db update --dry-run` the same mistake is `MIGRATION.STATEMENT_ANSWERS_NO_QUESTION`. |
|
|
79
79
|
| `MIGRATION.STATEMENT_DID_NOT_RESOLVE_LOSS` | A rename typed at the data-loss prompt | The plan was made again with the rename and still loses the subject's data. Answer with `delete`, or give a rename whose old name is the subject. |
|
|
80
|
-
| `CONTRACT.MARKER_MISMATCH` | `db verify` (finding, exit 4) | The marker disagrees with the contract hash (**Postgres:** `
|
|
80
|
+
| `CONTRACT.MARKER_MISMATCH` | `db verify` (finding, exit 4) | The marker disagrees with the contract hash (**Postgres:** `prisma.signatures`; **Mongo:** `_prisma_migrations`). The DB is at a different contract version than the code thinks. Either run a migration forward, or — if the DB is correct and the marker is stale after a manual fix-up — run `db sign`. |
|
|
81
|
+
| `CONTRACT.PRISMA_SPACE_BEHIND` | `db verify`, `migration status`, `migration log`, dry runs; the client's first query (a warning, only when the client is given a `log`) | The records Prisma keeps for itself in the database are not up to date with the installed release, for example a database a release candidate set up, whose tables are in `prisma_contract`. Run the command the project already uses to change its database: `prisma db migrate` with migrations, `prisma db update` with `db update`, or `prisma db sign` if it only signs. Each brings the records up to date before its usual work. Then run the read again. |
|
|
82
|
+
| `MIGRATION.INSTALLED_SPACE_UNREACHABLE` | `db init`, `db update`, `db migrate`, `db sign`, `db verify` | The records Prisma keeps for itself were changed by a release this one cannot follow: `meta.reason` is `laterMajor` when a later major version of Prisma changed them, `unknownContract` otherwise. Use the release that last changed the database, or a newer one. Do not edit them by hand. |
|
|
81
83
|
| `CONTRACT.MARKER_MISSING` | `db verify` (finding, exit 4), runtime startup (warning) | The DB has no marker yet. Run `prisma db init --db <url>` to baseline an empty database, `db update --db <url>` to apply the current contract directly, or `db sign --db <url>` if the schema already matches the contract. |
|
|
82
84
|
| `MIGRATION.STATEMENT_INVALID` | `migration plan` / `db update` with `--rename` | The statement is malformed, mixes a model and a field, renames something to itself, swaps two names, or repeats a name. The error's next step is the statement to type instead; use it. |
|
|
83
85
|
| `MIGRATION.STATEMENT_UNRESOLVED` | `migration plan` / `db update` with `--rename` | A name is not where a rename needs it. The error lists the names it found and says what to type: the statement the right way round, the order that works, or to leave out a rename that has already happened. |
|
|
@@ -424,7 +426,7 @@ Postgres and SQLite first; MongoDB below. `migration plan` cannot see rows, so t
|
|
|
424
426
|
- **An optional field made required** is tightened directly. If rows hold NULL, the apply fails and counts them (`3 rows of "Item" hold NULL in "note", so it cannot become required.`); set the values and re-run, or plan with `--backfill`.
|
|
425
427
|
- **On MongoDB** the same questions are asked about the documents. A validator change (`collMod(..., { ..., checkDocuments: true })`) checks the documents as its own precheck, after the plan's rewrites, and stops while one does not fit; operations that ran before it stay applied, and a re-run skips them. To apply a validator over documents that do not fit, set `checkDocuments: false` on its `collMod` in `migration.ts`. `--delete User.age` casts with `$convert` (`castField`), only where the result keeps what the values mean: `String` to `Boolean` or `DateTime` to `Int` offer `--convert` only; a cast that keeps every value, such as `Int` to `BigInt`, asks nothing. `--convert User.age` and `--backfill User.plan` write `dataTransform('User.age', { check, run })` with the filter written and the update as `placeholder('User.age:update')`, which you replace with an update document (`{ $set: { … } }`) or an aggregation pipeline (`[{ $set: { age: { $toInt: '$age' } } }]`); the `run` uses `rawUpdateMany(..., { bypassDocumentValidation: true })`, and a hand-written one must skip validation too. A new required field gets a temporary value (`fillField`), unless it has a unique index or its type has none, such as a date, or it is a variant's discriminator, since no temporary value names a variant. A discriminator renamed without `--rename` is refused, and the refusal gives the `--rename` to pass; a model's first discriminator is left to the document check. On a collection with documents, such a field stops the apply: a unique one at its index build, where the documents that lack it all hold `null`, and any other at the validator change's document check. Both errors name `--backfill`, so use it. A required field of a variant new to the collection, such as `Bug.severity` when `Task` gains its first discriminator, has no documents to backfill yet: set it in the update you write for `--backfill Task.type`, or keep it optional until a later change. A field that gains an enum or changes type inside a value object is not a statement: the plan warns, and you add a `dataTransform` before the validator change.
|
|
426
428
|
- **Adopting a Prisma 6 MongoDB database.** A Prisma 6 database has no validator, and the first Prisma 8 plan adds one, which checks the documents first. If documents do not fit, the apply stops and names what the change touches, one `_id`, and the `mongosh` query that finds the rest. The error says why the document it shows does not fit, such as a field the new validator does not name. Fix those documents and run the command again; a plain update works, since the collection has no validator yet. Or, under `db migrate`, apply the validator over them: set `checkDocuments: false` on that `collMod` in `migration.ts`, run the file with `node`, and run `db migrate` again; they then fail their next update until they fit.
|
|
427
|
-
- **Following failure advice under `db migrate`:** the migration is already written, so the error says to copy any code you wrote in its `migration.ts`, delete its directory, and run the printed `migration plan --from <hash> --name <name> …` command, which keeps the migration's name, together with the other statements you planned it with. Paths in the advice are relative to the directory the command ran from, and the commands it prints repeat the `--config` it was given, so each runs as printed from there.
|
|
429
|
+
- **Following failure advice under `db migrate`:** the migration is already written, so the error says to copy any code you wrote in its `migration.ts`, delete its directory, and run the printed `migration plan --from <hash> --name <name> …` command, which keeps the migration's name, together with the other statements you planned it with. Paths in the advice are relative to the directory the command ran from, and the commands it prints repeat the `--config` it was given, so each runs as printed from there. A printed command that connects to a database carries `--db <url>` when the run was given `--db`, or when `db.connection` in `prisma.config.ts` has no value (for example, its environment variable is not set): replace `<url>` with the database's URL.
|
|
428
430
|
|
|
429
431
|
## Workflow — Author a migration by hand
|
|
430
432
|
|
|
@@ -493,7 +495,7 @@ pnpm prisma db verify --db $DATABASE_URL
|
|
|
493
495
|
|
|
494
496
|
## Policies: what a database says about how it may change
|
|
495
497
|
|
|
496
|
-
Every database records two policies
|
|
498
|
+
Every database records two policies, and every command obeys them. On Postgres they are in `prisma.config`; on the other targets they are in the application space's marker. Read them from the error that refuses you, or with `prisma migration status --to <ref> --db <url>`, which reports where the ref's declared policies differ from the database's.
|
|
497
499
|
|
|
498
500
|
**Change policy.** The strategies the database may be changed by:
|
|
499
501
|
|
|
@@ -552,7 +554,7 @@ Write the field by hand, or with the `migration ref policy` commands, which chan
|
|
|
552
554
|
|
|
553
555
|
No other command changes a ref's policies. Commands that rewrite a ref (`migration ref set`, `db update`, `db sign`, `db migrate`, and the `migration ref policy` commands) keep the `hash`, `invariants` and `policies` they do not change, and write `formatVersion` themselves. A ref file with any other field is refused with `MIGRATION.INVALID_REF_FILE`, and the file is left as it was: remove the field by hand.
|
|
554
556
|
|
|
555
|
-
**Applying a declared policy.** `db migrate --to <ref>` and `db update --to <ref>` compare the ref's declarations with the database before running anything. If they differ, the command fails with `MIGRATION.POLICY_MISMATCH` and nothing runs. The database's policy changes only when the deploy is told it may: `prisma db migrate --to production --permit-policy-change --db <url>`. The run is checked against the ref's policies, runs, and
|
|
557
|
+
**Applying a declared policy.** `db migrate --to <ref>` and `db update --to <ref>` compare the ref's declarations with the database before running anything. If they differ, the command fails with `MIGRATION.POLICY_MISMATCH` and nothing runs. The database's policy changes only when the deploy is told it may: `prisma db migrate --to production --permit-policy-change --db <url>`. The run is checked against the ref's policies, runs, and records them in the database (on Postgres in `prisma.config`, elsewhere in the marker) when it succeeds, so a failed run leaves the old policy. With nothing pending, the run writes only the policies. A pipeline that should apply reviewed policy changes passes the flag on every deploy; a cautious team leaves it out and applies policy changes by hand. The flag needs `--to <ref>`: with a hash, `@db`, `@empty` or no `--to`, the command fails with `CLI.INVALID_ARGUMENTS` before it connects. A ref that declares no policies is accepted and changes nothing, so a pipeline can pass the flag on every deploy.
|
|
556
558
|
|
|
557
559
|
The flag is consent, like `--delete`. It is for the person who owns the database and reviewed the ref change. Never add it to make your own deploy pass, and never change a database's or a ref's policies, by hand or with `migration ref policy set` or `delete`, to get a deploy, a plan or `db update` past a refusal or a mismatch: the policy is there to stop exactly that.
|
|
558
560
|
|
|
@@ -586,7 +586,7 @@ const { affectedRows } = await db.execute(deletePlan);
|
|
|
586
586
|
|
|
587
587
|
Each row must include every column that is not nullable and has no default; leaving one out is a type error that names the column. A value typed `T | undefined` for such a column is also an error, so narrow it first.
|
|
588
588
|
|
|
589
|
-
`.returning(...)` requires the contract to require `
|
|
589
|
+
`.returning(...)` requires the contract to require `db.returning`. `postgres15` to `postgres18` list it.
|
|
590
590
|
|
|
591
591
|
### Computed projections and joins
|
|
592
592
|
|
|
@@ -696,7 +696,7 @@ Cross-namespace relations (e.g. `public.Profile` → `auth.User`) follow the sam
|
|
|
696
696
|
5. **Importing `and` / `or` / `not` from an internal package.** They are exported from `@prisma/orm-postgres/orm-client`; do not import them from a platform package such as `@prisma/orm-family-sql`.
|
|
697
697
|
6. **Trying to `db.sql.from(tables.user)`.** That surface does not exist. The builder is table-shaped: `db.sql.<ns>.<tableName>.select(...)`. There is no `db.schema.tables` either.
|
|
698
698
|
7. **Reading rows with `execute`.** Plans run through the client: `db.query(plan)` for rows, `db.execute(plan)` for a non-returning write (`{ affectedRows }`). Inside a transaction, `tx.query(plan)` / `tx.execute(plan)`. `execute` never yields rows — a `select` or `.returning(...)` plan passed to it gives you statistics, not data.
|
|
699
|
-
8. **Setting `capabilities: { lateral: true }` in `prisma.config.ts`.** The ORM config (`ormConfig({...})`) does not take `capabilities`. The contract lists every capability it requires in `requiredCapabilities`, beside the path in the contract entry or in `defineContract`, usually `[...postgres18, ...postgresDriver]`, which includes `
|
|
699
|
+
8. **Setting `capabilities: { lateral: true }` in `prisma.config.ts`.** The ORM config (`ormConfig({...})`) does not take `capabilities`. The contract lists every capability it requires in `requiredCapabilities`, beside the path in the contract entry or in `defineContract`, usually `[...postgres18, ...postgresDriver]`, which includes `db.lateral`, `db.jsonAgg` and `db.returning`. To require one more, add its key to that list (see `references/contract.md`).
|
|
700
700
|
9. **Confabulating a TypedSQL or `.stream()` surface.** Neither exists. Raw SQL does: the client's raw lane, ``db.raw.sql`…` ``. Reusable statements do: `db.prepare(...)` (see *Prepared statements* in [`queries.md`](./queries.md)). Streaming: `for await` over a read terminal or `runtime.query(plan)` — with the caveats in *Streaming* in [`queries.md`](./queries.md).
|
|
701
701
|
10. **Mixing the ORM mutation return with `db.query(plan)` / `db.execute(plan)`.** ORM terminals issue the query themselves and return rows. `query` and `execute` are for plans.
|
|
702
702
|
11. **Adding a `cursor()` to a relation, count, operation or `nulls` order.** It throws `ORM.ARGUMENT_INVALID`. Use `.limit(n).offset(n)`, or order by plain columns.
|
|
@@ -37,7 +37,7 @@ This skill does **not** cover migrating from another ORM (Drizzle, Prisma 6/7, S
|
|
|
37
37
|
- **Why the application lists them.** The application must have exactly one copy of each. Prisma does not accept a value that another copy of its own code created, and a package manager takes a peer dependency only from the application's own list. A monorepo whose applications are on different Prisma releases can still get two copies under npm workspaces and under Bun's hoisted linker; keep such applications on one release, or use pnpm, Yarn or Bun's isolated linker.
|
|
38
38
|
- **Yarn Plug'n'Play.** `prisma orm init` does not support it. With Yarn, set `nodeLinker: node-modules` in `.yarnrc.yml` first.
|
|
39
39
|
- **`db.ts`**: the runtime entry point. Lives next to the contract source at `src/prisma/db.ts`. Imports the contract artefacts and exports a `db` value the rest of the app uses.
|
|
40
|
-
- **Marker**: a row in the `
|
|
40
|
+
- **Marker**: a row in the `prisma.signatures` table (Postgres) or a document in the `_prisma_migrations` collection (Mongo) that records the contract hash per contract space. Lets Prisma 8 detect drift between contract and live DB. Created by `db init` (greenfield / first-touch orientation) or `db sign` (brownfield).
|
|
41
41
|
|
|
42
42
|
### Canonical on-disk layout
|
|
43
43
|
|
|
@@ -33,11 +33,11 @@ This skill covers using Prisma 8 against a **Supabase** project end-to-end: comp
|
|
|
33
33
|
|
|
34
34
|
## Workflow — Wire the pack into the config
|
|
35
35
|
|
|
36
|
-
The concept: the pack registers the Supabase contract space so your contract can reference it and the planner/verifier know what Supabase owns. Its descriptor is the `pack` export and it goes into the ordinary `extensions` array of the target config, inside the standard envelope (see `references/contract.md` § *Key Concepts*).
|
|
36
|
+
The concept: the pack registers the Supabase contract space so your contract can reference it and the planner/verifier know what Supabase owns. Its descriptor is the `pack` export and it goes into the ordinary `extensions` array of the target config, inside the standard envelope (see `references/contract.md` § *Key Concepts*). It imports `definePrismaConfig` from `prisma/config`, which the project's `prisma` development dependency provides (`prisma orm init` adds it):
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
39
|
// prisma.config.ts
|
|
40
|
-
import { definePrismaConfig } from '
|
|
40
|
+
import { definePrismaConfig } from 'prisma/config';
|
|
41
41
|
import supabasePack from '@prisma/orm-extension-supabase/pack';
|
|
42
42
|
import { defineConfig as ormConfig, postgres18, postgresDriver } from '@prisma/orm-postgres/config';
|
|
43
43
|
|
|
@@ -19,25 +19,34 @@ Before changing any code, work out how far the chain can go. The application can
|
|
|
19
19
|
|
|
20
20
|
When the lines disagree, npm refuses the install if the packages that disagree are ones the application lists itself. pnpm, Yarn and Bun install anyway and print a peer dependency warning, so a successful install does not prove that the versions match.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
**Which packages are released with the ORM.** Some Prisma packages are published from the Prisma ORM repository, `prisma/orm`, at every release, such as `@prisma/orm-extension-pgvector`, `@prisma/orm-postgres-contrib` and `@prisma/orm-better-auth`. Each lists the other Prisma packages at that release, so it moves to `<to>` together with the database package in the bump step below, and does not limit how far the application can go. Other packages have versions of their own and are published when their maintainer chooses, even when their name starts with `@prisma/orm-`: Prisma publishes some from other repositories, and a package released with the ORM can move to a repository of its own.
|
|
23
|
+
|
|
24
|
+
Each published version says where it came from, in the `repository.url` of its `package.json`. Decide at each step of the chain: a package is released with the ORM at that step when it has a version in that step's release (`<to>` itself on the `8.0.0` release candidates; from release 8.0, a version in the `<to>` release, as [Version detection](#version-detection) defines it, such as `8.0.1` or `8.0.1-ea.0` and never `8.0.0-rc.25`), and that version's `repository.url` names the repository `prisma/orm` itself, such as `https://github.com/prisma/orm.git`. A repository whose name only starts the same way, such as `prisma/orm-extension-<name>`, is another repository. `pnpm view <name> versions --json` lists the versions, and `pnpm view <name>@<version> repository.url` reads the field; for the installed version, read `node_modules/<name>/package.json`. Any other package has versions of its own at that step: treat it as an extension published by someone else, which this pre-flight covers. Never derive its version from `<to>`, which can name a version that was never published.
|
|
25
|
+
|
|
26
|
+
If you cannot tell which kind a package is, treat it as one with versions of its own. That is safe: the pre-flight takes the newest release that accepts the step, and for a package released with the ORM that is its version in `<to>`.
|
|
23
27
|
|
|
24
28
|
Steps:
|
|
25
29
|
|
|
26
|
-
1. **Read `prisma.config.ts`** (or its TS-discoverable equivalent at the project root) and enumerate the list of extension packages it imports. Each `extensions: [...]` entry corresponds to an installed npm package.
|
|
27
|
-
2. **For each extension**, read its installed `package.json` from `node_modules/<extension-package-name>/package.json` and find every `@prisma/orm-*` entry under `dependencies`, `peerDependencies`, or `optionalDependencies` (`@prisma/orm-framework`, `@prisma/orm-family-sql` or `@prisma/orm-family-mongo`, `@prisma/orm-toolchain`, and a `@prisma/orm-target-*` package). Until release 8.0, by construction those entries are exact-version pins (e.g. `"8.0.0-rc.11"`), set when the extension author last ran their own upgrade.
|
|
28
|
-
3. **Find each extension's releases.** List its published versions with `pnpm view <extension> versions --json`. For each version, read the
|
|
30
|
+
1. **Read `prisma.config.ts`** (or its TS-discoverable equivalent at the project root) and enumerate the list of extension packages it imports. Each `extensions: [...]` entry corresponds to an installed npm package. Add any other package in the project's `package.json` that names an `@prisma/orm-*` package as a peer dependency, such as a library integration. Leave out a package that is released with the ORM at every step of the chain, as described above.
|
|
31
|
+
2. **For each extension**, read its installed `package.json` from `node_modules/<extension-package-name>/package.json` and find every `@prisma/orm-*` entry under `dependencies`, `peerDependencies`, or `optionalDependencies` (`@prisma/orm-framework`, `@prisma/orm-family-sql` or `@prisma/orm-family-mongo`, `@prisma/orm-toolchain`, and a `@prisma/orm-target-*` package), and every entry there on another package that step 1 listed, which has versions of its own whatever its name. Until release 8.0, by construction those entries are exact-version pins (e.g. `"8.0.0-rc.11"`), set when the extension author last ran their own upgrade.
|
|
32
|
+
3. **Find each extension's releases.** List its published versions with `pnpm view <extension> versions --json`. For each version, read the entries step 2 names, under `dependencies`, `peerDependencies` and `optionalDependencies`: `pnpm view <extension>@<version> dependencies peerDependencies optionalDependencies --json`. Then, for each step in the chain below, work out the version each of those packages has at that step, as the bump step of the per-step flow defines it:
|
|
29
33
|
- on the `8.0.0` release candidates, it is `<to>` itself;
|
|
30
|
-
- from release 8.0, it is that package's first version in the `<to>` release, such as `8.0.1` for a GA package and `8.0.1-ea.0` for one below GA.
|
|
34
|
+
- from release 8.0, it is the version the install will take for the entry the bump step writes: the newest published version that entry accepts. The bump step writes the package's first version in the `<to>` release, as [Version detection](#version-detection) defines it, such as `8.0.1` for a GA package and `8.0.1-ea.0` for one below GA, with a caret or a tilde, so once `8.0.2` is published the install takes `8.0.2`, and an extension that names exactly `8.0.1` does not accept it;
|
|
35
|
+
- for a package with versions of its own, such as another extension, it is the release this pre-flight notes for that package at that step.
|
|
31
36
|
|
|
32
|
-
Note the release of each extension whose every entry accepts its package's version at that step.
|
|
33
|
-
4. **Find the last step every extension allows.** Walk the chain from the first step. The chain can go as far as the last step
|
|
37
|
+
Note, for each step, the newest release of each extension whose every entry accepts its package's version at that step. Several releases can accept the same step; take the newest.
|
|
38
|
+
4. **Find the last step every extension allows.** Walk the chain from the first step. A step for which some extension has no release, while a later step of the chain has one for it, does not stop the chain: the steps up to that later step are taken together, as [Steps taken together](#steps-taken-together) describes. The chain can go as far as the last step for which every extension has a release. If that is short of the user's target, tell the user before installing anything: which extension has no release for which Prisma version, how far the upgrade can go, and their options:
|
|
34
39
|
- (a) Wait for, or ask for, a release of the extension for that version, then re-run.
|
|
35
40
|
- (b) Upgrade only as far as the last step every extension allows.
|
|
36
41
|
- (c) Remove the extension, and upgrade without it.
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
If an extension does have a release for the step, but that release pins another package with versions of its own exactly, at a version other than the one this pre-flight noted for that package, say that instead of reporting a missing release: name the extension's release, its pin, and the version noted for the other package.
|
|
44
|
+
|
|
45
|
+
5. **Check the `prisma` command-line tool.** If the project lists `prisma`, find for each step the `prisma` version that fits it, as [Choosing the `prisma` version](#choosing-the-prisma-version) describes, and treat `prisma` like an extension with versions of its own. A step no `prisma` version fits, while a later step of the chain has one, is taken together with that later step. The chain goes no further than the last step a `prisma` version fits. If that is short of the user's target, tell the user before installing anything, as in step 4: which step has no `prisma` version, and how far the upgrade can go. When the step is to the newest release, a `prisma` version that carries it is normally published within a few days of the ORM, so the user can wait and re-run. For an older step none will come, so the user can only upgrade that far.
|
|
46
|
+
|
|
47
|
+
Do not skip a step's upgrade instructions, do not install an extension at a release that names another Prisma version, and do not install past the last step every extension and `prisma` allow.
|
|
39
48
|
|
|
40
|
-
If
|
|
49
|
+
If step 1 finds no package to check and the project does not list `prisma`, skip the pre-flight.
|
|
41
50
|
|
|
42
51
|
## Role detection
|
|
43
52
|
|
|
@@ -53,6 +62,7 @@ If the repository also holds an extension, in a `package.json` of its own, run *
|
|
|
53
62
|
- **From-version.** Read the installed Prisma 8 version from `pnpm-lock.yaml` (or `package-lock.json` / `yarn.lock`): take the resolved version of the application's database package, which is `@prisma/orm-postgres`, `@prisma/orm-mongo`, `@prisma/orm-sqlite`, `@prisma/orm-mysql` or `@prisma/orm-mariadb`. Do not read it from an extension published by someone else. Such an extension has its own version, and the pre-flight above deals with it.
|
|
54
63
|
- **On the `8.0.0` release candidates,** compare the full version strings, including the part after the hyphen. `8.0.0-rc.10` and `8.0.0-rc.11` are different versions, and different steps in the chain below.
|
|
55
64
|
- **From release 8.0,** each package has its own patch number or level suffix, and a step is named by the release, which is the major and minor: `8.0-to-8.1`. So the from-version is the release that the database package's version belongs to. `8.0.1-ea.0`, `8.0.1` and `8.0.2` all belong to release `8.0`.
|
|
65
|
+
- **What counts as a version of a release.** Release 8.0 starts at `8.0.1` for a GA package and `8.0.1-ea.0` (or `-preview.0`, `-rc.0`) for one below GA. A version `8.0.0-rc.N` is a release candidate, which is a step of its own, not a version of release 8.0, although its major and minor are `8.0`. A version with `-dev.` in it is a development build and is not a version of any release. Wherever this reference says "a version in the `<to>` release" or "the first version in the `<to>` release", it means this.
|
|
56
66
|
- If the lockfile shows the application's Prisma packages on different releases, which is already a broken state, the **lowest** is the from-version.
|
|
57
67
|
- **To-version.** Either the version the user specified, or whatever `npm view @prisma/orm-postgres dist-tags.latest` reports. Do not assume that is a stable version: while Prisma 8 is a release candidate, `latest` tracks the newest release, `8.0.0-rc.N` included. If the user wants a stable version specifically, they must name it.
|
|
58
68
|
|
|
@@ -68,9 +78,20 @@ If the from-to delta spans more than one release (e.g. `0.6 → 0.8`), build the
|
|
|
68
78
|
|
|
69
79
|
The [`../upgrading/app/upgrades/`](../upgrading/app/upgrades/) directories name the steps — read the chain off the directory names rather than deriving it arithmetically. Each directory is `<from>-to-<to>`. A step normally spans one stable minor (`0.7-to-0.8`) or one release candidate (`8.0.0-rc.1-to-8.0.0-rc.2`). When intermediate versions were not published, a guide may span a larger hop; follow the available directory chain rather than inventing missing steps. Moving onto the RC line from the last stable minor is a single step of its own (`0.17-to-8.0.0-rc.1`).
|
|
70
80
|
|
|
71
|
-
Apply each step in order, fully: bump, install, run instructions, validate, commit — before moving to the next. Halt the chain on the first failed step; do not skip ahead.
|
|
81
|
+
Apply each step in order, fully: bump, install, run instructions, validate, commit — before moving to the next. The one exception is [steps taken together](#steps-taken-together), which the pre-flight decides. Halt the chain on the first failed step; do not skip ahead.
|
|
82
|
+
|
|
83
|
+
The chain order does not depend on which extensions are installed; the pre-flight has already worked out how far it can go, and which steps are taken together.
|
|
84
|
+
|
|
85
|
+
### Steps taken together
|
|
86
|
+
|
|
87
|
+
An extension with versions of its own may have no release for some steps of the chain and a release for a later one. A release candidate cut after the extension's last release is one such step. The extension at its old release names the old Prisma versions, so the project cannot install those steps with it. The `prisma` command-line tool is the same: for some steps no `prisma` version fits, and a `prisma` command must run on the toolchain of the packages installed at that time. Take those steps, and the later step, together, using the per-step flow's own parts:
|
|
72
88
|
|
|
73
|
-
|
|
89
|
+
- Do the bump once, to the later step's versions: the first later step for which every extension has a release and a `prisma` version fits.
|
|
90
|
+
- Install once, and re-sync the skills.
|
|
91
|
+
- Read and apply the upgrade instructions of every step from the first of them to that later step, in the chain's order, with no install in between.
|
|
92
|
+
- Validate once, after the last of them, then commit. Name every step the commit covers in its message.
|
|
93
|
+
|
|
94
|
+
The `prisma` commands that the earlier steps' instructions run, such as `prisma contract emit`, `prisma db sign` and `prisma migration plan`, run on the installed toolchain, which is the later step's. So where an earlier step's guide says what such a command must or must not change, read that against the later step: the command writes the later step's format. If validation fails, report every step taken together, and the change ids whose files the failure names, because the failure can come from any of them.
|
|
74
95
|
|
|
75
96
|
## Per-step flow
|
|
76
97
|
|
|
@@ -79,9 +100,9 @@ For each `(from, to)` step in the chain:
|
|
|
79
100
|
1. **Bump the app's Prisma packages.** Change these entries in the project's `package.json`, under both `dependencies` and `devDependencies`:
|
|
80
101
|
- the database package, such as `@prisma/orm-postgres`;
|
|
81
102
|
- the platform packages that the database package lists as peer dependencies;
|
|
82
|
-
- every extension or library integration
|
|
103
|
+
- every extension or library integration that is [released with the ORM](#pre-flight--extension-compatibility) at this step, such as `@prisma/orm-extension-pgvector`, `@prisma/orm-postgres-contrib` and `@prisma/orm-better-auth`.
|
|
83
104
|
|
|
84
|
-
Each of these is published at every release and lists the other Prisma packages at that release, so one that is left behind disagrees with the rest.
|
|
105
|
+
Each of these is published at every release and lists the other Prisma packages at that release, so one that is left behind disagrees with the rest. A package whose name starts with `@prisma/orm-` but that has versions of its own at this step is not in this list. It moves as an extension published by someone else, below.
|
|
85
106
|
|
|
86
107
|
**What to write, on the `8.0.0` release candidates.** Rewrite every entry to the exact `<to>` version, with no caret and no tilde. All entries move to the same version.
|
|
87
108
|
|
|
@@ -89,11 +110,13 @@ For each `(from, to)` step in the chain:
|
|
|
89
110
|
- beside a GA database package, a GA entry gets a caret and an entry below GA gets a tilde;
|
|
90
111
|
- beside a database package below GA, every entry gets a tilde.
|
|
91
112
|
|
|
92
|
-
**Write a caret only when `<to>` is the newest published release,** which `pnpm view <
|
|
113
|
+
**Write a caret only when `<to>` is the newest published release of every package this step writes,** which `pnpm view <name> versions --json` shows for each: the database package, each platform package the application lists, and each extension or library integration released with the ORM at this step. The packages of a release are not all published at the same moment, so a platform package can have a later release before the database package does. A caret accepts later releases, so at any other step the install would take a release later than `<to>`, whose instructions have not been applied. That is every step before the last one, and the last one too when the user's target is older than the newest release. At such a step write a tilde in place of the caret: a tilde stays within `<to>` and still takes its fixes. If the upgrade ends on a release that is not the newest, say in the final report that those entries have a tilde where [Versions and support](https://github.com/prisma/orm/blob/main/docs/oss/versioning.md#what-an-application-writes) gives a caret.
|
|
93
114
|
|
|
94
115
|
**A peer dependency the project does not list.** If the database package at `<to>` lists an `@prisma/orm-*` peer dependency that the project's `package.json` does not have, add it, written as that package's entry for `<to>` would be. The application lists every one of them, so that it has one copy of each. A monorepo whose applications are on different Prisma releases can still get two copies under npm workspaces and under Bun's hoisted linker; keep such applications on one release, or use pnpm, Yarn or Bun's isolated linker.
|
|
95
116
|
|
|
96
|
-
**Extensions published by someone else
|
|
117
|
+
**Extensions published by someone else,** and Prisma packages with versions of their own. Set each one to the release the pre-flight noted for this step: the one whose every entry the pre-flight reads accepts that package's version at the step. On the `8.0.0` release candidates, write it exactly. From release 8.0, write it as [Versions and support](https://github.com/prisma/orm/blob/main/docs/oss/versioning.md#what-an-application-writes) gives for its level, by the same rules as the entries above: a caret on a GA version beside a GA database package, a tilde otherwise, such as `~8.0.1-ea.0` for a version below GA, and a tilde in place of the caret where the rule above allows no caret. If that range also accepts a later release of the package that the pre-flight did not note, because that release does not accept the step, write the noted release exactly instead: the install takes the newest release a range accepts. If an extension has no such release and the pre-flight did not take this step together with a later one, halt before this step's install. The project stays at the last step that worked, and the user gets the pre-flight's message for that extension and step.
|
|
118
|
+
|
|
119
|
+
**The `prisma` command-line tool.** If the project lists `prisma`, move it too, to a version chosen as [Choosing the `prisma` version](#choosing-the-prisma-version) describes. `prisma` runs the ORM commands from its own copy of the toolchain, and that copy must be on the application's release. The pre-flight has already found the version for this step. A step no `prisma` version fits is taken together with a later one, or is past where the chain stops.
|
|
97
120
|
|
|
98
121
|
The skill itself ships inside the Prisma packages, so bumping them is what updates it. There is no separate skill package to bump.
|
|
99
122
|
|
|
@@ -121,13 +144,27 @@ For each `(from, to)` step in the chain:
|
|
|
121
144
|
chore: upgrade @prisma/orm-* to <to-version>
|
|
122
145
|
```
|
|
123
146
|
|
|
124
|
-
(Or the project's own commit-message convention.) Never squash steps. The user may squash on merge; the in-flight history must be per-step so a failed step is bisectable.
|
|
147
|
+
(Or the project's own commit-message convention.) Never squash steps, except that [steps taken together](#steps-taken-together) are one commit, which names each of them. The user may squash on merge; the in-flight history must be per-step so a failed step is bisectable.
|
|
125
148
|
|
|
126
149
|
Then move on to the next step.
|
|
127
150
|
|
|
151
|
+
## Choosing the `prisma` version
|
|
152
|
+
|
|
153
|
+
The `prisma` command-line tool is published from another repository, [`prisma/prisma-cli`](https://github.com/prisma/prisma-cli). Each of its versions for Prisma 8 depends on one exact version of `@prisma/orm-toolchain`, and runs the ORM commands, such as `prisma contract emit`, from that copy, not from the copy the project lists. So the files those commands write and read come from the toolchain the `prisma` version brings. From `prisma@8.0.0-rc.36` on, each version also lists `@prisma/orm-framework` at the same exact version. Earlier versions do not list it, and get it through the toolchain. Some ORM release candidates, such as `8.0.0-rc.1`, `8.0.0-rc.6`, `8.0.0-rc.9` and `8.0.0-rc.15`, have no `prisma` version that carries them.
|
|
154
|
+
|
|
155
|
+
Its version numbers are its own, though they look like the ORM's: `prisma@8.0.0-rc.36` carries the ORM at `8.0.0-rc.25`. Never choose `prisma` by its own number. Read its dependencies.
|
|
156
|
+
|
|
157
|
+
1. Run `pnpm view prisma dist-tags.latest`, then `pnpm view prisma@<that version> dependencies`.
|
|
158
|
+
2. That version fits the step when its `@prisma/orm-toolchain`, and its `@prisma/orm-framework` if it lists one, are:
|
|
159
|
+
- on the `8.0.0` release candidates, exactly `<to>`, because file formats changed between release candidates;
|
|
160
|
+
- from release 8.0, versions in the `<to>` release as [Version detection](#version-detection) defines it, with any patch number or level suffix. A `8.0.0-rc.N` version does not fit a step to release 8.0: on the day of release 8.0, `latest` may still carry `8.0.0-rc.25`. The tool is meant to stop when its toolchain and the project's packages are on different releases, and within one release the files it writes and reads stay compatible ([ADR 329](https://github.com/prisma/orm/blob/main/docs/architecture%20docs/adrs/ADR%20329%20-%20An%20application%20lists%20the%20platform%20packages%20and%20our%20packages%20name%20each%20other%20as%20peers.md#the-prisma-command-line-tool)).
|
|
161
|
+
3. If `latest` does not fit, look through `pnpm view prisma versions --json` for the highest version that fits. Never take a version with `-dev.` in it, which is a development build, and never one whose dependencies name no `@prisma/orm-toolchain`, which is a Prisma 7 version.
|
|
162
|
+
4. Write the version exactly, with no caret or tilde, so that a later `prisma` carrying another release is not installed. This has a cost: an ordinary update with the package manager moves the Prisma packages to a new release and leaves `prisma` carrying the old one. This upgrade flow moves `prisma` at each step. After an update made any other way, choose its version again by these steps.
|
|
163
|
+
5. If no version fits a step, take it, and every step after it that no version fits either, together with the next step that a `prisma` version fits, as [Steps taken together](#steps-taken-together) describes. A `prisma` command must run on the toolchain of the packages installed at that time, so those steps cannot be installed one by one. If no `prisma` version fits any of the remaining steps, the run is taken together with the last step of the chain. The application flow then stops before installing that run, as step 5 of the pre-flight says, so the chain ends at the last step a `prisma` version fits. The extension flow instead installs it and uses the overrides stopgap that its bump step describes, because an extension author may need to prepare a release before `prisma` catches up. That is the one difference between the two flows.
|
|
164
|
+
|
|
128
165
|
## When the chain is done
|
|
129
166
|
|
|
130
|
-
Report back to the user: the number of steps applied, the SHAs of the commits you made, and any open follow-ups (e.g. tests that were already red before the upgrade and still are).
|
|
167
|
+
Report back to the user: the number of steps applied, the SHAs of the commits you made, and any open follow-ups (e.g. tests that were already red before the upgrade and still are). If the chain stopped short of the user's target because no `prisma` version carries a later step, say so, and say which step to re-run from once one is published.
|
|
131
168
|
|
|
132
169
|
## Failure surfaces
|
|
133
170
|
|
|
@@ -30,6 +30,7 @@ If detection is ambiguous, ask the user which role to operate under.
|
|
|
30
30
|
- **From-version.** Read the installed Prisma 8 version from `pnpm-lock.yaml` (or `package-lock.json` / `yarn.lock`): take the resolved version of any `@prisma/orm-*` platform package (`@prisma/orm-framework`, `@prisma/orm-family-*`, `@prisma/orm-target-*`, `@prisma/orm-toolchain`). Do not read it from an extension published by someone else, which has its own version.
|
|
31
31
|
- **On the `8.0.0` release candidates,** compare the full version strings, including the part after the hyphen. `8.0.0-rc.10` and `8.0.0-rc.11` are different versions, and different steps in the chain below.
|
|
32
32
|
- **From release 8.0,** a step is named by the release, which is the major and minor: `8.0-to-8.1`. So the from-version is the release that a package's version belongs to. `8.0.1-ea.0`, `8.0.1` and `8.0.2` all belong to release `8.0`. (A platform package below GA has a level suffix, such as `8.0.1-ea.0` for `@prisma/orm-family-mongo`.)
|
|
33
|
+
- **What counts as a version of a release.** Release 8.0 starts at `8.0.1` for a GA package and `8.0.1-ea.0` (or `-preview.0`, `-rc.0`) for one below GA. A version `8.0.0-rc.N` is a release candidate, which is a step of its own, not a version of release 8.0, although its major and minor are `8.0`. A version with `-dev.` in it is a development build and is not a version of any release. Wherever this reference says "a version in the `<to>` release" or "the first version in the `<to>` release", it means this.
|
|
33
34
|
- If the lockfile shows the platform packages on different releases, the lowest is the from-version.
|
|
34
35
|
- **To-version.** Either the version the user specified, or whatever `npm view @prisma/orm-framework dist-tags.latest` reports. Do not assume that is a stable version: while Prisma 8 is a release candidate, `latest` tracks the newest release, `8.0.0-rc.N` included. If the user wants a stable version specifically, they must name it.
|
|
35
36
|
|
|
@@ -45,7 +46,7 @@ If the from-to delta spans more than one release (e.g. `0.6 → 0.8`), build the
|
|
|
45
46
|
|
|
46
47
|
The [`../upgrading/extension/upgrades/`](../upgrading/extension/upgrades/) directories name the steps — read the chain off the directory names rather than deriving it arithmetically. Each directory is `<from>-to-<to>`. A step normally spans one stable minor (`0.7-to-0.8`) or one release candidate (`8.0.0-rc.1-to-8.0.0-rc.2`). When intermediate versions were not published, a guide may span a larger hop; follow the available directory chain rather than inventing missing steps. Moving onto the RC line from the last stable minor is a single step of its own (`0.17-to-8.0.0-rc.1`).
|
|
47
48
|
|
|
48
|
-
Apply each step in order, fully: bump, install, run instructions, check pins, validate, commit — before moving to the next. Halt the chain on the first failed step.
|
|
49
|
+
Apply each step in order, fully: bump, install, run instructions, check pins, validate, commit — before moving to the next. The one exception is a step that a package with versions of its own, or `prisma`, has no release for; the bump step says when to take steps together. Halt the chain on the first failed step.
|
|
49
50
|
|
|
50
51
|
## Per-step flow
|
|
51
52
|
|
|
@@ -54,16 +55,37 @@ This flow assumes you are an **external extension author**: your extension lives
|
|
|
54
55
|
For each `(from, to)` step in the chain:
|
|
55
56
|
|
|
56
57
|
1. **Bump `@prisma/orm-*` deps.** What to write depends on the release:
|
|
57
|
-
- **On the `8.0.0` release candidates,** rewrite every `@prisma/orm-*` entry in the extension's `package.json` to the exact `<to>` version, such as `"8.0.0-rc.11"
|
|
58
|
+
- **On the `8.0.0` release candidates,** rewrite every `@prisma/orm-*` entry in the extension's `package.json` to the exact `<to>` version, such as `"8.0.0-rc.11"`, except a package with versions of its own (below): no caret, no tilde, no range, and no `workspace:` specifier. The exact-pin rule below says why. All entries move to the same version. That includes another extension [released with the ORM](upgrade-app.md#pre-flight--extension-compatibility), such as `@prisma/orm-extension-pgvector`: each of those lists the others at that release's version.
|
|
58
59
|
- **From release 8.0,** the two sections of `package.json` differ.
|
|
59
|
-
- Under `peerDependencies`, write the ranges that [the last section](#from-release-80-number-your-package-and-declare-ranges) gives. They say which releases your package accepts, and a caret there need not change at every step.
|
|
60
|
-
- Under `devDependencies`, write each package's first version in the `<to>` release, so that your build and tests run against `<to>`: `8.2.0` for a GA package at the step to release 8.2, whatever the peer range says. Put a tilde in front of every one, such as `~8.2.0` or `~8.2.0-ea.0`. A tilde stays within `<to>` and still takes its fixes. A caret would let the install take a later release, whose instructions have not been applied, and would let a GA package move ahead of a package below GA that the tests use.
|
|
60
|
+
- Under `peerDependencies`, write the ranges that [the last section](#from-release-80-number-your-package-and-declare-ranges) gives, except for a package with versions of its own (below). They say which releases your package accepts, and a caret there need not change at every step.
|
|
61
|
+
- Under `devDependencies`, write each package's first version in the `<to>` release, again except for a package with versions of its own, so that your build and tests run against `<to>`: `8.2.0` for a GA package at the step to release 8.2, whatever the peer range says. Put a tilde in front of every one, such as `~8.2.0` or `~8.2.0-ea.0`. A tilde stays within `<to>` and still takes its fixes. A caret would let the install take a later release, whose instructions have not been applied, and would let a GA package move ahead of a package below GA that the tests use.
|
|
61
62
|
|
|
62
63
|
Where each entry goes is the same on every release:
|
|
63
64
|
- A package that the extension's shipped code imports belongs under `peerDependencies`, and again under `devDependencies`.
|
|
64
65
|
- A package that only the extension's tests use, such as a database package the tests run against, belongs under `devDependencies` alone.
|
|
65
66
|
- Move any entry that is still under `dependencies` or `optionalDependencies`. An extension written for an earlier release had the framework, the family and the toolchain as ordinary dependencies.
|
|
66
67
|
|
|
68
|
+
**A package with versions of its own.** A Prisma package is released with the ORM at this step only when it has a version in the `<to>` release, as [Version detection](#version-detection) defines it, whose `repository.url` names `prisma/orm` itself, as [the application pre-flight](upgrade-app.md#pre-flight--extension-compatibility) describes. Any other package your extension uses has versions of its own, even when its name starts with `@prisma/orm-`: an extension published by someone else, a package Prisma publishes from another repository, or one that moved out of the ORM repository. If you cannot tell which kind a package is, treat it as one with versions of its own; the search below finds the right version for either kind. Do not write `<to>`, or a version derived from it, for such a package: that version may never be published. Find the newest release of it whose every entry accepts this step's versions, reading its entries on `@prisma/orm-*` packages and on the other packages with versions of their own as step 3 of the application pre-flight does. If it has none, but has one for a later step of the chain, take the steps up to that later step together, as [Steps taken together](upgrade-app.md#steps-taken-together) describes for an application. In this flow that means: do step 1, the bump, once, to the later step's versions; step 2, the install, once; step 3, the pin check, once, after the install; then steps 4 and 5, reading and applying the upgrade instructions, for every step from the first of them to the later one, in order; then step 6, validation, and step 7, the commit, once. If no later step has one either, halt before this step's install and tell the user which package has no release for which Prisma version. Write the release you found:
|
|
69
|
+
- on the `8.0.0` release candidates, as its exact version, under `devDependencies`, and also under `peerDependencies` when the extension's shipped code imports it, as above;
|
|
70
|
+
- from release 8.0, under `devDependencies`, with a tilde on that release's version, such as `~8.0.1-ea.0`, or as the exact version when the tilde would also accept a later release of it that does not accept this step, because the install takes the newest release a range accepts; under `peerDependencies`, when the shipped code imports it, the range [the last section](#from-release-80-number-your-package-and-declare-ranges) gives for that package's level, taken from that release's version and not from `<to>`, such as `^8.0.1` for a GA version `8.0.1` or `~8.0.1-ea.0` for a version below GA.
|
|
71
|
+
|
|
72
|
+
**The `prisma` command-line tool.** If the extension lists `prisma` under `devDependencies`, to run `prisma` commands such as `prisma contract emit` in its build or tests, choose its version as [Choosing the `prisma` version](upgrade-app.md#choosing-the-prisma-version) describes: on the `8.0.0` release candidates its toolchain must be exactly `<to>`, and so must its framework where it lists one; from release 8.0 they must be in the `<to>` release, which no `8.0.0-rc.N` version is. This matters more for an extension than for an application: the files your build ships and the commands your tests run come from the toolchain that `prisma` brings, not from the one your extension lists.
|
|
73
|
+
|
|
74
|
+
If no `prisma` version fits a step that is not the last of the chain, take that step, and every step after it that no `prisma` version fits either, together with the next step that a `prisma` version fits, as for a package with versions of its own above: a `prisma` command must run on the toolchain of the packages installed at that time. If no `prisma` version fits any of the remaining steps, take the run together with the last step of the chain, which then uses the overrides below. If none fits the last step, which is normal on the day of a release, because `prisma` is published after the ORM, move `prisma` to its `latest` version and make it use this step's versions with pnpm overrides. Use `<to>` on the release candidates, and from release 8.0 the versions your `devDependencies` resolve to:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
"pnpm": {
|
|
78
|
+
"overrides": {
|
|
79
|
+
"prisma>@prisma/orm-toolchain": "<version this step installs>",
|
|
80
|
+
"prisma>@prisma/orm-framework": "<version this step installs>"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The toolchain names one exact `@prisma/cli-engine` as a peer dependency. Under the overrides it runs on the engine that `prisma` brings, and the install may print a peer dependency warning for it when the two versions differ. Leave the engine alone: `prisma` itself runs on that engine, and ADR 329 says the toolchain still reads a config made by an engine of another version.
|
|
86
|
+
|
|
87
|
+
The overrides can also go under the `overrides` key of `pnpm-workspace.yaml`, or in your package manager's equivalent. They run `prisma` with a toolchain it was not released with, so they are a stopgap. Do not publish a release of your extension built while they are in place. Once a `prisma` version that fits is published, move `prisma` to it, remove the overrides, and run the install and validation again.
|
|
88
|
+
|
|
67
89
|
The skill itself ships inside the Prisma packages, so bumping them is what updates it. There is no separate skill package to bump.
|
|
68
90
|
|
|
69
91
|
2. **Install.** Run `pnpm install` (or the project's lockfile-managing command). The extension's source is now broken against the new SPI — the upgrade instructions for `<from> → <to>` exist to fix it.
|
|
@@ -73,10 +95,10 @@ For each `(from, to)` step in the chain:
|
|
|
73
95
|
- every such peer dependency must also be under `devDependencies`;
|
|
74
96
|
- none may be under `dependencies` or `optionalDependencies`.
|
|
75
97
|
|
|
76
|
-
A development dependency with no peer entry is one that only the tests use, and passes. This prints any entry that breaks the rule, and exits 1:
|
|
98
|
+
A development dependency with no peer entry is one that only the tests use, and passes. A package with versions of its own keeps the version the bump step chose; name each one after `<to>` so the check does not compare its version with `<to>`. It still checks where the package is listed, that its version is exact, and that its peer and development entries are the same version, also for a named package whose name does not start with `@prisma/orm-`. This prints any entry that breaks the rule, and exits 1:
|
|
77
99
|
|
|
78
100
|
```bash
|
|
79
|
-
node -e 'const p=require("./package.json");const to=process.argv
|
|
101
|
+
node -e 'const p=require("./package.json");const [to,...own]=process.argv.slice(1);const ours=(n)=>n.startsWith("@prisma/orm-");const bad=[];for(const f of ["dependencies","optionalDependencies"])for(const n of Object.keys(p[f]??{}))if(ours(n)||own.includes(n))bad.push(f+": "+n+" belongs in peerDependencies, or in devDependencies alone if only tests use it");for(const f of ["peerDependencies","devDependencies"])for(const [n,v] of Object.entries(p[f]??{}))if((ours(n)||own.includes(n))&&(own.includes(n)?!/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/.test(v)||(f==="peerDependencies"&&n in (p.devDependencies??{})&&p.devDependencies[n]!==v):v!==to))bad.push(f+": "+n+"@"+v);for(const n of Object.keys(p.peerDependencies??{}))if((ours(n)||own.includes(n))&&!(n in (p.devDependencies??{})))bad.push("devDependencies: "+n+" is missing");if(bad.length){console.error(bad.join("\n"));process.exit(1)}' <to> [<package with versions of its own> ...]
|
|
80
102
|
```
|
|
81
103
|
|
|
82
104
|
If it fails, the bump step did not rewrite every entry. Fix the entries it printed and run it again before going on.
|
|
@@ -103,7 +125,7 @@ For each `(from, to)` step in the chain:
|
|
|
103
125
|
chore: upgrade @prisma/orm-* to <to-version>
|
|
104
126
|
```
|
|
105
127
|
|
|
106
|
-
(Or the extension's own commit-message convention, if it has one.) One commit per step — never squash steps.
|
|
128
|
+
(Or the extension's own commit-message convention, if it has one.) One commit per step — never squash steps, except that [steps taken together](upgrade-app.md#steps-taken-together) are one commit, which names each of them.
|
|
107
129
|
|
|
108
130
|
Move on to the next step. Repeat.
|
|
109
131
|
|
|
@@ -111,7 +133,7 @@ Move on to the next step. Repeat.
|
|
|
111
133
|
|
|
112
134
|
This rule holds until release 8.0, while every Prisma 8 package is published as `8.0.0-rc.N`. From release 8.0, ranges replace it; see [the last section](#from-release-80-number-your-package-and-declare-ranges).
|
|
113
135
|
|
|
114
|
-
A Prisma 8 extension names every `@prisma/orm-*` package its shipped code uses, another extension published from the Prisma repository included, as a **peer dependency** at a single **exact** version (no `^`, no `~`, no range, no wildcard, no `workspace:` specifier in the published `package.json`), and lists the same packages under `devDependencies` at that version, so its own build and tests install them. A package of ours that only its tests use is a development dependency alone, at that version. None of them is an ordinary dependency. All of those entries share the same version. The pin advances after each successful upgrade step, release-candidate steps included.
|
|
136
|
+
A Prisma 8 extension names every `@prisma/orm-*` package its shipped code uses, another extension published from the Prisma repository included, as a **peer dependency** at a single **exact** version (no `^`, no `~`, no range, no wildcard, no `workspace:` specifier in the published `package.json`), and lists the same packages under `devDependencies` at that version, so its own build and tests install them. A package of ours that only its tests use is a development dependency alone, at that version. None of them is an ordinary dependency. All of those entries share the same version. A package with versions of its own is the exception: it goes in the same places, a development dependency always and a peer dependency when the shipped code imports it, but at its own version, which the bump step says how to choose. The pin advances after each successful upgrade step, release-candidate steps included.
|
|
115
137
|
|
|
116
138
|
The version is the one the application's database package (`@prisma/orm-postgres`, `@prisma/orm-mongo`, …) uses.
|
|
117
139
|
|
|
@@ -119,7 +141,7 @@ An application must have one copy of each Prisma package, and peer dependencies
|
|
|
119
141
|
|
|
120
142
|
To list every copy and the package that brought it, run `npm ls @prisma/orm-framework`, `pnpm why @prisma/orm-framework` or `bun why @prisma/orm-framework`. [ADR 329](https://github.com/prisma/orm/blob/main/docs/architecture%20docs/adrs/ADR%20329%20-%20An%20application%20lists%20the%20platform%20packages%20and%20our%20packages%20name%20each%20other%20as%20peers.md) explains the reasons, and the one case peer dependencies do not cover, a monorepo with applications on different Prisma releases.
|
|
121
143
|
|
|
122
|
-
The one-line check in step 3 of the per-step flow enforces the rule
|
|
144
|
+
The one-line check in step 3 of the per-step flow enforces the rule. Wire the check into the extension's CI alongside the build/test step so an accidental range pin fails the PR before it lands.
|
|
123
145
|
|
|
124
146
|
## From release 8.0: number your package and declare ranges
|
|
125
147
|
|
|
@@ -133,7 +155,8 @@ From release 8.0, Prisma's packages share a release number, which is the major a
|
|
|
133
155
|
| --- | --- | --- |
|
|
134
156
|
| A GA package, and you use only its GA functions | A caret on the first release your package works with | `^8.1.0` |
|
|
135
157
|
| A GA package, and you use a function below GA, such as `preview_search` | A tilde: that function may change in the next release | `~8.1.0` |
|
|
136
|
-
| A package below GA | A tilde on its first version in that release | `~8.1.0-preview.0` |
|
|
158
|
+
| A package below GA, released with the ORM | A tilde on its first version in that release | `~8.1.0-preview.0` |
|
|
159
|
+
| A package with versions of its own | The range for its level, on the newest release of it that accepts the step, found as the bump step says | `^1.4.0` |
|
|
137
160
|
|
|
138
161
|
With a caret, your package keeps working when an application moves to a later release: a package at `8.1.2` that lists `^8.1.0` works in an application on `8.4`. An application on a release below `8.1` gets a mismatch reported at install. With a tilde, you publish a new version of your package for each Prisma release.
|
|
139
162
|
|
|
@@ -143,7 +166,7 @@ The convention has two costs. A feature of yours that needs no newer Prisma rele
|
|
|
143
166
|
|
|
144
167
|
## When the chain is done
|
|
145
168
|
|
|
146
|
-
Report back to the user: the number of steps applied, the SHAs of the commits you made, and any open follow-ups.
|
|
169
|
+
Report back to the user: the number of steps applied, the SHAs of the commits you made, and any open follow-ups. If the overrides for `prisma` are in place, say so: do not publish a release built with them. Once a `prisma` version that fits is published, move `prisma` to it, remove the overrides, and install and validate again.
|
|
147
170
|
|
|
148
171
|
## Failure surfaces
|
|
149
172
|
|
|
@@ -564,7 +564,7 @@ Run the codemod in dry-run mode to confirm no committed manifest still carries t
|
|
|
564
564
|
pnpm exec tsx ./strip-migration-labels-hints.ts --check
|
|
565
565
|
```
|
|
566
566
|
|
|
567
|
-
`--check` lists every manifest that still needs fixing and exits non-zero if any remain, so wire it into your extension's CI
|
|
567
|
+
`--check` lists every manifest that still needs fixing and exits non-zero if any remain, so wire it into your extension's CI. A fully migrated tree reports `0 needing fix` and exits `0`.
|
|
568
568
|
|
|
569
569
|
### Validation
|
|
570
570
|
|
|
@@ -54,4 +54,4 @@ While at it, scan any seed `migration.ts` doc-comments in your extension for sta
|
|
|
54
54
|
|
|
55
55
|
### Validation
|
|
56
56
|
|
|
57
|
-
After running the script and applying the source-level rules above, run `pnpm typecheck && pnpm test` (or your extension's own equivalent).
|
|
57
|
+
After running the script and applying the source-level rules above, run `pnpm typecheck && pnpm test` (or your extension's own equivalent).
|
|
@@ -145,6 +145,6 @@ There is no codemod for this — extensions construct `SqlStorage` via too many
|
|
|
145
145
|
|
|
146
146
|
### Validation
|
|
147
147
|
|
|
148
|
-
After running the JSON codemod and applying the source-level rules above, run `pnpm typecheck && pnpm test` (or your extension's equivalent).
|
|
148
|
+
After running the JSON codemod and applying the source-level rules above, run `pnpm typecheck && pnpm test` (or your extension's equivalent). The pin set is unchanged for this transition; the breaking change is in runtime construction behaviour, not the dependency contract.
|
|
149
149
|
|
|
150
150
|
If your extension ships seed migrations under `packages/<extension>/migrations/`, also run the codemod with `--check` against the project root to confirm the seed snapshots all stamp correctly. The user-facing copy of the same codemod (under `../../../app/upgrades/0.9-to-0.10/`) operates on the user's app-space migrations; this copy operates on your extension's seed migrations.
|
package/dist/adapter.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-target-mongo/adapter";
|
package/dist/adapter.mjs
DELETED
package/dist/components.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/components";
|
package/dist/components.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/components/authoring";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/components/codec";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/components/components";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/components/control";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/components/emission";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/components/execution";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/components/ir";
|
package/dist/components__ir.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/components/psl-ast";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/components/utils";
|
package/dist/contract.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/contract";
|
package/dist/contract.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/contract/apply-specifier-default-control-policy";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@prisma/orm-framework/contract/contract-validation-error";
|