@prisma/orm-mongo 8.0.0-rc.24-dev.43 → 8.0.0-rc.25

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.
@@ -0,0 +1,1566 @@
1
+ ---
2
+ from: "8.0.0-rc.24"
3
+ to: "8.0.0-rc.25"
4
+ changes:
5
+ - id: pg-is-a-peer-dependency
6
+ summary: |
7
+ `pg` (`^8.22.0`) and `@types/pg` (`^8.20.0`) are now required peer dependencies of `@prisma/orm-target-postgres`, `@prisma/orm-postgres` and `@prisma/orm-extension-supabase`, not dependencies. An extension package whose tests or tooling load the Postgres driver must declare `pg` and `@types/pg` in its own `devDependencies`, because not every package manager and configuration installs a missing peer. An extension pack that peers the target and never loads the driver itself declares neither; the application supplies them.
8
+ detection:
9
+ glob: "**/package.json"
10
+ matches:
11
+ - '"@prisma/orm-(?:postgres|target-postgres|extension-supabase)"\s*:'
12
+ - id: extension-importing-pg-peers-it
13
+ summary: |
14
+ An extension whose own code imports from `pg`, for example to type a `pg.Pool` option, declares `pg` (`^8.22.0`) and `@types/pg` (`^8.20.0`) as peer dependencies, as the Postgres target does, so that it and the application share one copy of the driver and its types.
15
+ detection:
16
+ glob: "**/*.{ts,mts,cts}"
17
+ matches:
18
+ - '(?:from|import|require)\s*\(?\s*[''"]pg[''"]'
19
+ - id: temporal-polyfill-peer-range-moves-to-1-0-8
20
+ summary: |
21
+ The required peer range of `temporal-polyfill` moves from `^1.0.4` to `^1.0.8` on every database package: `@prisma/orm-postgres`, `@prisma/orm-sqlite`, `@prisma/orm-mysql`, `@prisma/orm-mariadb`, `@prisma/orm-mongo` and their `@prisma/orm-target-*` packages. An extension package that declares `temporal-polyfill` itself, for example in the `devDependencies` its tests install, changes its range to `^1.0.8` and reinstalls, so the lockfile does not keep a version below 1.0.8.
22
+ detection:
23
+ glob: "**/{package.json,pnpm-workspace.yaml}"
24
+ matches:
25
+ - '"temporal-polyfill"\s*:\s*"[\^~]?1\.0\.[0-7](?![\d])'
26
+ - '[''"]?temporal-polyfill[''"]?:\s*[''"]?[\^~]?1\.0\.[0-7](?![\d])'
27
+ - id: config-type-renamed-to-prisma-config
28
+ summary: |
29
+ The config type that `defineConfig` returns is renamed from `PrismaNextConfig` to `PrismaConfig`, in `@prisma/orm-framework/config/config-types`, `@prisma/orm-toolchain/cli/config-types` and every package that re-exports it, including the target facades' `defineConfig` return types. The old name is gone. The detection matches TypeScript sources that name the old type.
30
+ detection:
31
+ glob: "**/*.{ts,mts,cts,tsx}"
32
+ matches:
33
+ - '(?<![\w$])PrismaNextConfig(?![\w$])'
34
+ - id: target-package-names-generated-file-modules
35
+ summary: |
36
+ A package that adds a target must name, in the config its `defineConfig` returns, the module generated contract types import from (`contract.typesModule`) and the module migration files import from (`migrations.module`), and must hand the config target and adapter descriptors whose type declarations state its own types module. Without `contract.typesModule`, every command that writes contract types fails with `CONFIG.CONTRACT_TYPES_MODULE_MISSING`: `prisma contract emit`, `prisma migration plan` and `prisma migration new` always, `prisma db init`, `prisma db update` and `prisma db sign` when they advance a ref, and `prisma db migrate` when it advances a ref to a contract that has no snapshot under `migrations/snapshots/`. `prisma migration plan` and `prisma migration new` write that snapshot for every migration they create, so `prisma db migrate` rarely needs the module. Without `migrations.module`, `prisma migration plan` and `prisma migration new` fail with `CONFIG.MIGRATION_MODULE_MISSING`.
37
+ detection:
38
+ glob: "**/*.{ts,mts,cts}"
39
+ matches:
40
+ - '@prisma/orm-framework/config/config-types'
41
+ - '@prisma/orm-toolchain/cli/config-types'
42
+ - id: extension-config-names-generated-file-modules
43
+ summary: |
44
+ An extension that has a contract of its own, emitted with a config it assembles from the framework's `defineConfig`, must name `contract.typesModule` and `migrations.module` in that config. The extension's own commands otherwise fail in the same way as an application's: see `target-package-names-generated-file-modules`.
45
+ detection:
46
+ glob: "**/prisma.config.{ts,mts,cts}"
47
+ matches:
48
+ - '@prisma/orm-framework/config/config-types'
49
+ - '@prisma/orm-toolchain/cli/config-types'
50
+ - id: family-imports-are-import-requirements
51
+ summary: |
52
+ `EmissionSpi.getFamilyImports` takes the types module and returns import requirements, where it took a function that translated module names and returned lines of import text. `ImportSpecifierResolver`, `keepInternalSpecifiers` and `resolveRequirementSpecifiers` are removed from `@prisma/orm-framework/components/emission`.
53
+ detection:
54
+ glob: "**/*.{ts,mts,cts}"
55
+ matches:
56
+ - '(?<![\w$])getFamilyImports\s*\('
57
+ - '(?<![\w$])(ImportSpecifierResolver|keepInternalSpecifiers|resolveRequirementSpecifiers)(?![\w$])'
58
+ - id: migration-renderer-takes-the-migration-module
59
+ summary: |
60
+ A migration plan's `renderTypeScript` takes the module the rendered file imports from, as a string, where it took a function that translated module names. The renderer names no module of its own.
61
+ detection:
62
+ glob: "**/*.{ts,mts,cts}"
63
+ matches:
64
+ - '(?<![\w$])renderTypeScript\s*\(\s*[^)\s]'
65
+ - id: emitter-takes-the-types-module
66
+ summary: |
67
+ In `@prisma/orm-toolchain/emitter`, `generateContractDts` takes the types module as a required fifth argument, `EmitOptions.typesModule` is required and `EmitOptions.resolveImportSpecifier` is removed, and `generateImportLines` is replaced by `typesImportRequirements`.
68
+ detection:
69
+ glob: "**/*.{ts,mts,cts}"
70
+ matches:
71
+ - '(?<![\w$])(generateContractDts|generateImportLines)\s*\('
72
+ - 'resolveImportSpecifier'
73
+ - id: mysql-config-components-carry-family-and-modules
74
+ summary: |
75
+ `MysqlConfigComponents`, the argument of `createMysqlDefineConfig` from `@prisma/orm-mysql/config`, requires `family`, `typesModule` and `migrationModule`, and its `target` and `adapter` are used as given.
76
+ detection:
77
+ glob: "**/*.{ts,mts,cts}"
78
+ matches:
79
+ - '(?<![\w$])createMysqlDefineConfig\s*\('
80
+ - id: control-api-takes-types-module
81
+ summary: |
82
+ The control client's `emit` requires `contractConfig.typesModule`, and `renderContractDts` requires `typesModule`: the module the generated contract types import from. The `projectDir` option of the control API's contract emit, `migration new` and `migration plan` operations is removed, and `preflightRefAdvancement` takes the config in its place.
83
+ detection:
84
+ glob: "**/*.{ts,mts,cts,tsx}"
85
+ matches:
86
+ - 'contractConfig\s*:'
87
+ - '(?<![\w$])renderContractDts\s*\('
88
+ - '@prisma/orm-toolchain/cli/control-api'
89
+ - id: component-type-import-module-is-not-a-literal-type
90
+ summary: |
91
+ On every Prisma target and adapter descriptor, the type of a type import's `package` is a template string type such as `` `${string}/codec-types` ``, where it was one string literal. Code that depends on the literal type compares the value instead.
92
+ detection:
93
+ glob: "**/*.{ts,mts,cts}"
94
+ matches:
95
+ - 'codecTypes\.import\.package'
96
+ - id: toolchain-publish-surface-entrypoints-removed
97
+ summary: |
98
+ `@prisma/orm-toolchain/publish-surface`, `@prisma/orm-toolchain/publish-surface/import-roots` and `@prisma/orm-toolchain/publish-surface/shells` are removed. Nothing replaces them.
99
+ detection:
100
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
101
+ matches:
102
+ - '@prisma/orm-toolchain/publish-surface'
103
+ - id: typescript-contract-from-path-requires-target
104
+ summary: |
105
+ `typescriptContractFromPath` from `@prisma/orm-family-sql/contract-ts/config-types` now takes three arguments: the contract path, the output path (or `undefined`), and an options object that must hold the configured target's pack ref as `target` and that target's `contract-builder` module as `contractBuilderModule`. Calls with one or two arguments, or with only `defaultControlPolicy` and `createNamespace`, no longer compile, and in JavaScript they throw. The detection matches TypeScript and JavaScript files that import it from the SQL family, under any name; the MongoDB family's function of the same name is unchanged.
106
+ detection:
107
+ glob: "**/*.{ts,mts,cts,js,mjs,cjs}"
108
+ matches:
109
+ - '(?<![\s\S])(?=[\s\S]*@(?:prisma/orm-family-sql|internal/sql-contract-ts)/(?:contract-ts/)?config-types)[\s\S]*\btypescriptContractFromPath\b'
110
+ - id: target-package-exports-an-init-contribution
111
+ summary: |
112
+ `prisma orm init` takes everything about a target from the target package: a package that wants `init` to set up a project on it exports an init contribution, typed `InitContribution` from `@prisma/orm-toolchain/cli/init-contribution`, as the default export of its `init` entrypoint. `@prisma/orm-postgres`, `@prisma/orm-mongo`, `@prisma/orm-sqlite` and `@prisma/orm-mysql` export one. A package without it is not affected; `init` cannot set up a project on it, and the application writes `prisma.config.ts` by hand.
113
+ - id: init-reaches-a-target-package-by-name
114
+ summary: |
115
+ `prisma orm init --target <package name>` sets up a project on any target package that exports an init contribution from its `init` entrypoint. The package needs no entry in any list of Prisma's, and must list the `prisma-orm-extension` keyword. A package without an `init` entrypoint is not affected.
116
+ - id: mysql-driver-factories-take-the-target
117
+ summary: |
118
+ `createMysqlRuntimeDriverDescriptor` and `createMysqlControlDriverDescriptor`, which build the MySQL driver for a target that extends MySQL, take an options object whose `target` is the target's runtime metadata, from which the drivers take their target id and the display name their errors show, and whose `checkViolationErrors` lists the error numbers the database reports a failed CHECK constraint with, as in `createMysqlRuntimeDriverDescriptor({ target: mariadbTargetDescriptorMetaRuntime, checkViolationErrors: [4025] })`.
119
+ detection:
120
+ glob: "**/*.{ts,mts,cts,tsx}"
121
+ matches:
122
+ - 'createMysql(?:Runtime|Control)DriverDescriptor\(\s*[''"`]'
123
+ - id: mysql-codec-descriptor-wrap-parameter
124
+ summary: |
125
+ A MySQL or MariaDB codec descriptor now has `wrapParameter(parameter, ref)`, which returns the expression a parameter of its codec is written as, and the codec registry refuses a descriptor without it. A descriptor that extends `MysqlCodecDescriptor` or is made with `mysqlCodec()` inherits it. One that implements `AnyMysqlCodecDescriptor` itself must add it.
126
+ detection:
127
+ glob: "**/*.{ts,mts,cts,tsx}"
128
+ matches:
129
+ - '\bAnyMysqlCodecDescriptor\b'
130
+ - id: adapters-report-include-capabilities
131
+ summary: |
132
+ The ORM loads includes with the one-query include only when the contract's `sql` group reports `jsonAgg`, `outerReferencesInDerivedTables` and `jsonAggWithoutTruncation`. An SQL adapter must report each of them where it is true of its database. An adapter that reports none of them gets one query per relation: its users' paged and `distinct` includes need window functions, `prepared.all()`, `prepared.first()` and `prepared.firstOrThrow()` with includes throw `ORM.CAPABILITY_MISSING`, and a read with includes runs several statements.
133
+ - id: has-one-key-must-be-unique
134
+ summary: |
135
+ Building a SQL contract fails with `CONTRACT.RELATION_INVALID` when a one-to-one relation, `rel.hasOne(Target, { by: ... })` in TypeScript, names `by` fields of the target model that no primary key, unique constraint or unique index without a `where` covers exactly. Make those fields unique, or make the relation `rel.hasMany`. PSL schemas are not affected: PSL already refused a singular back-relation over a non-unique foreign key. The detection matches TypeScript sources that declare a `hasOne` relation.
136
+ detection:
137
+ glob: "**/*.{ts,mts,cts,tsx}"
138
+ matches:
139
+ - '(?<![\w$])rel\s*\.\s*hasOne\s*\('
140
+ - id: ts-renamed-postgres-json-column-helper
141
+ summary: |
142
+ The PostgreSQL column helper `jsonColumn` is renamed `plainJsonColumn`, after the explicit type it gives (`PlainJson`, a `json` column). The old name is removed. The contract does not change. SQLite's `jsonColumn` has a rename of its own.
143
+ detection:
144
+ glob: "**/*.{ts,mts,cts,tsx}"
145
+ matches:
146
+ - '(?:import|export)[ \t]+(?:type[ \t]+)?\{[^}]*(?<![\w$])jsonColumn(?![\w$])[^}]*\}[ \t]*from[ \t]*[''"](?:@prisma/orm-postgres/adapter/column-types|@prisma/orm-target-postgres/adapter/column-types|@internal/adapter-postgres/column-types)[''"]'
147
+ - 'import[ \t]+(?:type[ \t]+)?\*[ \t]*as[ \t]+([\w$]+)[ \t]+from[ \t]*[''"](?:@prisma/orm-postgres/adapter/column-types|@prisma/orm-target-postgres/adapter/column-types|@internal/adapter-postgres/column-types)[''"][\s\S]*(?<![\w$])\1\s*\.\s*jsonColumn(?![\w$])'
148
+ - id: ts-postgres-explicit-json-type
149
+ summary: |
150
+ In `postgresExplicitTypes` and `postgresScalarTypes` from the PostgreSQL target, the explicit type of a `json` column is `PlainJson`. `postgresExplicitTypes.Json` is removed, and `postgresScalarTypes.Json` is now a type choice, not a type constructor. Read `PlainJson` where code needs the `json` type constructor.
151
+ detection:
152
+ glob: "**/*.{ts,mts,cts,tsx}"
153
+ matches:
154
+ - '(?<![\w$])postgres(?:Explicit|Scalar)Types(?:\.Json|\[[ \t]*[''"]Json[''"][ \t]*\])(?![\w$])'
155
+ - id: psl-renamed-sql-string
156
+ summary: |
157
+ The SQL family's `sql.String(n)`, a `varchar(n)` column on PostgreSQL, SQLite and MySQL, is renamed `sql.Varchar(n)`. `sql.String` stays for one release line as a deprecated alias that warns with `PSL_DEPRECATED_SCALAR_NAME`. The contract does not change.
158
+ detection:
159
+ glob: "**/*.prisma"
160
+ matches:
161
+ - '(?<![\w.])sql\s*\.\s*String\s*\('
162
+ - id: ts-renamed-sql-string
163
+ summary: |
164
+ In a TypeScript contract, `type.sql.String(n)` is renamed `type.sql.Varchar(n)`. `type.sql.String` still compiles as a deprecated alias and gives the same type and contract.
165
+ detection:
166
+ glob: "**/*.{ts,mts,cts,tsx}"
167
+ matches:
168
+ - '(?<![\w$])sql\s*\.\s*String\s*\('
169
+ - id: sqlite-decimal-codec
170
+ summary: |
171
+ On SQLite, `Decimal` is now a convenience type over the explicit type `DecimalString`, with its own codec `sqlite/decimal@1` on the same `text` column. A field written `Decimal` (or `type.Decimal()`) emitted `sqlite/text@1` before. Re-emit the contract and sign the database; no column changes and no data moves. Stored text that is not a decimal now fails to read, so find and fix such rows.
172
+ detection:
173
+ glob: "**/*.prisma"
174
+ matches:
175
+ - '(?:^|\n)[ \t]*[A-Za-z_]\w*[ \t]+Decimal(?![\w])'
176
+ - '=[ \t]*Decimal(?![\w])'
177
+ - id: ts-sqlite-decimal-codec
178
+ summary: |
179
+ In a SQLite TypeScript contract, `type.Decimal()` now emits codec `sqlite/decimal@1` instead of `sqlite/text@1`, and `type.DecimalString()` is the same type. Re-emit the contract and sign the database; no column changes and no data moves.
180
+ detection:
181
+ glob: "**/*.{ts,mts,cts,tsx}"
182
+ matches:
183
+ - '(?<![\s\S])(?=[\s\S]*[''"](?:@prisma/orm-sqlite|@internal/sqlite)/contract-builder[''"])[\s\S]*\.\s*Decimal\s*\('
184
+ - id: sqlite-bigintnumber-deprecated
185
+ summary: |
186
+ On SQLite, `BigIntNumber` is a deprecated alias of `IntegerNumber` that warns with `PSL_DEPRECATED_SCALAR_NAME`, and a field written with it now emits codec `sqlite/integer@1` instead of `sqlite/bigintnumber@1`. Write `BigInt(as: number)` (or `type.BigInt({ as: 'number' })`), or `IntegerNumber`, which the warning names; both give the same contract. Re-emit the contract and sign the database. No column changes and no data moves.
187
+ detection:
188
+ glob: "**/*.{prisma,ts,mts,cts,tsx}"
189
+ matches:
190
+ - '(?<![\w.])BigIntNumber(?![\w])'
191
+ - '\.\s*BigIntNumber\s*\('
192
+ - id: sqlite-integer-safe-range
193
+ summary: |
194
+ On SQLite, an `Int` field, and every field whose codec is `sqlite/integer@1` (`IntegerNumber`, `BigInt(as: number)`, the deprecated `BigIntNumber`), now refuses to write a number that is not an integer within ±(2^53 − 1), such as `1.5`, with `RUNTIME.ENCODE_FAILED`, and reading a stored number that is not an integer, such as a `real`, raises `RUNTIME.DECODE_FAILED` naming the table and column. Before, the codec wrote any number as it was and read such a number as it was. A stored integer outside the range, which failed to read in a row with a `RangeError` from `node:sqlite` before, now raises `RUNTIME.DECODE_FAILED` naming the table and column. `sql/int@1` checks a read the same way. Find rows that hold such values and fix them.
195
+ detection:
196
+ glob: "**/*.{prisma,ts,mts,cts,tsx}"
197
+ matches:
198
+ - '(?:^|\n)[ \t]*[A-Za-z_]\w*[ \t]+(?:Int|IntegerNumber)(?![\w])'
199
+ - '=[ \t]*(?:Int|IntegerNumber)(?![\w])'
200
+ - 'BigInt[ \t]*\([ \t]*as[ \t]*:[ \t]*number'
201
+ - '(?<![\s\S])(?=[\s\S]*[''"](?:@prisma/orm-sqlite|@internal/sqlite)/contract-builder[''"])[\s\S]*\.\s*(?:Int|IntegerNumber)\s*\('
202
+ - '(?<![\s\S])(?=[\s\S]*[''"](?:@prisma/orm-sqlite|@internal/sqlite)/contract-builder[''"])[\s\S]*\.\s*BigInt\s*\(\s*\{[^}]*as\s*:\s*[''"]number[''"]'
203
+ - '(?<![\w$])(?:integerNumberColumn|sqliteIntegerColumn)(?![\w$])'
204
+ - '(?:import|export)[ \t]+(?:type[ \t]+)?\{[^}]*(?<![\w$])integerColumn(?![\w$])[^}]*\}[ \t]*from[ \t]*[''"](?:@prisma/orm-sqlite/adapter/column-types|@prisma/orm-target-sqlite/adapter/column-types|@internal/adapter-sqlite/column-types)[''"]'
205
+ - 'import[ \t]+(?:type[ \t]+)?\*[ \t]*as[ \t]+([\w$]+)[ \t]+from[ \t]*[''"](?:@prisma/orm-sqlite/adapter/column-types|@prisma/orm-target-sqlite/adapter/column-types|@internal/adapter-sqlite/column-types)[''"][\s\S]*(?<![\w$])\1\s*\.\s*integerColumn(?![\w$])'
206
+ - id: ts-renamed-sqlite-column-helpers
207
+ summary: |
208
+ The SQLite column helpers are renamed after the explicit type each gives: `integerColumn` is `integerNumberColumn` (`IntegerNumber`), `bigintColumn` is `integerBigIntColumn` (`IntegerBigInt`) and `jsonColumn` is `plainJsonColumn` (`PlainJson`). The old names are removed. The contract does not change.
209
+ detection:
210
+ glob: "**/*.{ts,mts,cts,tsx}"
211
+ matches:
212
+ - '(?:import|export)[ \t]+(?:type[ \t]+)?\{[^}]*(?<![\w$])(?:integerColumn|bigintColumn|jsonColumn)(?![\w$])[^}]*\}[ \t]*from[ \t]*[''"](?:@prisma/orm-sqlite/adapter/column-types|@prisma/orm-target-sqlite/adapter/column-types|@internal/adapter-sqlite/column-types)[''"]'
213
+ - 'import[ \t]+(?:type[ \t]+)?\*[ \t]*as[ \t]+([\w$]+)[ \t]+from[ \t]*[''"](?:@prisma/orm-sqlite/adapter/column-types|@prisma/orm-target-sqlite/adapter/column-types|@internal/adapter-sqlite/column-types)[''"][\s\S]*(?<![\w$])\1\s*\.\s*(?:integerColumn|bigintColumn|jsonColumn)(?![\w$])'
214
+ - id: psl-renamed-mongo-int64
215
+ summary: |
216
+ On MongoDB, the explicit type `Int64` (a BSON long read as a `bigint`) is renamed `Int64BigInt`. `Int64` stays for one release line as a deprecated alias that warns with `PSL_DEPRECATED_SCALAR_NAME`. The contract does not change.
217
+ detection:
218
+ glob: "**/*.prisma"
219
+ matches:
220
+ - '(?<![\w.])Int64(?![\w])'
221
+ - id: ts-removed-mongo-int64-helper
222
+ summary: |
223
+ In a MongoDB TypeScript contract, `type.Int64()` is removed. Write `type.BigInt()`, the convenience type, or `type.Int64BigInt()`, the explicit type. Both give the same contract.
224
+ detection:
225
+ glob: "**/*.{ts,mts,cts,tsx}"
226
+ matches:
227
+ - '\.\s*Int64(?![\w])'
228
+ - '\{[^{}]*\bInt64\b[^{}]*\}\s*=\s*\w'
229
+ - id: re-emit-for-include-capabilities
230
+ summary: |
231
+ SQL adapters report two new capabilities in the `sql` group, `outerReferencesInDerivedTables` and `jsonAggWithoutTruncation`, which together with `sql.jsonAgg` decide whether the ORM loads includes with the one-query include or with one query per relation. The PostgreSQL and MySQL adapters now also report `sql.jsonAgg`. Run `prisma contract emit` to record them in `contract.json` and `contract.d.ts`. A contract that is not re-emitted keeps working, because the runtime merges the adapter's capabilities over the contract's, and the profile hash does not change, so no database needs signing again. The contract snapshots under `migrations/snapshots/` need no change.
232
+ detection:
233
+ glob: "**/contract.json"
234
+ matches:
235
+ - '(?<![\s\S])(?=[\s\S]*"targetFamily"\s*:\s*"sql")(?![\s\S]*"target"\s*:\s*"mariadb")(?![\s\S]*"jsonAggWithoutTruncation")'
236
+ - '(?<![\s\S])(?=[\s\S]*"target"\s*:\s*"mariadb")(?![\s\S]*"jsonAgg")'
237
+ - id: mysql-reemit-contract
238
+ summary: |
239
+ On MySQL and MariaDB, `Int`, `BigInt`, `Float`, `Decimal`, `String`, `Boolean`, `Bytes` and `Json` are now convenience types, and the target has new codecs for them. The emitted `contract.d.ts` gains aggregate result types for the new codecs. Re-emit the contract; its hashes do not change, so the database needs no migration and no new signature. `contract.json` changes only by the capabilities `re-emit-for-include-capabilities` describes.
240
+ detection:
241
+ glob: "**/prisma.config.{ts,mts,cts,js,mjs}"
242
+ matches:
243
+ - '[''"]@prisma/orm-(?:mysql|mariadb)/config[''"]'
244
+ - id: activity-handle-transaction-takes-callback
245
+ summary: |
246
+ An activity handle's `transaction` member, from `startActivityOn` in `@prisma/orm-family-sql/runtime` or from a runtime's `startActivity`, takes a callback: `handle.transaction(fn, options)` runs `fn` in a transaction through `withTransaction` and resolves with its result. It no longer returns a `RuntimeTransaction` for the caller to commit or roll back. The detection matches TypeScript sources that call an optional `transaction` member.
247
+ detection:
248
+ glob: "**/*.{ts,mts,cts,tsx}"
249
+ matches:
250
+ - '\.transaction\?\.\('
251
+ - id: activity-handle-transaction-and-in-transaction-required
252
+ summary: |
253
+ An activity handle, the `ActivityHandle` from `startActivityOn` or `startActivity` in `@prisma/orm-family-sql/runtime`, always has `transaction(fn, options)` and a new `inTransaction()` member. On a handle opened inside a transaction, or on a connection whose transaction is open, `transaction(fn)` runs `fn` in a savepoint, and `transaction(fn, options)` rejects with `RUNTIME.SAVEPOINT_OPTIONS_UNSUPPORTED`. An object built by hand and typed as `ActivityHandle` must have both members, and a wrapper that copies a handle member by member must forward them. The detection matches TypeScript sources that name the type or call an optional `transaction` member.
254
+ detection:
255
+ glob: "**/*.{ts,mts,cts,tsx}"
256
+ matches:
257
+ - '(?<![\w$])ActivityHandle(?![\w$])'
258
+ - '\.transaction\?\.\('
259
+ - id: activity-route-transaction-always-defined
260
+ summary: |
261
+ `ActivityRoute.transaction`, from `@prisma/orm-family-sql/runtime`, is always a function; its type no longer includes `undefined`. The detection matches TypeScript sources that name the type.
262
+ detection:
263
+ glob: "**/*.{ts,mts,cts,tsx}"
264
+ matches:
265
+ - '(?<![\w$])ActivityRoute(?![\w$])'
266
+ - id: orm-write-inside-transaction-suspends-tx
267
+ summary: |
268
+ An ORM write of more than one statement inside a transaction runs in a savepoint. While it runs, other work sent on the same transaction rejects with `RUNTIME.TRANSACTION_SUSPENDED`. When such a write fails with an error that ends the whole transaction, such as a deadlock on MySQL or MariaDB, it rejects with `RUNTIME.TRANSACTION_ROLLBACK_FAILED`, whose `cause` is the database's error, and the transaction is closed. The detection matches TypeScript sources that call `transaction` and `Promise.all` or `Promise.allSettled`.
269
+ detection:
270
+ glob: "**/*.{ts,mts,cts,tsx}"
271
+ matches:
272
+ - '(?<![\s\S])(?=[\s\S]*\.transaction\s*\()[\s\S]*Promise\.all'
273
+ - id: sql-runtime-base-own-transaction-removed
274
+ summary: |
275
+ `SqlRuntimeBase.ownTransaction` is removed, and `ActivityRoute.transaction` is now `(parent, fn, options) => Promise<R>`: it runs `fn` in a transaction beneath `parent`, usually with `withTransaction(provider, fn, options, parent)`, instead of returning a `RuntimeTransaction`. `withTransaction` takes that optional `parent` and passes it to `provider.connection({ activityParent })`. The detection matches TypeScript sources that call `ownTransaction` or build an `ActivityRoute`.
276
+ detection:
277
+ glob: "**/*.{ts,mts,cts,tsx}"
278
+ matches:
279
+ - '(?<![\w$])ownTransaction\s*\('
280
+ - '(?<![\w$])ActivityRoute(?![\w$])'
281
+ - id: orm-runtime-queryable-transaction-removed
282
+ summary: |
283
+ The ORM client's `RuntimeQueryable` type, from `@prisma/orm-family-sql/orm-client`, no longer has an optional `transaction` member. The ORM runs a write of several statements in a transaction of the call's own activity handle and never calls `transaction` on the queryable it is given. The detection matches TypeScript sources that name the type.
284
+ detection:
285
+ glob: "**/*.{ts,mts,cts,tsx}"
286
+ matches:
287
+ - '(?<![\w$])RuntimeQueryable(?![\w$])'
288
+ - id: rollback-after-commit-rejects
289
+ summary: |
290
+ `rollback()` on a runtime transaction or savepoint whose `commit()` the database applied rejects with `RUNTIME.TRANSACTION_CLOSED` and sends nothing; it used to resolve. This includes a `commit()` that rejected because an `activityEnded` hook threw after the `COMMIT`. The detection matches TypeScript sources that call `rollback()`.
291
+ detection:
292
+ glob: "**/*.{ts,mts,cts,tsx}"
293
+ matches:
294
+ - '\.rollback\s*\(\s*\)'
295
+ - id: transaction-context-has-transaction
296
+ summary: |
297
+ `TransactionContext`, from `@prisma/orm-family-sql/runtime`, has a required `transaction(fn)` member: it runs `fn` in a savepoint and passes it the savepoint's `TransactionContext`. An object an extension builds by hand and types as `TransactionContext` must have the member. A context type that extends `TransactionContext` has the member too, with a callback that receives the runtime's context, unless the extension declares its own. The detection matches TypeScript sources that name the type.
298
+ detection:
299
+ glob: "**/*.{ts,mts,cts,tsx}"
300
+ matches:
301
+ - '(?<![\w$])TransactionContext(?![\w$])'
302
+ - id: transaction-settlement-state-has-closed-and-abandon
303
+ summary: |
304
+ `TransactionSettlementState`, from `@prisma/orm-family-sql/runtime/internal/prepared-query`, has two required members: `closed`, whether the transaction is closed, and `abandon()`, which invalidates the transaction and ends its activity. An object of this type built by hand must have both; code that forwards the member of a transaction it wraps needs no change. The detection matches TypeScript sources that name the type.
305
+ detection:
306
+ glob: "**/*.{ts,mts,cts,tsx}"
307
+ matches:
308
+ - '(?<![\w$])TransactionSettlementState(?![\w$])'
309
+ - id: postgres-transaction-context-has-transaction
310
+ summary: |
311
+ `PostgresTransactionContext`, from `@prisma/orm-postgres/runtime`, has a required `transaction(fn)` member: `tx.transaction(fn)` runs `fn` in a savepoint and passes it a context of the same type. A context an extension builds for its own transactions and types as `PostgresTransactionContext` must have the member, or be typed with the runtime's `transaction` in its place. The detection matches TypeScript sources that name the type.
312
+ detection:
313
+ glob: "**/*.{ts,mts,cts,tsx}"
314
+ matches:
315
+ - '(?<![\w$])PostgresTransactionContext(?![\w$])'
316
+ - id: supabase-transaction-context-has-transaction
317
+ summary: |
318
+ `SupabaseTransactionContext`, from `@prisma/orm-extension-supabase/runtime`, is `PostgresTransactionContext`, so it has a required `transaction(fn)` member: `tx.transaction(fn)` runs `fn` in a savepoint and passes it a `SupabaseTransactionContext`. A context an extension builds for its own transactions and types as `SupabaseTransactionContext` must have the member. The detection matches TypeScript sources that name the type.
319
+ detection:
320
+ glob: "**/*.{ts,mts,cts,tsx}"
321
+ matches:
322
+ - '(?<![\w$])SupabaseTransactionContext(?![\w$])'
323
+ - id: facade-transaction-contexts-have-transaction
324
+ summary: |
325
+ `MysqlTransactionContext` (`@prisma/orm-mysql/runtime`) and `SqliteTransactionContext` (`@prisma/orm-sqlite/runtime`) declare their own `transaction(fn)` member: `tx.transaction(fn)` runs `fn` in a savepoint and passes it a context of the same type, not the runtime's `TransactionContext`. A context an extension builds for its own transactions and types as one of them must have the member. The detection matches TypeScript sources that name one of the types.
326
+ detection:
327
+ glob: "**/*.{ts,mts,cts,tsx}"
328
+ matches:
329
+ - '(?<![\w$])(?:Mysql|Sqlite)TransactionContext(?![\w$])'
330
+ - id: relation-mutator-writes-parameter
331
+ summary: |
332
+ The boolean type parameter `FilteredWritesDisabled` of `RelationMutator` (its sixth), exported from `@prisma/orm-family-sql/orm-client`, is replaced by `Writes extends 'many' | 'one' | 'none'`, which also decides whether the mutator offers the new `update(data)` and `delete()` members. The type also gains three parameters after `ParentLinkFields`: `NsId`, `ConflictActions` and `DeleteDisabled extends boolean = false`, which makes `delete` unavailable. `VariantRelationMutator` is new in this release and takes the same parameters after `VariantValue`. Code that passes the `Writes` argument replaces `false` with `'many'`, and `true` with `'one'` for a to-one relation in `update()` data or `'none'` in `create()` data. Code that leaves the argument out gets the default `'many'` and is unaffected. The types may be imported under another name; follow the local name.
333
+ detection:
334
+ glob: "**/*.{ts,mts,cts,tsx}"
335
+ matches:
336
+ - '(?<![\w$])(?:Variant)?RelationMutator\s*<'
337
+ - 'import\s+(?:type\s+)?\{[^}]*(?<![\w$])(?:Variant)?RelationMutator(?![\w$])[^}]*\}'
338
+ - id: foreign-key-with-relation-callback-refused
339
+ summary: |
340
+ `update()` data that sets a field of the foreign key the record holds for a relation (many-to-one, such as `Post.authorId` for `Post.author`) and also has a callback on that relation is refused with `ORM.ARGUMENT_INVALID` (`meta.problem: 'foreign-key-with-relation-mutation'`, with `meta.relation` and `meta.fields`) before any statement runs. It used to run, and a `create`, `connect` or `disconnect` callback overwrote the foreign key the data set. Keep either the foreign key or the callback.
341
+ - id: mongo-collection-has-prepared
342
+ summary: |
343
+ `MongoCollection`, from `@prisma/orm-mongo/orm`, has a `prepared` member (`all()`, `first()`, `firstOrThrow()`), and its `limit` and `offset` take a number or a prepared placeholder. An object you type as `MongoCollection` yourself, such as a test double, needs `prepared`, and its `limit` and `offset` must accept the wider argument.
344
+ detection:
345
+ glob: "**/*.{ts,mts,cts,tsx}"
346
+ matches:
347
+ - ':\s{0,20}MongoCollection<[^<>]{0,200}(?:<[^<>]{0,200}>[^<>]{0,200}){0,4}>\s{0,20}=\s{0,20}\{'
348
+ - '\bimplements\s{1,20}MongoCollection\b'
349
+ - id: mongo-prepare-member-moved
350
+ summary: |
351
+ `MongoPrepareMember` moved and changed meaning. It is no longer exported from `@prisma/orm-mongo/family-runtime`; it is exported from `@prisma/orm-mongo/runtime`, takes the contract as its type argument instead of codec types, and has the client's `prepare` method, which also takes an ORM read and returns `MongoPreparedFrom<Params, Q>`. `MongoRuntime` declares its own `prepare`, which takes plans only.
352
+ detection:
353
+ glob: "**/*.{ts,mts,cts,tsx}"
354
+ matches:
355
+ - '(?:import|export)\s{1,20}(?:type\s{1,20})?\{[^}]{0,300}\bMongoPrepareMember\b[^}]{0,300}\}\s{0,20}from\s{0,20}[''"]@prisma/orm-mongo/family-runtime[''"]'
356
+ - ':\s{0,20}MongoPrepareMember\b(?!\s{0,20}<)'
357
+ - id: mongo-where-filter-takes-placeholders
358
+ summary: |
359
+ `MongoWhereFilter`, from `@prisma/orm-mongo/orm`, lets each scalar field's value also be a `MongoPreparedParamRef`, the placeholder a `prepare` callback receives. Code that takes a `MongoWhereFilter` and reads a field's value as the field's type must handle the placeholder first.
360
+ detection:
361
+ glob: "**/*.{ts,mts,cts,tsx}"
362
+ matches:
363
+ - '\bMongoWhereFilter\b'
364
+ - id: compile-mongo-query-has-no-row-type
365
+ summary: |
366
+ `compileMongoQuery`, from `@prisma/orm-mongo/orm`, takes no type argument and returns `MongoQueryPlan<Record<string, unknown>>`. A call that passed a row type, `compileMongoQuery<Row>(...)`, no longer compiles.
367
+ detection:
368
+ glob: "**/*.{ts,mts,cts,tsx}"
369
+ matches:
370
+ - '\bcompileMongoQuery\s{0,20}<'
371
+ - id: runner-records-database-policies
372
+ summary: |
373
+ `MigrationRunnerPerSpaceOptions` (from `@prisma/orm-framework/components/control`) has a new optional field, `databasePolicies`. A target's migration runner that receives it sets `meta.policies` of the space's marker to it in the marker update at the end of the run, inside the run's transaction where the target has one, and leaves the rest of `meta` as it is. A run with no migrations and `databasePolicies` set still writes the marker, and writes no ledger entry. A marker write without `databasePolicies` must leave `meta` unchanged, `initMarker`'s upsert included. The `destination` that `initMarker` and `updateMarker` of `SqlControlAdapter` and `MongoControlAdapter` take is the framework's `MarkerDestination`, which carries the same optional `databasePolicies`; store it with `storedDatabasePolicies` under `DATABASE_POLICIES_META_KEY`. `MigrationRunner.execute` takes a new optional `expectedDatabasePolicies` beside `perSpaceOptions`: the policies the caller checked. Once the runner holds its marker lock, and before it applies the first space, it reads the application space's marker and calls `compareMarkerDatabasePolicies(marker, expectedDatabasePolicies)`. On `moved` it returns `databasePoliciesMovedFailure(expectedDatabasePolicies, comparison.found)` (`MIGRATION.MARKER_CAS_FAILURE` with `meta.reason: 'databasePolicies'`) without running any operation; on `unreadable` it throws `errorMarkerPoliciesCorrupt` (from `@prisma/orm-framework/errors/execution`), whose advice keeps the marker. A SQL target's runner does all of this with one call to `checkDatabasePoliciesHeld(family, driver, expectedDatabasePolicies)` from `@prisma/orm-family-sql/family/control`; a MongoDB runner compares with `compareMarkerDatabasePolicies` before its first space, and after a failed marker write asks `markerSwapFailure(found, expectedStorageHash, checkedPolicies)` from `@prisma/orm-family-mongo/family/control` why it failed. `ControlFamilyInstance.signSpaces` takes the same `expectedDatabasePolicies` beside `spaces` and compares them the same way before it writes any marker, whether or not the application space is among `spaces`; when they no longer hold it returns only a conflict for the application space with `reason: 'databasePolicies'`, `checked` and the `comparison`, and no `contract`. Every other conflict now carries `reason: 'storageHash'`. Likewise, the `MIGRATION.MARKER_CAS_FAILURE` a runner returns when the marker's storage hash moved under it carries `meta.reason: 'storageHash'` beside `space`, `expectedStorageHash`, `foundStorageHash` and `destinationStorageHash`. `MongoControlAdapter.updateMarker` takes an optional fifth argument, and `MarkerOperations.updateMarker` an optional fourth, `checkedPolicies` (`DatabasePolicies`): the policies the run checked. The update then matches only a marker whose `meta.policies` reads as them, however it is stored: no key outside `DATABASE_POLICIES_KEYS` and `DATA_PROTECTION_KEYS`, `change` as a set, each data protection setting by value, and an absent setting only where `checkedPolicies` has its default. `MarkerOperations` also has a required `markerLocation`, the collection that holds the markers, which the runner names in errors. When that update fails, `markerSwapFailure` reports a moved storage hash, moved policies, unreadable policies, or a marker changed and changed back; map them to the storage-hash failure, `databasePoliciesMovedFailure`, `errorMarkerPoliciesCorrupt`, and a `MIGRATION.MARKER_CAS_FAILURE` with `meta.reason: 'markerChanged'`. Do not retry the update. The SQL family's `insertMarker` takes `MarkerInsert`, a `MarkerDestination` without `databasePolicies`. The marker update is written when anything changed or policies are given; a ledger entry is written only when the run applied a migration edge, as before.
374
+ detection:
375
+ glob: "**/*.{ts,tsx,mts,cts}"
376
+ matches:
377
+ - '(?<![\s\S])(?![\s\S]*databasePolicies)(?=[\s\S]*\b(?:SqlControlAdapter|MongoControlAdapter|MigrationRunner)\b)[\s\S]*\b(?:initMarker|updateMarker)\s*[(:]'
378
+ - id: control-family-access-changes-of
379
+ summary: |
380
+ `ControlFamilyInstance` (from `@prisma/orm-framework/components/control`) has a new required method, `accessChangesOf(operations)`. It takes the operations of one recorded migration and returns a `MigrationAccessChange` (`{ operationIndex, subject, widens }`) for each operation that changes who can read or write data, `operationIndex` being its position in `operations`. `db migrate` refuses such a migration on a database whose data protection policy records `access-widening-forbidden`. Recognise an operation from its structure, such as its target details and the id its operation factory builds, never from its label. A family whose operations never change access returns `[]`. `SqlControlTargetDescriptor` (from `@prisma/orm-family-sql/family/control`) has a new required `accessChangesOf` with the same signature, which the SQL family instance calls; a SQL target with no operation that changes access sets `accessChangesOf: () => []`.
381
+ detection:
382
+ glob: "**/*.{ts,tsx,mts,cts}"
383
+ matches:
384
+ - '(?<![\s\S])(?![\s\S]*accessChangesOf)(?=[\s\S]*\bControlFamilyInstance\b)[\s\S]*\bstorageNameOf\s*[(:]'
385
+ - '(?<![\s\S])(?![\s\S]*accessChangesOf)(?=[\s\S]*\bSqlControlTargetDescriptor\b)[\s\S]*\bclassifyEntityKind\s*:'
386
+ - id: aggregate-planner-access-changes-of
387
+ summary: |
388
+ `planMigration(...)` and `resolveRecordedPath(...)` from `@prisma/orm-toolchain/migration-tools/aggregate` take a required `accessChangesOf(operations)` beside `storageNameOf`. The aggregate planner calls it once per recorded migration, with that migration's operations, and lists what it returns in the space's `accessChanges`, at positions in the whole path. Pass the family instance's `accessChangesOf`, or `() => []` in a test.
389
+ detection:
390
+ glob: "**/*.{ts,tsx,mts,cts}"
391
+ matches:
392
+ - '(?<![\s\S])(?![\s\S]*accessChangesOf)(?=[\s\S]*\b(?:planMigration|resolveRecordedPath)\s*\()[\s\S]*\bstorageNameOf\s*:'
393
+ - id: schema-tables-same-name
394
+ summary: |
395
+ In `@prisma/orm-family-sql/family/control`, `SchemaTables` gains a required `sameName(left, right)`: whether the database takes two table or column names for one, the comparison its `tablesNamed` and `columnsNamed` use. A `SchemaTables` or a test double of it adds `sameName`; use the new `exactName` export where names compare exactly.
396
+ detection:
397
+ glob: "**/*.{ts,mts,cts}"
398
+ matches:
399
+ - '(?<![\w$])SchemaTables(?![\w$])'
400
+ - id: plan-statements-plans-stored-name-renames
401
+ summary: |
402
+ `planStatements` from `@prisma/orm-family-sql/family/control` now plans a table or column rename for a model or field that keeps its name while its stored name changes, with no statement, whenever there is an origin contract. Its result, `PlannedStatements`, gains `alreadyRenamedTables` (tables whose rename the database already has, whose constraint renames a target puts before its creates and after the drops that free their new names) and `storageRenames` (a `StorageRenames`, or `undefined` with no origin contract). `StatementPlanningTarget` no longer extends `TableRenameByHand`.
403
+ detection:
404
+ glob: "**/*.{ts,mts,cts}"
405
+ matches:
406
+ - '(?<![\w$])(?:planStatements|PlannedStatements|StatementPlanningTarget)(?![\w$])'
407
+ - id: subjects-of-calls-storage-renames
408
+ summary: |
409
+ The context that `subjectsOfCalls` from `@prisma/orm-family-sql/family/control` takes gains a required `storageRenames`: the `storageRenames` of `planStatements`' result; `new StorageRenames([], fromContract, contract, exactName)` for a target that plans no renames; or `undefined` with no origin contract.
410
+ detection:
411
+ glob: "**/*.{ts,mts,cts}"
412
+ matches:
413
+ - '(?<![\w$])subjectsOfCalls(?![\w$])'
414
+ - id: stored-value-keep-data-edit-removed
415
+ summary: |
416
+ `StoredValueSubject.keepDataEdit` and the `keepData` and `swapsValues` fields of `StoredValueRewrite` (from `@prisma/orm-family-sql/family/control`) are gone, so the `dataLoss` entries of `CallSubjects` no longer carry `keepDataEdit`. A stored value whose member keeps its name is now rewritten by the plan, not asked about. Code that read these fields stops reading them.
417
+ detection:
418
+ glob: "**/*.{ts,mts,cts}"
419
+ matches:
420
+ - '(?<![\w$])(?:keepDataEdit|keepData|swapsValues)(?![\w$])'
421
+ - id: engine-pin-moves-to-0-10-4
422
+ summary: |
423
+ The toolchain now peers `@prisma/cli-engine@0.10.4` (up from 0.10.0). An extension package that depends on `@prisma/cli-engine` for its tests or tooling must move to `0.10.4`.
424
+ detection:
425
+ glob: "**/{package.json,pnpm-workspace.yaml}"
426
+ matches:
427
+ - '"@prisma/cli-engine":\s*"[^"]*(?<![\d.])0\.(?:\d|10\.[0123xX*])(?!\d)'
428
+ - '[''"]?@prisma/cli-engine[''"]?:\s*[''"]?(?:[\^~]|[<>]=?\s*)?0\.(?:\d|10\.[0123xX*])(?!\d)'
429
+ - id: consent-required-summary-is-one-fixed-sentence
430
+ summary: |
431
+ The first line of `CLI.CONSENT_REQUIRED` is now one fixed sentence. It no longer names the subject of a statement question, and it no longer quotes the question of a consent that `--confirm` answers. Code that matched the old first line must read the error's `code`, `why` and `meta` instead.
432
+ detection:
433
+ glob: "**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,snap,json,sh,bash,yml,yaml}"
434
+ matches:
435
+ - 'needs? a statement'
436
+ - '--yes cannot give'
437
+ - '--yes cannot grant'
438
+ - '--yes does not give it'
439
+ - 'requires explicit consent, (?:and|which)'
440
+ - 'Grant it by passing --confirm'
441
+ - 'session is not interactive'
442
+ ---
443
+
444
+ # 8.0.0-rc.24 → 8.0.0-rc.25 — Extension author upgrade instructions
445
+
446
+ The examples write the ORM client as `db.orm.public.<Model>`, which is the PostgreSQL form with its namespace. On SQLite, MySQL and MariaDB the same collection is `db.orm.<Model>`.
447
+
448
+ ## Order of the steps
449
+
450
+ Make the changes below in any order, with three exceptions:
451
+
452
+ 1. Add `pg` and `@types/pg` where they are needed, move a declared `temporal-polyfill` to `^1.0.8`, and move a declared `@prisma/cli-engine` to `0.10.4`, before you run the package manager's install for the upgrade (`pg-is-a-peer-dependency`, `extension-importing-pg-peers-it`, `temporal-polyfill-peer-range-moves-to-1-0-8`, `engine-pin-moves-to-0-10-4`).
453
+ 2. Before you run `prisma contract emit` or `prisma migration plan` for any reason in this guide, make the config changes these commands need: name the types module and the migration module (`target-package-names-generated-file-modules`, `extension-config-names-generated-file-modules`, `mysql-config-components-carry-family-and-modules`), and give `typescriptContractFromPath` its target (`typescript-contract-from-path-requires-target`). Without them, emitting fails with `CONFIG.CONTRACT_TYPES_MODULE_MISSING`.
454
+ 3. Make the changes to contract sources (`has-one-key-must-be-unique`, the renamed PostgreSQL, SQLite and MongoDB types and column helpers) before you re-emit the contract (`re-emit-for-include-capabilities`, `mysql-reemit-contract`, and the SQLite entries that say to re-emit). One emit then covers all of them.
455
+
456
+
457
+ ## Peer dependencies and the config type
458
+
459
+ ### `pg-is-a-peer-dependency`
460
+
461
+ Make this change before you run the package manager's install for the upgrade. In each `package.json` that `detection` matches, if the package's tests or scripts load the Postgres driver, make sure `devDependencies` has `pg` in a range that allows 8.22.0 or later within major version 8 and `@types/pg` in a range that allows 8.20.0 or later; add `"pg": "^8.22.0"` and `"@types/pg": "^8.20.0"` where they are missing. Without them, a test or script that loads the Postgres driver fails because Node.js cannot find the package `pg`.
462
+
463
+ ### `extension-importing-pg-peers-it`
464
+
465
+ For each published extension package whose source files `detection` matches, move `pg` and `@types/pg` out of `dependencies` if they are there, and declare them in `peerDependencies` as `"pg": "^8.22.0"` and `"@types/pg": "^8.20.0"`. Keep them in `devDependencies` too, so the extension's own tests install them. Skip files under the extension's tests: a test that imports `pg` needs only the `devDependencies` entry.
466
+
467
+ ### `temporal-polyfill-peer-range-moves-to-1-0-8`
468
+
469
+ In each `package.json`, or catalog in `pnpm-workspace.yaml`, that `detection` matches, change the `temporal-polyfill` range to `^1.0.8`, then reinstall. If the range is a reference such as `catalog:`, change the range it resolves to. A package that does not declare `temporal-polyfill` itself needs no change: its package manager installs the peer at a version inside the new range.
470
+
471
+ ### `config-type-renamed-to-prisma-config`
472
+
473
+ In every file the detection matches, rename each import, re-export and type use of `PrismaNextConfig` to `PrismaConfig`. If the file already has its own `PrismaConfig`, import the type under an alias instead, such as `import type { PrismaConfig as PrismaToolchainConfig }`, and use the alias. Leave string literals that happen to contain the text alone; they are application values, not the type. Its type parameters do not change. Then run the project's formatter, since a shorter name can let an import fit on one line.
474
+
475
+ ```ts
476
+ // Before
477
+ import type { PrismaNextConfig } from '@prisma/orm-toolchain/cli/config-types';
478
+ const config: PrismaNextConfig<'sql', 'postgres'> = defineConfig({ /* ... */ });
479
+
480
+ // After
481
+ import type { PrismaConfig } from '@prisma/orm-toolchain/cli/config-types';
482
+ const config: PrismaConfig<'sql', 'postgres'> = defineConfig({ /* ... */ });
483
+ ```
484
+
485
+
486
+ ## A target package names the modules generated files import from
487
+
488
+ Prisma no longer works out which package a generated file should import from. The package an application installs for its target says so, in the config. Prisma's own target packages do this the same way.
489
+
490
+ An extension that only contributes types, operations or codecs to an existing target, and has no contract of its own, needs none of the changes in this section, as long as each type declaration it makes states a module of its own published package.
491
+
492
+ ### `target-package-names-generated-file-modules`
493
+
494
+ This applies to a package that an application installs to use a target: one that exports a `defineConfig` built on the framework's `defineConfig`, from `@prisma/orm-framework/config/config-types` or `@prisma/orm-toolchain/cli/config-types`. It has three things to do.
495
+
496
+ **1. Export a module with the types a generated `contract.d.ts` imports.** It only re-exports: the framework's contract types, the family's, and the target's codec and operation types.
497
+
498
+ ```ts
499
+ // src/contract-types.ts, exported as <your package>/contract-types
500
+ export type * from '@prisma/orm-framework/contract/types';
501
+ export type * from '@prisma/orm-family-sql/contract/types';
502
+ export type * from './codec-types';
503
+ export type * from './operation-types';
504
+ ```
505
+
506
+ **2. State that module in the type declarations of the target and adapter you hand to the config.** `restateTypeDeclarations` returns a copy of a descriptor whose type declarations name the module you give it, keeping each name and alias. Assemble the components in one file, and build both `defineConfig` and any control client from it:
507
+
508
+ ```ts
509
+ // src/components.ts
510
+ import { restateTypeDeclarations } from '@prisma/orm-framework/target-package-config/type-declarations';
511
+
512
+ export const typesModule = 'prisma-orm-acmedb/contract-types';
513
+ export const migrationModule = 'prisma-orm-acmedb/migration';
514
+
515
+ export const target = restateTypeDeclarations(dbTarget, typesModule);
516
+ export const adapter = restateTypeDeclarations(dbAdapter, typesModule);
517
+ ```
518
+
519
+ An application on your package can import only from packages it depends on directly, which is your package and not the ones it is built from. This is what makes the generated file name yours.
520
+
521
+ **3. Name both modules in the config.**
522
+
523
+ ```ts
524
+ // src/config.ts
525
+ import { prismaContract } from '@prisma/orm-family-sql/contract-psl/provider';
526
+ import { defineConfig as defineFrameworkConfig } from '@prisma/orm-framework/config/config-types';
527
+ import { adapter, createNamespace, driver, family, migrationModule, pack, target, typesModule } from './components';
528
+
529
+ export function defineConfig(options: { contract: string; output: string }) {
530
+ return defineFrameworkConfig({
531
+ family,
532
+ target,
533
+ adapter,
534
+ driver,
535
+ contract: {
536
+ ...prismaContract(options.contract, {
537
+ output: options.output,
538
+ target: pack,
539
+ createNamespace,
540
+ }),
541
+ typesModule,
542
+ },
543
+ migrations: { module: migrationModule },
544
+ });
545
+ }
546
+ ```
547
+
548
+ `migrations.module` names the module that exports the migration base class, the command-line entry and your operation helpers: everything your migration renderer writes an import for.
549
+
550
+ Neither module may be empty, a path or a URL. Name it the way your package is imported.
551
+
552
+ Then check from outside: install your package in a scratch application from a tarball, run `prisma contract emit` and `prisma migration plan`, and typecheck with `skipLibCheck` off. Every import in the generated files should name your package, an extension's own package, or a relative path.
553
+
554
+ ### `extension-config-names-generated-file-modules`
555
+
556
+ This applies to an extension that has a contract of its own: it has a `prisma.config.ts` that imports `defineConfig` from `@prisma/orm-toolchain/cli/config-types` or `@prisma/orm-framework/config/config-types`, possibly under another name, and passes it the family, target and adapter, and it commits a generated `contract.d.ts` and migrations.
557
+
558
+ Name both modules in the object passed to that call, with a types module private to the extension package:
559
+
560
+ ```ts
561
+ contract: { ...contractSource, typesModule: '#contract-types' },
562
+ migrations: { module: '@prisma/orm-target-postgres/target/migration' },
563
+ ```
564
+
565
+ ```json
566
+ { "imports": { "#contract-types": "./src/contract-types.ts" } }
567
+ ```
568
+
569
+ `src/contract-types.ts` exports the framework's contract types, the family's, and the target's codec and operation types, as in `target-package-names-generated-file-modules` above. A relative path such as `'./contract-types'` is refused: the copy of the contract kept beside each migration is written into another folder, where that path points at nothing.
570
+
571
+ If your build inlines that module into a declaration file you publish, check that the built file still exports every type. A bundler can drop a whole-module `export type *` when it inlines the module; naming each type in the re-export avoids that.
572
+
573
+ Then run `prisma contract emit` in the extension and commit the regenerated files.
574
+
575
+ ### `family-imports-are-import-requirements`
576
+
577
+ This applies to a package that implements a family's `EmissionSpi`, from `@prisma/orm-framework/components/emission`.
578
+
579
+ ```ts
580
+ // before
581
+ getFamilyImports(resolveImportSpecifier: ImportSpecifierResolver): string[];
582
+ // after
583
+ getFamilyImports(typesModule: string): ReadonlyArray<ImportRequirement>;
584
+ ```
585
+
586
+ Return one `ImportRequirement`, from `@prisma/orm-framework/ts-render`, for each type the family's part of `contract.d.ts` uses, each with `moduleSpecifier: typesModule` and `typeOnly: true`, and with `alias` where the generated file uses the type under another name. Do not build or return import text.
587
+
588
+ `ImportSpecifierResolver`, `keepInternalSpecifiers` and `resolveRequirementSpecifiers` are removed. Nothing translates a module name any more, so remove their uses.
589
+
590
+ ### `migration-renderer-takes-the-migration-module`
591
+
592
+ This applies to a package that implements a migration planner whose plan has `renderTypeScript`.
593
+
594
+ ```ts
595
+ // before
596
+ renderTypeScript(resolveImportSpecifier: ImportSpecifierResolver): string;
597
+ // after
598
+ renderTypeScript(migrationModule: string): string;
599
+ ```
600
+
601
+ Write every import of the migration base class, the command-line entry and your operation helpers from `migrationModule`. It is the config's `migrations.module`. Remove any module name the renderer or its operations held themselves.
602
+
603
+ ### `emitter-takes-the-types-module`
604
+
605
+ This applies to code that calls the emitter directly, from `@prisma/orm-toolchain/emitter`.
606
+
607
+ - `generateContractDts` takes the types module as its fifth argument. Pass the config's `contract.typesModule`.
608
+ - In `EmitOptions`, pass `typesModule` and remove `resolveImportSpecifier`.
609
+ - `generateImportLines`, which returned lines of import text, is replaced by `typesImportRequirements`, which returns import requirements. Render them with the helper in `@prisma/orm-framework/ts-render`.
610
+
611
+ ### `mysql-config-components-carry-family-and-modules`
612
+
613
+ This applies to a package that builds its `defineConfig` with `createMysqlDefineConfig`, as a target that speaks the MySQL protocol does.
614
+
615
+ Pass three more members:
616
+
617
+ ```ts
618
+ export const defineConfig = createMysqlDefineConfig({
619
+ pack,
620
+ family,
621
+ target,
622
+ adapter,
623
+ driver,
624
+ typesModule: 'prisma-orm-acmedb/contract-types',
625
+ migrationModule: 'prisma-orm-acmedb/migration',
626
+ });
627
+ ```
628
+
629
+ - `family` is the SQL family's control descriptor. The helper no longer supplies it.
630
+ - `typesModule` and `migrationModule` are the two modules of your package that generated files import from. The helper names them in the config, so your package must export both.
631
+ - `target` and `adapter` are used as given. Restate their type declarations yourself with `restateTypeDeclarations`, as in `target-package-names-generated-file-modules` above.
632
+
633
+ ### `control-api-takes-types-module`
634
+
635
+ A script or test that calls the control client passes the module the generated contract types import from:
636
+
637
+ ```ts
638
+ await client.emit({ contractConfig: { source, output, typesModule } });
639
+ await client.renderContractDts({ contract, typesModule });
640
+ ```
641
+
642
+ Take the value from the config: `defineConfig(...).contract.typesModule`.
643
+
644
+ Code that calls the control API's operations directly, from `@prisma/orm-toolchain/cli/control-api`, removes the `projectDir` option from contract emit, `migration new` and `migration plan`, and passes the config to `preflightRefAdvancement` where it passed `projectDir`.
645
+
646
+ ### `component-type-import-module-is-not-a-literal-type`
647
+
648
+ This applies to code that reads the module of a type import from a Prisma target or adapter descriptor, such as `postgresAdapter.types.codecTypes.import.package`, and relies on its type being one exact string.
649
+
650
+ The value is unchanged. Its type is now a template string type, because the module is filled in when the package is built. Replace a type-level comparison with the exact string by a comparison of the value, or by a check of the suffix.
651
+
652
+ ### `toolchain-publish-surface-entrypoints-removed`
653
+
654
+ Remove every import of `@prisma/orm-toolchain/publish-surface` and its two subpaths. They held the table and the functions that translated module names when files were generated. That translation no longer happens, so there is nothing to call in their place.
655
+
656
+
657
+ ## A TypeScript contract must be built for the config's target
658
+
659
+ ### `typescript-contract-from-path-requires-target`
660
+
661
+ In every file the detection matches, give each call of `typescriptContractFromPath` from `@prisma/orm-family-sql/contract-ts/config-types`, under whatever name the file imports it, all three arguments. Pass the output path second, or `undefined` to keep the default beside the contract. Pass as the third an object with `target`, the pack ref of the target the config is for, and `contractBuilderModule`, that target's `contract-builder` entry, such as `@prisma/orm-postgres/contract-builder`. Keep any `defaultControlPolicy` and `createNamespace` the call already passed beside them. The option types are exported from the same entry as `TypeScriptContractFromPathOptions` and `ConfigTarget`, though an object literal is enough. The loader then refuses a contract built for another target with `CONTRACT.TARGET_MISMATCH`.
662
+
663
+ ```ts
664
+ // Before
665
+ typescriptContractFromPath('prisma/contract.ts', 'prisma/contract.json', {
666
+ defaultControlPolicy: 'external',
667
+ createNamespace: postgresCreateNamespace,
668
+ });
669
+
670
+ // After
671
+ typescriptContractFromPath('prisma/contract.ts', 'prisma/contract.json', {
672
+ target: postgresPackRef,
673
+ contractBuilderModule: '@prisma/orm-postgres/contract-builder',
674
+ defaultControlPolicy: 'external',
675
+ createNamespace: postgresCreateNamespace,
676
+ });
677
+ ```
678
+
679
+
680
+ ## `prisma orm init` sets up a project from the target package
681
+
682
+ ### `target-package-exports-an-init-contribution`
683
+
684
+ `prisma orm init` installs the target package first, then loads the default export of its `init` entrypoint and writes the project from it. The CLI holds no template for any target.
685
+
686
+ This applies to a package that adds a target and wants `prisma orm init` to set up projects on it. Nothing changes for a package that does not.
687
+
688
+ A user reaches your package with `prisma orm init --target <your package name>`; `init-reaches-a-target-package-by-name` below says what your package needs for that.
689
+
690
+ Export an `init` entrypoint whose default export satisfies `InitContribution`:
691
+
692
+ ```ts
693
+ // src/init.ts, exported as <your package>/init
694
+ import type { InitContribution } from '@prisma/orm-toolchain/cli/init-contribution';
695
+
696
+ export default {
697
+ label: 'AcmeDB',
698
+ configModule: 'prisma-orm-acmedb/config',
699
+ peerPackages: ['acmedb-driver'],
700
+ authoringModes: ['psl', 'typescript'],
701
+ starterContract: (mode) => (mode === 'psl' ? starterPsl : starterTs),
702
+ contractSample: (mode) => (mode === 'psl' ? samplePsl : sampleTs),
703
+ databaseFile: () => dbFile,
704
+ envExample: () => 'DATABASE_URL="acmedb://localhost:5000/mydb"\n',
705
+ quickReference: (input) => renderQuickReference(input),
706
+ } satisfies InitContribution;
707
+ ```
708
+
709
+ - `db.ts` and `.env.example` read the connection string from `DATABASE_URL`, and `dotenv` is installed with your package, so `db.ts` may import `dotenv/config`. `--probe-db` reads `DATABASE_URL` from the shell's environment, not from `.env`.
710
+ - `peerPackages` names the drivers your package requires as peers. `init` reads it only after your package is installed, so it cannot help a package manager that refuses to install your package without its peers. For a package Prisma lists, the list names the drivers so they go into that first install.
711
+ - `readme`, `serverRequirement`, `probe` and `prisma7QuickReference` are optional. A `probe` must settle within the 60 seconds `init` gives it. Give `prisma7QuickReference` when your `configModule` exports `prisma7Schema`.
712
+ - The entrypoint may import types from the framework, and no framework code that runs. The CLI that loads it can be a different installed copy of the framework from the one your package depends on.
713
+
714
+ ### `init-reaches-a-target-package-by-name`
715
+
716
+ ```bash
717
+ prisma orm init --target prisma-orm-acmedb --authoring psl
718
+ ```
719
+
720
+ This applies to a package that adds a target and exports an init contribution, or wants to. Nothing changes for a package that does not. The guide for the whole package is `references/build-a-target-package.md` in the `prisma-8` skill.
721
+
722
+ Check these against your package:
723
+
724
+ - **The keyword.** Add `"keywords": ["prisma-orm-extension"]` to your `package.json`. Before `init` installs a package that is not in Prisma's list of short names, it reads the package's keywords and refuses a package without this one. It reads the registry's `latest` manifest when it is about to install your package, and the installed `package.json` when the project already declares your package and has it on disk. When it cannot read your package from the registry, for example one that needs credentials or a scope's own registry, it asks the user to install your package first.
725
+ - **The package name.** `--target` takes your package's name as published, with no version or tag.
726
+ - **The first install.** `init` does not know your drivers before your package is installed, and it does not work them out from the registry. It installs your package and `dotenv`, and the package manager handles your required peer dependencies its own way. A package manager set up to refuse a package whose peers are missing fails that install, and `init` reports the failure. After loading your contribution, `init` declares its `peerPackages` in a later install. Your `init` entrypoint is loaded between the two installs, so it must load without the drivers present.
727
+ - **Other required peers.** `init` installs only `peerPackages`. Tell your users in your README about any other peer your package requires.
728
+ - **`--json`.** The result reports your package name as both `target` and `package`.
729
+ - **Prisma 7 schemas.** `init` maps the provider of a Prisma 7 schema to a target package through Prisma's list only. In a project with a Prisma 7 schema, `--target <your package>` sets up a fresh contract and leaves the schema alone, and `--from-prisma7-schema` with `--target <your package>` is refused.
730
+
731
+
732
+ ## Targets that extend MySQL
733
+
734
+ ### `mysql-driver-factories-take-the-target`
735
+
736
+ Find each call to `createMysqlRuntimeDriverDescriptor` or `createMysqlControlDriverDescriptor` that passes a target id, and pass the target's runtime metadata instead, which carries its `targetId` and its `displayName`, and the error numbers the database reports a failed CHECK constraint with (3819 on MySQL, 4025 on MariaDB):
737
+
738
+ ```ts
739
+ // was createMysqlRuntimeDriverDescriptor('mariadb')
740
+ const driver = createMysqlRuntimeDriverDescriptor({
741
+ target: mariadbTargetDescriptorMetaRuntime,
742
+ checkViolationErrors: [4025],
743
+ });
744
+ ```
745
+
746
+ A target without metadata of its own passes an object with the two fields: `{ target: { targetId: 'mariadb', displayName: 'MariaDB' }, checkViolationErrors: [4025] }`.
747
+
748
+ ### `mysql-codec-descriptor-wrap-parameter`
749
+
750
+ In each matched file, find any object or class that implements `AnyMysqlCodecDescriptor` itself, without extending `MysqlCodecDescriptor` (from `@prisma/orm-target-mysql/target/codec-descriptor`) or being made with `mysqlCodec()`. If a matched file gives the type another name, such as `type CustomDescriptor = AnyMysqlCodecDescriptor`, search the project for that name too: a descriptor typed through it can sit in a file this step does not match. The same holds for a descriptor written as a plain object with no type: check every descriptor your extension gives a MySQL or MariaDB client in its codec list, since the codec registry refuses one without the method with `RUNTIME.CODEC_DESCRIPTOR_INVALID`. Give each such descriptor a `wrapParameter` method that returns the parameter it is given:
751
+
752
+ ```ts
753
+ import type { CodecRef } from '@prisma/orm-framework/components/codec';
754
+ import type { AnyExpression, AnyParamRef } from '@prisma/orm-family-sql/relational-core/ast';
755
+
756
+ wrapParameter(parameter: AnyParamRef, _ref: CodecRef): AnyExpression {
757
+ return parameter;
758
+ }
759
+ ```
760
+
761
+ The MySQL renderer calls it for every parameter of the codec but those of `LIMIT` and `OFFSET`, with the parameter as an expression and the codec reference, which carries the column's type parameters, and writes the expression it returns into the statement. Return an expression around the parameter only when the server must read the value as a particular type, as MySQL's own `mysql/decimal@1` returns `CastExpr.as(parameter, 'DECIMAL(65,30)')` for a column with at most 35 digits before the point, and a cast with fewer digits after the point for a wider column, read from the type parameters of the codec reference. The expression must hold the parameter exactly once, or the renderer refuses the statement with `RUNTIME.CODEC_DESCRIPTOR_INVALID`. Without the method, building the codec registry fails with `RUNTIME.CODEC_DESCRIPTOR_INVALID`. A file that only uses `AnyMysqlCodecDescriptor` as a type, such as the type of a parameter, needs no change.
762
+
763
+
764
+ ## SQL adapters report the include capabilities
765
+
766
+ ### `adapters-report-include-capabilities`
767
+
768
+ Add the three keys to your adapter's `sql` capability group, each set to `true` only where your database meets it:
769
+
770
+ - `jsonAgg`: the database aggregates rows into a JSON array.
771
+ - `outerReferencesInDerivedTables`: a reference to the outer query resolves inside a derived table in a subquery.
772
+ - `jsonAggWithoutTruncation`: an oversized JSON aggregate fails or cannot be decoded, and never comes back as a shorter valid array.
773
+
774
+ ```ts
775
+ export const myAdapterCapabilities = {
776
+ sql: {
777
+ jsonAgg: true,
778
+ outerReferencesInDerivedTables: true,
779
+ jsonAggWithoutTruncation: true,
780
+ },
781
+ };
782
+ ```
783
+
784
+ If your database lacks any of them, leave that key out or set it to `false`. The ORM then loads each include with one query per relation, and your users meet these differences:
785
+
786
+ - A paged include (`limit` or `offset`) and a `distinct()` include are numbered with `ROW_NUMBER()`, so the database needs window functions.
787
+ - `prepared.all()`, `prepared.first()` and `prepared.firstOrThrow()` with includes throw `ORM.CAPABILITY_MISSING`, because a prepared read is one statement.
788
+ - A read with includes sends one statement for its rows and one for each included relation, outside a transaction.
789
+
790
+
791
+ ## A `hasOne` relation needs a unique key on the target
792
+
793
+ ### `has-one-key-must-be-unique`
794
+
795
+ A `hasOne` relation says that at most one row of the target model points at each row of this model. The SQL contract build now checks that the target's `by` fields are unique. They are unique when one of these covers exactly those fields, in any order:
796
+
797
+ - the target's primary key;
798
+ - a unique constraint (`.unique()` on the field, or `constraints.unique([...])` in `.attributes()`);
799
+ - a unique index (`constraints.index([...], { unique: true })` in `.sql()`) without a `where`.
800
+
801
+ A unique constraint over more fields than `by`, or over only some of them, does not count. When none matches, `prisma contract emit` and `defineContract` fail:
802
+
803
+ ```text
804
+ CONTRACT.RELATION_INVALID: Relation "User.profile" is one-to-one, but the fields "userId" of model "Profile" are not unique. Add a unique constraint over exactly those fields, or make "profile" a hasMany relation.
805
+ ```
806
+
807
+ In every file the detection matches, find each `rel.hasOne(Target, { by: ... })` whose `by` fields of `Target` are not unique, and apply one of the two fixes below. Then re-emit the contract with `prisma contract emit`.
808
+
809
+ **Each parent has at most one related row: make the key unique.** Add a unique constraint over exactly the `by` fields of the target model. For one field, use `.unique()`:
810
+
811
+ ```ts
812
+ // Before
813
+ const Profile = model('Profile', {
814
+ fields: {
815
+ id: field.column(int4Column).id(),
816
+ userId: field.column(int4Column),
817
+ },
818
+ });
819
+
820
+ // After
821
+ const Profile = model('Profile', {
822
+ fields: {
823
+ id: field.column(int4Column).id(),
824
+ userId: field.column(int4Column).unique(),
825
+ },
826
+ });
827
+ ```
828
+
829
+ For several fields, add `constraints.unique([fields.a, fields.b])` to the target's `.attributes()`. The contract's storage gains a unique constraint, so plan and apply a migration for it. The migration fails if the table already holds two rows with the same key; remove the duplicates first.
830
+
831
+ **A parent can have several related rows: use `hasMany`.** Replace `rel.hasOne(Target, { by })` with `rel.hasMany(Target, { by })`. The relation then reads as an array of rows instead of one row or `null`, so update the code that reads or writes it.
832
+
833
+
834
+ ## PostgreSQL's `Json` is a convenience type, and `sql.String` is `sql.Varchar`
835
+
836
+ On PostgreSQL, `Json` is now a convenience type, as `Int` and `String` are. Its optional `storage` argument chooses the column: `Json` and `Json(storage: json)` are a `json` column, and `Json(storage: jsonb)` is a `jsonb` column. Written bare, `Json` gives the same `json` column as before, so schemas need no change and every contract stays the same. `Jsonb` is unchanged.
837
+
838
+ The explicit type of a `json` column is named `PlainJson`, and the column helper is renamed to match it.
839
+
840
+ On every SQL target, `sql.String(n)` is renamed `sql.Varchar(n)`, with `sql.String` kept as a deprecated alias.
841
+
842
+ ### `ts-renamed-postgres-json-column-helper`
843
+
844
+ The detection matches a file that imports or re-exports `jsonColumn` from `@prisma/orm-postgres/adapter/column-types`, `@prisma/orm-target-postgres/adapter/column-types` or the Prisma repository's workspace package for it, or imports one of them as a namespace and reads `jsonColumn` from it. In that file, rename the import or re-export and every use of the name. Any other form, such as a dynamic import, fails type-checking because the export is gone; rename it where the compiler reports it:
845
+
846
+ ```ts
847
+ import { plainJsonColumn } from '@prisma/orm-postgres/adapter/column-types';
848
+
849
+ field.column(plainJsonColumn); // was jsonColumn
850
+ ```
851
+
852
+ `field.column(type.Json())` and `field.column(type.PlainJson())` give the same column. A file that imports `jsonColumn` from a SQLite package is covered by `ts-renamed-sqlite-column-helpers`, not this one.
853
+
854
+ ### `ts-postgres-explicit-json-type`
855
+
856
+ Read the `json` type constructor as `PlainJson`:
857
+
858
+ ```ts
859
+ import { postgresExplicitTypes } from '@prisma/orm-target-postgres/target';
860
+
861
+ postgresExplicitTypes.PlainJson.output.codecId; // was postgresExplicitTypes.Json, 'pg/json@1'
862
+ ```
863
+
864
+ `postgresScalarTypes.Json` is the convenience type, a type choice whose `storage` option picks `PlainJson` or `Jsonb`. Code that reads `.output` from it, or treats it as a type constructor, reads `postgresScalarTypes.PlainJson` instead.
865
+
866
+ ### `psl-renamed-sql-string`
867
+
868
+ `sql.String(n)` shared a name with the `String` convenience type and meant something else: a `varchar(n)` column. It is renamed `sql.Varchar(n)`. In each matched schema, replace `sql.String(` with `sql.Varchar(`, in fields and in `types {}` aliases:
869
+
870
+ ```prisma
871
+ model Label {
872
+ id Int @id
873
+ name sql.Varchar(50) // was sql.String(50)
874
+ }
875
+ ```
876
+
877
+ The contract does not change. `sql.Char(n)` keeps its name.
878
+
879
+ ### `ts-renamed-sql-string`
880
+
881
+ In each matched file, rename every `sql.String` call to `sql.Varchar`, including a call split across lines such as `type.sql` and `.String(64)` on the next line:
882
+
883
+ ```ts
884
+ field.column(type.sql.Varchar(50)); // was type.sql.String(50)
885
+ ```
886
+
887
+ The contract does not change.
888
+
889
+
890
+ ## SQLite scalars get convenience types
891
+
892
+ On SQLite, `Int`, `BigInt`, `Float`, `Decimal`, `String`, `Boolean`, `Bytes` and `Json` are now convenience types, as on PostgreSQL and MongoDB. Each chooses one explicit type: `Int` is `IntegerNumber`, `BigInt` is `IntegerBigInt`, `BigInt(as: number)` is `IntegerNumber`, `Float` is `Real`, `Decimal` is `DecimalString`, `String` is `Text`, `Boolean` is `IntegerBoolean`, `Bytes` is `Blob` and `Json` is `PlainJson`. An explicit type is named after the SQLite column type that stores it: `Text`, `Real` and `Blob`. `integer` is read by more than one codec of its data type, so those types carry the value too: `IntegerNumber` and `IntegerBigInt`. A type with a data type of its own, which a `text` column stores, is named after that data type: `DecimalString`, `PlainJson` and the date and time types. `IntegerBoolean` is an exception: `sqlite/boolean` is a data type of its own, which an `integer` column stores, and its name takes the form of the other `integer` types. Written bare, `Int`, `BigInt`, `Float`, `String`, `Bytes` and `Json` give the same codec as before.
893
+
894
+ Two names change the contract. A `Decimal` field gets its own codec, `sqlite/decimal@1`, where it was the same codec as `String`. `BigIntNumber` is a deprecated alias of `IntegerNumber`, so its codec id changes. Neither changes a column, and no data moves.
895
+
896
+ `Boolean` is new on SQLite: a schema can now write a `Boolean` field, or `type.Boolean()` in a TypeScript contract. It is an `integer` column holding 1 for `true` and 0 for `false`, which is what SQLite's own `TRUE` and `FALSE` are, with its own codec `sqlite/boolean@1`. `@default(true)` is written `DEFAULT 1`. A stored value other than 0 or 1 raises `RUNTIME.DECODE_FAILED`, naming the column. A field takes equality filters, and is not ordered or summed. No existing schema used it, so nothing changes for one.
897
+
898
+ `Int` and every other field on the codec `sqlite/integer@1` now checks that a value is an integer within the safe integer range, as `BigIntNumber` did; see `sqlite-integer-safe-range`.
899
+
900
+ A `BigInt` field now reads every stored 64-bit integer. Before, reading a row that held an integer outside ±(2^53 − 1) failed in `node:sqlite` with a `RangeError` whose code is `ERR_OUT_OF_RANGE`, so only a read through an `include()` or a `sumBigInt` gave the value. Nothing in the schema changes for it. A value read without an integer codec, such as a column of a raw SQL query, is now a `number` within the safe integer range and an exact `bigint` outside it, where the read threw before. `JSON.stringify` throws on a `bigint`, so code that serializes such a row prints the value with `String(value)`. A `BigInt` field also refuses to write a `bigint` outside the signed 64-bit range with `RUNTIME.ENCODE_FAILED`, where `node:sqlite` threw a `TypeError` before.
901
+
902
+ The column helpers of the TypeScript contract builder are renamed after the explicit type each gives, and `decimalStringColumn` and `integerBooleanColumn` are new.
903
+
904
+ ### Sign the database with the new contract
905
+
906
+ The `Decimal` and `BigIntNumber` changes below change the contract's storage hash, so `db verify` reports `CONTRACT.MARKER_MISMATCH` until the database is signed with the new contract. After re-emitting the contract:
907
+
908
+ - In a project with migrations, run `migration plan --from <latest migration>`, where `<latest migration>` is the name of the newest folder under `migrations/`. It writes a migration with no operations, which names the changed table, and `db migrate` applies it and signs the database. No table is rebuilt. Without `--from`, `migration plan` starts from the `db` ref. A project that applied its migrations with `db migrate` before this release, without `--advance-ref`, has none, so the command refuses with `MIGRATION.PLAN_ORIGIN_UNKNOWN`.
909
+ - In a project without migrations, run `db update`. It runs no operation and signs the database.
910
+
911
+ `db verify --schema-only` passes before and after: the columns are the same.
912
+
913
+ ### `sqlite-decimal-codec`
914
+
915
+ This applies to a schema whose target is SQLite. On PostgreSQL and MongoDB, `Decimal` does not change; skip this entry there. The detection matches every schema with a field or a `types {}` alias written `Decimal`, whatever its target.
916
+
917
+ Nothing in the schema changes. Re-emit the contract: each `Decimal` field's column now has codec `sqlite/decimal@1` and data type `sqlite/decimal` where it had `sqlite/text@1`. Then sign the database as described above.
918
+
919
+ `sqlite/decimal@1` reads and writes decimal text such as `"12.50"`, as before. It now refuses to write text that is not a decimal, and reading stored text that is not a decimal raises `RUNTIME.DECODE_FAILED`, naming the column. Such text is most often the `''` that an earlier migration wrote into the rows of a new required `Decimal` column; a new required column is now filled with `'0'`. Find those rows with this query, putting in each `Decimal` column and its table:
920
+
921
+ ```sql
922
+ SELECT rowid, "price"
923
+ FROM "product"
924
+ WHERE "price" IS NOT NULL
925
+ AND NOT (
926
+ typeof("price") = 'text'
927
+ AND ltrim("price", '-') <> ''
928
+ AND length("price") - length(ltrim("price", '-')) <= 1
929
+ AND ltrim("price", '-') NOT GLOB '*[^0-9.]*'
930
+ AND ltrim("price", '-') NOT GLOB '*.*.*'
931
+ AND ltrim("price", '-') NOT GLOB '.*'
932
+ AND ltrim("price", '-') NOT GLOB '*.'
933
+ );
934
+ ```
935
+
936
+ Set each row it returns to a decimal, such as `UPDATE "product" SET "price" = '0' WHERE "price" = '';`, or make the field optional and set it to `NULL`.
937
+
938
+ Stored text that is a decimal but has leading zeros or a minus sign on zero, such as `"0012.50"` or `"-0"`, stays as it is and still reads. An equality filter no longer finds it: the codec now writes a value, and compares a filter value, without the leading zeros or the minus sign on zero, so a filter for `"0012.50"` looks for `"12.50"`. This query returns those rows:
939
+
940
+ ```sql
941
+ SELECT rowid, "price"
942
+ FROM "product"
943
+ WHERE ltrim("price", '-') GLOB '0[0-9]*'
944
+ OR ("price" GLOB '-*' AND ltrim("price", '-0.') = '');
945
+ ```
946
+
947
+ Set each row it returns to the same number without the leading zeros or the minus sign on zero, such as `UPDATE "product" SET "price" = '12.50' WHERE "price" = '0012.50';`.
948
+
949
+ A `Decimal` field can be compared for equality only. Text compares by its characters, so `"1.5"` and `"1.50"` are different values, and ordering, the text filter `like` and aggregates such as `sum` and `max` are not offered; code that used them on a `Decimal` field no longer type-checks. A `Decimal` default may be written as text, `@default("12.50")`, or as a whole number, `@default(3)`. A number with a fraction, such as `@default(1.5)`, is refused when the contract is emitted, with `Expected a quoted string or a number that sqlite/decimal can hold; got sqlite/real`: write it as text, `@default("1.5")`.
950
+
951
+ Leave the `contract.prisma` copy inside each migration folder under `migrations/` as it is: it records the schema that migration was planned from.
952
+
953
+ ### `ts-sqlite-decimal-codec`
954
+
955
+ In a SQLite TypeScript contract, `type.Decimal()` and `type.DecimalString()` give the same column, with codec `sqlite/decimal@1`. The code does not change. Re-emit the contract and sign the database as described above; the notes under `sqlite-decimal-codec` about stored text that is not a decimal, equality and the column's values apply here too. A file that matches only because another library's `Decimal(` is called in it needs no change.
956
+
957
+ ### `sqlite-bigintnumber-deprecated`
958
+
959
+ This applies to a SQLite schema or TypeScript contract. On PostgreSQL, `BigIntNumber` was deprecated in an earlier release; skip this entry there.
960
+
961
+ In each matched SQLite schema, replace the type `BigIntNumber` with `BigInt(as: number)`, in fields, value object members and `types {}` aliases. In a SQLite TypeScript contract, replace `type.BigIntNumber()` with `type.BigInt({ as: 'number' })`. The deprecation warning names `IntegerNumber`, the explicit type, which gives the same contract as `BigInt(as: number)`; either is right:
962
+
963
+ ```prisma
964
+ model Post {
965
+ id Int @id
966
+ viewCount BigInt(as: number) // was BigIntNumber
967
+ }
968
+ ```
969
+
970
+ `Int` gives the same column too. The field's codec id changes from `sqlite/bigintnumber@1` to `sqlite/integer@1`, which writes and reads a `number` within the safe integer range, as `sqlite/bigintnumber@1` did; `sqlite-integer-safe-range` says what a value outside it raises. Re-emit the contract and sign the database as described above.
971
+
972
+ `sqlite/bigintnumber@1` stays: `count()` and the `sum` of an integer column still read their result through it, so a reference to it in generated `contract.d.ts` aggregate types is expected. A file that matches only because a comment or a string mentions `BigIntNumber` needs no change. Leave the `contract.prisma` copy inside each migration folder under `migrations/` as it is.
973
+
974
+ ### `sqlite-integer-safe-range`
975
+
976
+ This applies to a SQLite schema or TypeScript contract. On PostgreSQL and MongoDB, `Int` does not change; skip this entry there. The detection matches every schema with an `Int` field, whatever its target, because the change is to what the codec accepts, not to how the field is written.
977
+
978
+ Nothing in the schema or the contract changes. The codec `sqlite/integer@1`, which `Int`, `IntegerNumber`, `BigInt(as: number)` and the deprecated `BigIntNumber` give, now checks every value in both directions:
979
+
980
+ - A write of a number that is not an integer, such as `1.5`, or of an integer outside ±(2^53 − 1), the range a JavaScript `number` holds exactly, fails with `RUNTIME.ENCODE_FAILED` before any SQL runs, as in `sqlite/integer@1 value must be an integer within the safe integer range, got 1.5`. Before, the number was written as it was: SQLite stored `1.5` as a `real` in the `integer` column, and an integer past the range had already lost digits in the JavaScript `number` before it was written. Round the value in the application, or give the field `BigInt` if it needs the full 64-bit range.
981
+ - A read of a stored number that is not an integer, such as the `real` `1.5` an earlier write stored, fails with `RUNTIME.DECODE_FAILED` and names the table and column, as in `Column "line_item"."quantity" holds 1.5, which is not an integer within the safe integer range.` Before, a read of the row gave the number as it was, and a read through an `include()` already failed.
982
+ - A read of a stored integer outside the range fails with `RUNTIME.DECODE_FAILED` and names the table and column, in a row and through an `include()`, as in `Column "line_item"."quantity" holds 9007199254740993, which is not an integer within the safe integer range.` Before, a read of the row failed in `node:sqlite` before any codec ran, with a `RangeError` whose code is `ERR_OUT_OF_RANGE` and which named no column, and a read through an `include()` already raised `RUNTIME.DECODE_FAILED`.
983
+ - A stored blob fails with `RUNTIME.DECODE_FAILED` and names the table and column, in a row and through an `include()`, as in `Column "line_item"."quantity" holds bytes x'35', which is not an integer within the safe integer range.` `sql/int@1` reads a blob the same way. Before, some blobs were read as a number: in a row a one-byte blob read as the value of its byte, so `x'07'` read as 7, and a longer blob such as `x'3132'` was refused; through an `include()` a blob whose bytes spell digits read as that number, so `x'3132'` read as 12.
984
+
985
+ `sql/int@1`, which a TypeScript contract can name on SQLite, reads the same way: a stored number that is not an integer, an integer outside the range and a blob each raise `RUNTIME.DECODE_FAILED` naming the table and column. Before, it read a stored number in a row as it was.
986
+
987
+ Find such rows with this query, putting in each `Int` column and its table:
988
+
989
+ ```sql
990
+ SELECT rowid, "quantity"
991
+ FROM "line_item"
992
+ WHERE "quantity" IS NOT NULL
993
+ AND (
994
+ typeof("quantity") <> 'integer'
995
+ OR "quantity" > 9007199254740991
996
+ OR "quantity" < -9007199254740991
997
+ );
998
+ ```
999
+
1000
+ Set each row it returns to an integer within the range. A fraction inside the range can be rounded, such as `UPDATE "line_item" SET "quantity" = CAST(round("quantity") AS INTEGER) WHERE typeof("quantity") = 'real' AND abs("quantity") <= 9007199254740991;`. A value outside the range cannot be repaired by a cast, which stops at the 64-bit limit and stays outside the range: set it to the value the application means, or change the field to `BigInt`, which reads the full 64-bit range. Run the query again afterward; the upgrade is done when it returns no rows. A project whose rows the query does not return needs no change.
1001
+
1002
+ ### `ts-renamed-sqlite-column-helpers`
1003
+
1004
+ The detection matches a file that imports or re-exports `integerColumn`, `bigintColumn` or `jsonColumn` from `@prisma/orm-sqlite/adapter/column-types` or `@prisma/orm-target-sqlite/adapter/column-types`, or imports one of them as a namespace and reads one of those names from it. In that file, rename the import or re-export and every use of the name:
1005
+
1006
+ | Old name | New name | Explicit type |
1007
+ | --- | --- | --- |
1008
+ | `integerColumn` | `integerNumberColumn` | `IntegerNumber`, codec `sqlite/integer@1` |
1009
+ | `bigintColumn` | `integerBigIntColumn` | `IntegerBigInt`, codec `sqlite/bigint@1` |
1010
+ | `jsonColumn` | `plainJsonColumn` | `PlainJson`, codec `sqlite/json@1` |
1011
+
1012
+ ```ts
1013
+ import { integerNumberColumn, plainJsonColumn } from '@prisma/orm-sqlite/adapter/column-types';
1014
+
1015
+ field.column(integerNumberColumn); // was integerColumn
1016
+ field.column(plainJsonColumn); // was jsonColumn
1017
+ ```
1018
+
1019
+ Any other form, such as a dynamic import, fails type-checking because the export is gone; rename it where the compiler reports it. `field.column(type.Int())` and `field.column(type.IntegerNumber())` give the same column. A file that imports `jsonColumn` from a PostgreSQL package is covered by `ts-renamed-postgres-json-column-helper`, not this one. `textColumn`, `realColumn` and `blobColumn` keep their names. `decimalStringColumn` is new and gives `DecimalString`, codec `sqlite/decimal@1`, and `integerBooleanColumn` is new and gives `IntegerBoolean`, codec `sqlite/boolean@1`.
1020
+
1021
+
1022
+ ## MongoDB scalars get convenience types
1023
+
1024
+ On MongoDB, `Int`, `BigInt`, `Float`, `Decimal`, `Boolean`, `Bytes`, `String` and `Json` are now convenience types, as on PostgreSQL. Each chooses one explicit type named after the BSON type that stores it: `Int` is `Int32`, `BigInt` is `Int64BigInt`, `BigInt(as: number)` is `Int64Number`, `Float` is `Double`, `Decimal` is `Decimal128`, `Boolean` is `Bool`, `Bytes` is `Binary`, `String` is `BsonString` and `Json` is `PlainJson`. Every contract stays the same.
1025
+
1026
+ `Int`, `Float` and `Boolean` no longer warn, and `type.Int()`, `type.Float()` and `type.Boolean()` exist again. `BigInt`, `Bytes` and `Decimal`, which MongoDB refused before, now resolve.
1027
+
1028
+ ### `psl-renamed-mongo-int64`
1029
+
1030
+ In each matched schema, replace the type `Int64` with `BigInt`, the convenience type, or `Int64BigInt`, the explicit type. Do this in fields, value object members and `types {}` aliases. Leave `Int64Number` as it is, or write it `BigInt(as: number)`:
1031
+
1032
+ ```prisma
1033
+ model Post {
1034
+ id ObjectId @id @map("_id")
1035
+ views BigInt // was Int64
1036
+ }
1037
+ ```
1038
+
1039
+ The contract does not change. A file that matches only because a comment or a string mentions `Int64` needs no change. Leave the `contract.prisma` copy inside each migration folder under `migrations/` as it is: it records the schema that migration was planned from, and `Int64` still reads there as the same type.
1040
+
1041
+ ### `ts-removed-mongo-int64-helper`
1042
+
1043
+ In each matched file, replace every `Int64` read from the `type` helpers with `BigInt` or `Int64BigInt`. This covers a call, a call split across lines, and a read with no call, such as `const long = type.Int64`:
1044
+
1045
+ ```ts
1046
+ field.scalar(type.BigInt()); // was type.Int64()
1047
+ ```
1048
+
1049
+ A helper taken out of `type` by destructuring, such as `const { Int64 } = type`, also matches. Take out `BigInt` or `Int64BigInt` instead and rename its calls. The contract does not change. A file that matches only because a comment mentions `.Int64`, or because it uses another library's `Int64`, such as Apache Arrow's `new arrow.Int64()`, needs no change.
1050
+
1051
+
1052
+ ## Re-emit SQL contracts
1053
+
1054
+ ### `re-emit-for-include-capabilities`
1055
+
1056
+ Run `prisma contract emit` for every SQL contract. The emitted `capabilities.sql` gains the new keys the adapter reports:
1057
+
1058
+ ```json
1059
+ "sql": {
1060
+ "jsonAgg": true,
1061
+ "jsonAggWithoutTruncation": true,
1062
+ "outerReferencesInDerivedTables": true
1063
+ }
1064
+ ```
1065
+
1066
+ A MariaDB contract gains only `"jsonAgg": true`: MariaDB does not report the other two, and the emitter leaves out a capability that is `false`. Without them the ORM loads includes on MariaDB with one query per relation.
1067
+
1068
+ ### `mysql-reemit-contract`
1069
+
1070
+ On MySQL and MariaDB, `Int`, `BigInt`, `Float`, `Decimal`, `String`, `Boolean`, `Bytes` and `Json` are now convenience types, as on PostgreSQL, SQLite and MongoDB. Each chooses one explicit type named after the MySQL column type that stores it: `Int` is `Int4`, `BigInt` is `Int8BigInt`, `BigInt(as: number)` is `Int8Number`, `Float` is `Float8` (a `double`), `Decimal` is `NumericString(65, 30)`, `String` is `Varchar(191)` and `String(storage: text)` is `Text`, `Boolean` is `Bool` (a `tinyint(1)`), `Bytes` is `Longblob` and `Json` is `PlainJson`. A field written `Int`, `BigInt` or `String` gives the same codec as before, so no schema needs a change.
1071
+
1072
+ In each matched project, emit the contract again:
1073
+
1074
+ ```bash
1075
+ pnpm prisma contract emit
1076
+ ```
1077
+
1078
+ The generated `contract.d.ts` gains entries under `AggregateTypes` for the new codecs, such as `sum` over `mysql/decimal@1` and `avg` over `mysql/double@1`. The hashes in `contract.json` do not change, so the database's signature stays as it is and no migration is needed; `contract.json` changes only by the capabilities `re-emit-for-include-capabilities` describes. Leave the `contract.d.ts` copy inside each migration snapshot under `migrations/snapshots/` as it is.
1079
+
1080
+ A SQL contract on MySQL or MariaDB is emitted once for this entry and `re-emit-for-include-capabilities`.
1081
+
1082
+
1083
+ ## An activity handle runs `transaction(fn)` through `withTransaction`
1084
+
1085
+ ### `activity-handle-transaction-takes-callback`
1086
+
1087
+ Where code calls `transaction` on an activity handle, pass the work as a callback and drop the `commit()` and `rollback()` calls. The callback receives the same context `withTransaction` passes to its callback. `withTransaction` commits when the callback resolves, rolls back when it throws, and gives the connection back. A failed `COMMIT` rejects with `RUNTIME.TRANSACTION_COMMIT_FAILED` and a failed `ROLLBACK` after a callback error with `RUNTIME.TRANSACTION_ROLLBACK_FAILED`, each with the original error as `cause`. Code that matched on the driver's error from those calls matches on these codes instead. Leave calls on a connection, `connection.transaction(options)`, as they are; only the handle's member changed.
1088
+
1089
+ Before:
1090
+
1091
+ ```ts
1092
+ const tx = await handle.transaction?.(options);
1093
+ if (tx) {
1094
+ try {
1095
+ const result = await work(tx);
1096
+ await tx.commit();
1097
+ return result;
1098
+ } catch (error) {
1099
+ await tx.rollback();
1100
+ throw error;
1101
+ }
1102
+ }
1103
+ ```
1104
+
1105
+ After:
1106
+
1107
+ ```ts
1108
+ return handle.inTransaction()
1109
+ ? handle.transaction((tx) => work(tx))
1110
+ : handle.transaction((tx) => work(tx), options);
1111
+ ```
1112
+
1113
+ The member is always there (`activity-handle-transaction-and-in-transaction-required`), so the test for it goes too. On a handle opened inside a transaction the callback runs in a savepoint, and passing options there rejects with `RUNTIME.SAVEPOINT_OPTIONS_UNSUPPORTED`, so pass them only outside a transaction.
1114
+
1115
+ A handle opened on a connection the caller holds runs the transaction on that connection and leaves it held after a commit or a rollback. After a failed `BEGIN`, a failed `ROLLBACK` or a timeout the connection is destroyed, and a later `release()` by its holder rejects.
1116
+
1117
+ ### `activity-handle-transaction-and-in-transaction-required`
1118
+
1119
+ Drop the optional call on a handle's `transaction`: write `handle.transaction(...)` in place of `handle.transaction?.(...)`. Code that tested for the member, such as `'transaction' in handle` or `handle.transaction === undefined`, to learn whether the handle was opened inside a transaction calls `handle.inTransaction()` instead. Inside a transaction, call `handle.transaction(fn)` without options.
1120
+
1121
+ An object built by hand and typed as `ActivityHandle`, such as a stub in a test, gains both members:
1122
+
1123
+ ```ts
1124
+ const handle: ActivityHandle<'my-call'> = {
1125
+ ...members,
1126
+ transaction: (fn, options) => inner.transaction(fn, options),
1127
+ inTransaction: () => inner.inTransaction(),
1128
+ };
1129
+ ```
1130
+
1131
+ A wrapper that copies a handle's members by name, for example to record the statements it sends, forwards `inTransaction` too. Without it the ORM treats the handle as outside a transaction and passes its implicit transaction options, and on a facade that sets them, such as MySQL's, a write of several statements inside a transaction rejects with `RUNTIME.SAVEPOINT_OPTIONS_UNSUPPORTED`.
1132
+
1133
+ ### `activity-route-transaction-always-defined`
1134
+
1135
+ A `SqlRuntimeBase` subclass that builds an `ActivityRoute` sets `transaction` to a function; `transaction: undefined` no longer typechecks. Remove checks of the member for `undefined`. `sql-runtime-base-own-transaction-removed` below gives the function's new shape.
1136
+
1137
+ ### `orm-write-inside-transaction-suspends-tx`
1138
+
1139
+ Where code runs an ORM write of several statements, such as a create with a nested relation, at the same time as other work on the same transaction, for example in `Promise.all`, await the write before sending the other work:
1140
+
1141
+ ```ts
1142
+ await tx.orm.public.Post.create({ title, author: (author) => author.create(user) });
1143
+ await tx.execute(plan);
1144
+ ```
1145
+
1146
+ On any SQL database, when such a write fails with an error that ends the whole transaction, such as a deadlock on MySQL or MariaDB, the rollback to the savepoint fails too. The write then rejects with `RUNTIME.TRANSACTION_ROLLBACK_FAILED`, whose `cause` is the database's error, and the transaction is closed. Before, it rejected with the database's error itself. Code that retries on the database's deadlock error reads that error from `error.cause`.
1147
+
1148
+ ### `sql-runtime-base-own-transaction-removed`
1149
+
1150
+ A `SqlRuntimeBase` subclass that built an `ActivityRoute` with `transaction: (parent, options) => ...` and began the transaction through `this.ownTransaction(...)` now runs the callback with `transaction: (parent, fn, options) => withTransaction(provider, fn, options, parent)`. The provider's `connection(options)` opens the connection beneath `options?.activityParent`, and that connection's `transaction(options)` calls `beginTransactionOn(connection, owner, parent, options)` with the same parent. Delete the method that called `ownTransaction`.
1151
+
1152
+ Before:
1153
+
1154
+ ```ts
1155
+ transaction: (parent, options) => runtime().beginRoleTransaction(binding, parent, options),
1156
+
1157
+ private async beginRoleTransaction(binding, parent, options) {
1158
+ const { conn, session } = await this.openRoleConnection(binding, { activityParent: parent });
1159
+ return this.ownTransaction(session, () => this.beginTransactionOn(conn, session, parent, options));
1160
+ }
1161
+ ```
1162
+
1163
+ After:
1164
+
1165
+ ```ts
1166
+ connection: (options) => open(options)(),
1167
+
1168
+ transaction: (parent, fn, options) => withTransaction(scope, fn, options, parent),
1169
+ ```
1170
+
1171
+ Here `scope` is the role scope whose `connection(options)` opens a role session with `openRoleConnection(binding, options)`.
1172
+
1173
+ In the method that builds the session, take `const parent = options?.activityParent;` and pass `parent` in place of `undefined` to `beginTransactionOn` in the session's `transaction(options)`.
1174
+
1175
+ ### `orm-runtime-queryable-transaction-removed`
1176
+
1177
+ Remove any `transaction` member written only so the ORM could open a transaction on a queryable typed `RuntimeQueryable`; the ORM no longer reads it. Code that called `transaction` through a value typed `RuntimeQueryable` types the value as the runtime type it holds, such as `Runtime`, `RuntimeConnection` or an activity handle.
1178
+
1179
+ ### `rollback-after-commit-rejects`
1180
+
1181
+ Remove a `rollback()` call that runs after `commit()` resolved, such as one in a `finally` block or in a `catch` that also handles a hook error thrown from `commit()`. Where `commit()` can reject, call `rollback()` only when the transaction did not commit, or wrap the work in `withTransaction`, which decides this itself.
1182
+
1183
+
1184
+ ## Transaction contexts have `transaction` for nested transactions
1185
+
1186
+ `tx.transaction(fn)` inside a transaction now runs `fn` in a savepoint. The entries below say what an extension that builds or types a transaction context itself must add.
1187
+
1188
+ ### `transaction-context-has-transaction`
1189
+
1190
+ An object built by hand and typed as `TransactionContext`, such as a stub in a test, gains a `transaction` member. Delegate it to the context the object wraps, or reject when the object has none:
1191
+
1192
+ ```ts
1193
+ const ctx: TransactionContext = {
1194
+ get invalidated() {
1195
+ return inner.invalidated;
1196
+ },
1197
+ query: (plan) => inner.query(plan),
1198
+ execute: (plan) => inner.execute(plan),
1199
+ transaction: (fn) => inner.transaction(fn),
1200
+ };
1201
+ ```
1202
+
1203
+ A context type that extends `TransactionContext` and builds its object with `withTransactionMembers` now has `transaction` in its type and at run time, and the callback receives the runtime's `TransactionContext`, without the extension's members. To pass the extension's context instead, declare `transaction` on the type and add the member as in the example under `postgres-transaction-context-has-transaction`.
1204
+
1205
+ ### `transaction-settlement-state-has-closed-and-abandon`
1206
+
1207
+ Give an object you build by hand and type as `TransactionSettlementState` a `closed` getter and an `abandon()` method. Where the object wraps a transaction, forward both to it.
1208
+
1209
+ ### `postgres-transaction-context-has-transaction`
1210
+
1211
+ Where an extension builds the context of its own transactions with `withTransactionMembers(txCtx, members)` and gives it the type `PostgresTransactionContext`, or a type that aliases it, do one of the following.
1212
+
1213
+ To offer nested transactions, add a `transaction` member that calls the runtime context's `transaction` and builds the extension's context for the nested one. Build the context in a function that calls itself for the nested context, so each nested context has the member too:
1214
+
1215
+ ```ts
1216
+ function buildTransactionContext(txCtx: TransactionContext): PostgresTransactionContext<TContract, TCollections> {
1217
+ return withTransactionMembers(txCtx, {
1218
+ ...members(txCtx),
1219
+ transaction: <R>(
1220
+ fn: (tx: PostgresTransactionContext<TContract, TCollections>) => PromiseLike<R>,
1221
+ ) => txCtx.transaction((nested) => fn(buildTransactionContext(nested))),
1222
+ });
1223
+ }
1224
+
1225
+ return withTransaction(runtime, (txCtx) => fn(buildTransactionContext(txCtx)), options);
1226
+ ```
1227
+
1228
+ To keep the extension's context out of nested transactions, type it with the runtime's member, which the object already has through `withTransactionMembers`; the nested callback then receives the runtime's `TransactionContext`:
1229
+
1230
+ ```ts
1231
+ export type MyTransactionContext<
1232
+ TContract extends Contract<SqlStorage>,
1233
+ TCollections extends CollectionClasses = NoCollectionClasses,
1234
+ > = Omit<PostgresTransactionContext<TContract, TCollections>, 'transaction'> &
1235
+ Pick<TransactionContext, 'transaction'>;
1236
+ ```
1237
+
1238
+ ### `supabase-transaction-context-has-transaction`
1239
+
1240
+ `SupabaseTransactionContext` is `PostgresTransactionContext`. Where an extension builds a context with `withTransactionMembers(txCtx, members)` and types it as `SupabaseTransactionContext`, add a `transaction` member built as in the example under `postgres-transaction-context-has-transaction`, with `SupabaseTransactionContext` in place of `PostgresTransactionContext`.
1241
+
1242
+ ### `facade-transaction-contexts-have-transaction`
1243
+
1244
+ Where an extension builds the context of its own transactions with `withTransactionMembers(txCtx, members)` and gives it the type `MysqlTransactionContext` or `SqliteTransactionContext`, add a `transaction` member that calls the runtime context's `transaction` and builds the extension's context for the nested one, as in the example under `postgres-transaction-context-has-transaction`:
1245
+
1246
+ ```ts
1247
+ function buildTransactionContext(txCtx: TransactionContext): MysqlTransactionContext<TContract, TCollections> {
1248
+ return withTransactionMembers(txCtx, {
1249
+ ...members(txCtx),
1250
+ transaction: <R>(
1251
+ fn: (tx: MysqlTransactionContext<TContract, TCollections>) => PromiseLike<R>,
1252
+ ) => txCtx.transaction((nested) => fn(buildTransactionContext(nested))),
1253
+ });
1254
+ }
1255
+
1256
+ return withTransaction(runtime, (txCtx) => fn(buildTransactionContext(txCtx)), options);
1257
+ ```
1258
+
1259
+ Code that only receives `tx` from `db.transaction(...)` needs no change: the callback of `tx.transaction(...)` now receives the same type as `tx`, which has every member the runtime's `TransactionContext` has.
1260
+
1261
+
1262
+ ## The relation mutator types take `Writes` and `DeleteDisabled`
1263
+
1264
+ ### `relation-mutator-writes-parameter`
1265
+
1266
+ `RelationMutator<TContract, ModelName, LinkWritesDisabled, BareDisconnectDisabled, DisconnectDisabled, Writes, ParentLinkFields, NsId, ConflictActions, DeleteDisabled>` and `VariantRelationMutator<TContract, ModelName, VariantValue, LinkWritesDisabled, BareDisconnectDisabled, DisconnectDisabled, Writes, ParentLinkFields, NsId, ConflictActions, DeleteDisabled>` are the types of the mutator a relation callback receives. `RelationMutator` used to take a boolean, `FilteredWritesDisabled`, in the place of `Writes`, and had no `NsId`, `ConflictActions` or `DeleteDisabled`; `VariantRelationMutator` is new in this release. Nested `update(data)` and `delete()` of one related row are new, and `Writes` says which row writes the mutator offers:
1267
+
1268
+ | `Writes` | Relation | `where()` returns | `updateAll`, `deleteAll` | `update`, `delete` |
1269
+ | --- | --- | --- | --- | --- |
1270
+ | `'many'` (default) | to-many, including many-to-many | a mutator with `update`, `delete`, `updateAll`, `deleteAll` | available | only after `where()` |
1271
+ | `'one'` | to-one, including a relation the record holds the key for | a mutator with `update`, `delete` | not available | available |
1272
+ | `'none'` | in `create()` | not available | not available | not available |
1273
+
1274
+ An unavailable member takes a `never` parameter, so a call is a type error.
1275
+
1276
+ `DeleteDisabled` is `false` by default. It applies with `Writes = 'one'`: when it is `true`, `delete`, bare and after `where()`, takes a `never` parameter. With `Writes = 'many'` it has no effect. The ORM sets it on a relation whose foreign key, held by the record, is required.
1277
+
1278
+ In every file the detection matches, find each use of `RelationMutator<...>` or `VariantRelationMutator<...>`. A file may import them under another name, as in `import type { RelationMutator as RM } from '@prisma/orm-family-sql/orm-client'`; follow the local name. Where a use of `RelationMutator` passes its sixth argument:
1279
+
1280
+ - `false` becomes `'many'`.
1281
+ - `true` becomes `'none'` in `create()` data. In `update()` data it becomes `'one'` for a to-one relation, which offers `update` and `delete`; when the record holds the relation's foreign key and that key is required, also pass `DeleteDisabled = true`, because the ORM refuses `delete` there.
1282
+
1283
+ A use that leaves the `Writes` argument out gets `'many'` and needs no change. Code that lists the members of a mutator, for example with `keyof`, also sees `update` and `delete`.
1284
+
1285
+ ### `foreign-key-with-relation-callback-refused`
1286
+
1287
+ `update()` data that sets the foreign key the record holds for a relation and also has a callback on that relation is now refused, whatever the callback returns (`create`, `connect`, `disconnect`, `update` or `delete`). The ORM refuses it while it plans the write, before any statement runs, with:
1288
+
1289
+ ```text
1290
+ ORM.ARGUMENT_INVALID: update() data sets "authorId", the foreign key of relation "author", and also has a callback on "author"; set the foreign key or use the callback
1291
+ ```
1292
+
1293
+ `meta.relation` names the relation and `meta.fields` the foreign-key fields the data sets. A foreign-key field whose value is `undefined` does not count. It is not a type error.
1294
+
1295
+ Such data used to run, and a `create`, `connect` or `disconnect` callback silently overwrote the foreign key the data set.
1296
+
1297
+ For each such call, keep one of the two. To point the record at another row, set the foreign key, or use `connect` on the relation:
1298
+
1299
+ ```ts
1300
+ // before
1301
+ await db.orm.public.Post.where({ id: 10 }).update({
1302
+ authorId: 2,
1303
+ author: (author) => author.connect({ id: 2 }),
1304
+ });
1305
+
1306
+ // after
1307
+ await db.orm.public.Post.where({ id: 10 }).update({
1308
+ author: (author) => author.connect({ id: 2 }),
1309
+ });
1310
+ ```
1311
+
1312
+ The relation callback's `update` and `delete` are new in this release. To use one of them on the row the record points at and also point the record at another row, make two calls: first the callback, then the foreign key. Run them in one transaction, so that both changes apply or neither does. Where the foreign key is required, the callback's `delete` is refused: set the foreign key first, then delete the old row through its own collection.
1313
+
1314
+ ```ts
1315
+ await db.transaction(async (tx) => {
1316
+ await tx.orm.public.Post.where({ id: 10 }).update({
1317
+ author: (author) => author.update({ name: 'Ada' }),
1318
+ });
1319
+ await tx.orm.public.Post.where({ id: 10 }).update({ authorId: 2 });
1320
+ });
1321
+ ```
1322
+
1323
+
1324
+ ## MongoDB prepared ORM reads
1325
+
1326
+ ### `mongo-collection-has-prepared`
1327
+
1328
+ Give a hand-written `MongoCollection` a `prepared` member, and widen `limit` and `offset`. A test double that never prepares can throw:
1329
+
1330
+ ```ts
1331
+ const users: MongoCollection<Contract, 'User'> = {
1332
+ // ...
1333
+ limit: (n) => users,
1334
+ offset: (n) => users,
1335
+ prepared: {
1336
+ all: () => { throw new Error('not used in this test'); },
1337
+ first: () => { throw new Error('not used in this test'); },
1338
+ firstOrThrow: () => { throw new Error('not used in this test'); },
1339
+ },
1340
+ };
1341
+ ```
1342
+
1343
+ ### `mongo-prepare-member-moved`
1344
+
1345
+ Import `MongoPrepareMember` from `@prisma/orm-mongo/runtime` and give it the contract: `MongoPrepareMember<Contract>` is an object type that has the `prepare` method of a `mongo()` client. Where you meant an object with the runtime's `prepare`, write `Pick<MongoRuntime, 'prepare'>`, or type the value as `MongoRuntime`:
1346
+
1347
+ ```ts
1348
+ import type { MongoRuntime } from '@prisma/orm-mongo/family-runtime';
1349
+ import type { MongoPrepareMember } from '@prisma/orm-mongo/runtime';
1350
+
1351
+ const clientPrepare: MongoPrepareMember<Contract> = db;
1352
+ const runtimePrepare: Pick<MongoRuntime, 'prepare'> = await db.runtime();
1353
+ ```
1354
+
1355
+ ### `mongo-where-filter-takes-placeholders`
1356
+
1357
+ Where you read a value out of a `MongoWhereFilter`, check for a placeholder before using it as the field's type:
1358
+
1359
+ ```ts
1360
+ import { isMongoPreparedParamRef } from '@prisma/orm-mongo/value';
1361
+
1362
+ const name = filter.name;
1363
+ const label = name === undefined || isMongoPreparedParamRef(name) ? undefined : name.toUpperCase();
1364
+ ```
1365
+
1366
+ A placeholder's value is known only when a prepared statement runs.
1367
+
1368
+ ### `compile-mongo-query-has-no-row-type`
1369
+
1370
+ Drop the type argument from `compileMongoQuery(...)`. Where you need a row type, type the rows where you read them.
1371
+
1372
+
1373
+ ## Migration runners record the database's policies, and families name the operations that change access
1374
+
1375
+ A database now records its policies in its marker: whether `db update` may move it, and its data protection settings. `db migrate` refuses a recorded migration that changes who can read or write data on a database whose data protection policy forbids it. A target's migration runner and control adapter write and check the policies, and a family names the operations that change access.
1376
+
1377
+ ### `runner-records-database-policies`
1378
+
1379
+ In the runner's marker update, pass the policies on in the destination, and do not skip the marker write when nothing ran but policies are to be recorded:
1380
+
1381
+ ```ts
1382
+ const destination = {
1383
+ storageHash,
1384
+ profileHash,
1385
+ invariants: plan.providedInvariants,
1386
+ ...(options.databasePolicies === undefined ? {} : { databasePolicies: options.databasePolicies }),
1387
+ };
1388
+
1389
+ const nothingToRecord =
1390
+ isSelfEdge && operationsExecuted === 0 && invariantsAlreadyHeld && options.databasePolicies === undefined;
1391
+ ```
1392
+
1393
+ In the control adapter, write `meta.policies` when `destination.databasePolicies` is set, and never reset `meta` otherwise: an upsert that used to set `meta` to `{}` on conflict leaves `meta` alone unless it records policies.
1394
+
1395
+ Before the runner applies its first space, check that the policies the caller checked still hold: a SQL target calls `checkDatabasePoliciesHeld(family, driver, expectedDatabasePolicies)`; a MongoDB runner calls `compareMarkerDatabasePolicies` and, after a failed marker write, `markerSwapFailure`.
1396
+
1397
+ The other required changes, for every target:
1398
+
1399
+ - `MigrationRunner.execute` takes an optional `expectedDatabasePolicies` beside `perSpaceOptions`. Once the runner holds its marker lock, and before it applies the first space, it reads the application space's marker and calls `compareMarkerDatabasePolicies(marker, expectedDatabasePolicies)`. On `moved` it returns `databasePoliciesMovedFailure(expectedDatabasePolicies, comparison.found)` (`MIGRATION.MARKER_CAS_FAILURE` with `meta.reason: 'databasePolicies'`) without running any operation. On `unreadable` it throws `errorMarkerPoliciesCorrupt` from `@prisma/orm-framework/errors/execution`.
1400
+ - The `MIGRATION.MARKER_CAS_FAILURE` a runner returns when the marker's storage hash moved under it carries `meta.reason: 'storageHash'`.
1401
+ - `ControlFamilyInstance.signSpaces` takes the same `expectedDatabasePolicies` beside `spaces` and compares them before it writes any marker, whether or not the application space is among `spaces`. When they no longer hold, it returns only a conflict for the application space with `reason: 'databasePolicies'`, `checked` and the `comparison`, and no `contract`. Every other conflict carries `reason: 'storageHash'`.
1402
+ - A ledger entry is written only when the run applied a migration edge, as before.
1403
+
1404
+ For a SQL target:
1405
+
1406
+ - The `destination` that `initMarker` and `updateMarker` of `SqlControlAdapter` take is the framework's `MarkerDestination`, which carries the optional `databasePolicies`. Store it with `storedDatabasePolicies` under `DATABASE_POLICIES_META_KEY`.
1407
+ - `insertMarker` takes `MarkerInsert`, a `MarkerDestination` without `databasePolicies`.
1408
+
1409
+ For a MongoDB target:
1410
+
1411
+ - `MongoControlAdapter.updateMarker` takes an optional fifth argument, and `MarkerOperations.updateMarker` an optional fourth, `checkedPolicies` (`DatabasePolicies`): the policies the run checked. The update then matches only a marker whose `meta.policies` reads as them.
1412
+ - `MarkerOperations` has a required `markerLocation`, the collection that holds the markers, which the runner names in errors.
1413
+ - When the marker update fails, `markerSwapFailure(found, expectedStorageHash, checkedPolicies)` from `@prisma/orm-family-mongo/family/control` reports a moved storage hash, moved policies, unreadable policies, or a marker changed and changed back. Map them to the storage-hash failure, `databasePoliciesMovedFailure`, `errorMarkerPoliciesCorrupt`, and a `MIGRATION.MARKER_CAS_FAILURE` with `meta.reason: 'markerChanged'`. Do not retry the update.
1414
+
1415
+ ### `control-family-access-changes-of`
1416
+
1417
+ A family that implements `ControlFamilyInstance` itself adds `accessChangesOf` beside `storageNameOf`:
1418
+
1419
+ ```ts
1420
+ return {
1421
+ familyId: 'my-family',
1422
+ storageNameOf(operation) {
1423
+ return myStorageNameOf(operation);
1424
+ },
1425
+ accessChangesOf() {
1426
+ return [];
1427
+ },
1428
+ …
1429
+ };
1430
+ ```
1431
+
1432
+ A SQL target adds `accessChangesOf` to its control target descriptor beside `classifyEntityKind`:
1433
+
1434
+ ```ts
1435
+ const descriptor: SqlControlTargetDescriptor<'my-target', MyPlanTargetDetails> = {
1436
+ …
1437
+ classifyEntityKind: relationalNodeEntityKind,
1438
+ accessChangesOf: () => [],
1439
+ …
1440
+ };
1441
+ ```
1442
+
1443
+ A target with operations that change who can read or write rows, such as disabling row-level security or dropping a row-level-security policy, returns one entry for each, with `widens: true` when the operation only lets more people read or write and `false` when it can go either way. A test double of either one sets `accessChangesOf: () => []`.
1444
+
1445
+ ### `aggregate-planner-access-changes-of`
1446
+
1447
+ Pass `accessChangesOf` to each `planMigration({ ... })` and `resolveRecordedPath({ ... })` call, beside `storageNameOf`:
1448
+
1449
+ ```ts
1450
+ // Before
1451
+ planMigration({ ...inputs, storageNameOf: (operation) => family.storageNameOf(operation) });
1452
+
1453
+ // After
1454
+ planMigration({
1455
+ ...inputs,
1456
+ storageNameOf: (operation) => family.storageNameOf(operation),
1457
+ accessChangesOf: (operations) => family.accessChangesOf(operations),
1458
+ });
1459
+ ```
1460
+
1461
+ In a test, `accessChangesOf: () => []` lists none.
1462
+
1463
+
1464
+ ## A changed stored name is a rename in the SQL family's planning
1465
+
1466
+ The SQL family now treats a model, field or enum member that keeps its contract name as the same object when its stored name or stored value changes. These changes to `@prisma/orm-family-sql/family/control` follow from it. The family also exports `StorageRenames`, `exactName`, `SameName` and `ModelTable` (which moved, and is still exported under the same name).
1467
+
1468
+ ### `schema-tables-same-name`
1469
+
1470
+ Before:
1471
+
1472
+ ```ts
1473
+ const tables: SchemaTables = {
1474
+ hasNamespace: (namespaceId) => namespaceId === UNBOUND_NAMESPACE_ID,
1475
+ hasTable: (namespaceId, table) => schema.hasTable(namespaceId, table),
1476
+ // ...
1477
+ };
1478
+ ```
1479
+
1480
+ After:
1481
+
1482
+ ```ts
1483
+ import { exactName } from '@prisma/orm-family-sql/family/control';
1484
+
1485
+ const tables: SchemaTables = {
1486
+ sameName: exactName,
1487
+ hasNamespace: (namespaceId) => namespaceId === UNBOUND_NAMESPACE_ID,
1488
+ hasTable: (namespaceId, table) => schema.hasTable(namespaceId, table),
1489
+ // ...
1490
+ };
1491
+ ```
1492
+
1493
+ A database that compares names without case passes its own comparison, the same one its `tablesNamed` and `columnsNamed` use.
1494
+
1495
+ ### `plan-statements-plans-stored-name-renames`
1496
+
1497
+ A target that calls `planStatements` keeps putting its `calls` first in the plan. The calls may now include renames no statement asked for. Put the renames of the constraints of each table in `alreadyRenamedTables` before the plan's creates, but after a drop that frees the name a rename gives. Pass `storageRenames` on to `subjectsOfCalls`, as below. An object literal typed as `StatementPlanningTarget` that also holds `renderTableRename` and `tableRenameByHand` keeps them only where a `TableRenameByHand` is expected.
1498
+
1499
+ ### `subjects-of-calls-storage-renames`
1500
+
1501
+ Before:
1502
+
1503
+ ```ts
1504
+ subjectsOfCalls(subjects, { fromContract, contract, origins, byHand, removedVariants });
1505
+ ```
1506
+
1507
+ After, for a target that plans statements:
1508
+
1509
+ ```ts
1510
+ subjectsOfCalls(subjects, {
1511
+ fromContract,
1512
+ contract,
1513
+ origins,
1514
+ storageRenames: statements.value.storageRenames,
1515
+ byHand,
1516
+ removedVariants,
1517
+ });
1518
+ ```
1519
+
1520
+ After, for a target that plans no renames:
1521
+
1522
+ ```ts
1523
+ import { exactName, StorageRenames } from '@prisma/orm-family-sql/family/control';
1524
+
1525
+ subjectsOfCalls(subjects, {
1526
+ fromContract,
1527
+ contract,
1528
+ origins: NO_RENAMED_ORIGINS,
1529
+ storageRenames:
1530
+ fromContract === null ? undefined : new StorageRenames([], fromContract, contract, exactName),
1531
+ byHand,
1532
+ removedVariants,
1533
+ });
1534
+ ```
1535
+
1536
+ The advice on keeping the rows of a dropped table now comes from `storageRenames`; with `undefined`, a dropped table gets none.
1537
+
1538
+ ### `stored-value-keep-data-edit-removed`
1539
+
1540
+ Remove reads of `keepDataEdit`, `keepData` and `swapsValues`. `keepRowsEdit` is unchanged and still gives the edit that keeps the rows a removal would lose.
1541
+
1542
+
1543
+ ## The CLI engine is 0.10.4, and its consent error has one fixed first line
1544
+
1545
+ ### `engine-pin-moves-to-0-10-4`
1546
+
1547
+ For every file matched by `detection`, change the `@prisma/cli-engine` version (`0.10.3`, `0.10.2`, `0.10.1`, `0.10.0` or any earlier 0.x) to `0.10.4` and reinstall.
1548
+
1549
+ ### `consent-required-summary-is-one-fixed-sentence`
1550
+
1551
+ Two errors have the code `CLI.CONSENT_REQUIRED`. Both are raised when the run cannot ask (it is not interactive, or `--yes` is set). The first line (the `summary`) of each changed, and both now have the same one:
1552
+
1553
+ - `This command requires explicit consent, but it was not provided.`
1554
+ - Under `--yes`: `This command requires explicit consent for which --yes is not sufficient.` Engines 0.10.2 and 0.10.3 said `This command requires explicit consent, and --yes does not give it.`
1555
+
1556
+ **A statement question nobody answered.** `prisma migration plan` or `prisma db update` would lose data or change access, and no `--rename`, `--delete` or similar flag answers the question.
1557
+
1558
+ - Before: `"User.nick" needs a statement, and the session is not interactive.`, or `2 subjects need a statement, and the session is not interactive: "Bug", "Task".` for several questions. Under `--yes`, the line said `which --yes cannot give` in place of `and the session is not interactive`.
1559
+ - `why` (the questions), the next actions, `meta`, the code and the exit code (2) are unchanged. Read the unanswered subjects from `meta.unanswered` (each with its `subject` and `verbs`).
1560
+
1561
+ **A consent that `--confirm` answers.** For example `prisma init` over a project it would replace.
1562
+
1563
+ - Before: `"<question>" requires explicit consent, and the session is not interactive.`, or `…, which --yes cannot grant.` under `--yes`. When the consent has a token, the line ended `Grant it by passing --confirm <token>.`
1564
+ - The question is now in `why`, which this error did not have before. The next action, `meta.consentToken`, the code and the exit code (2) are unchanged. Read the token from `meta.consentToken`.
1565
+
1566
+ For every file matched by `detection`, stop matching the first line of this error. A match on `session is not interactive` needs a change only where it is for this error; other errors still use those words. Branch on the error's `code` (`CLI.CONSENT_REQUIRED`). The code alone does not tell the two errors apart: the first has `meta.unanswered`, and the second does not.