@prisma/orm-mongo 8.0.0-rc.25-dev.4 → 8.0.0-rc.25-dev.6

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.
@@ -8,8 +8,8 @@ import { buildNamespacedEnums } from "@prisma/orm-framework/contract/enum-access
8
8
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
9
9
  import { mongoQuery } from "@prisma/orm-family-mongo/query-builder";
10
10
  import { assertDefined } from "@prisma/orm-framework/utils/assertions";
11
- //#region ../../../3-targets/mongo/9-facade/dist/mongo-static-CSxUjmzn.mjs
12
- var version = "8.0.0-rc.25-dev.4";
11
+ //#region ../../../3-targets/mongo/9-facade/dist/mongo-static-B6oScFYI.mjs
12
+ var version = "8.0.0-rc.25-dev.6";
13
13
  const serializer = new MongoContractSerializer();
14
14
  const validator = `${mongoRuntimeTarget.targetId}@${version}`;
15
15
  /**
@@ -69,4 +69,4 @@ function mongoStatic(options) {
69
69
  //#endregion
70
70
  export { validateMongoContract as i, contractFromJson as n, mongoStatic as r, buildMongoStaticContext as t };
71
71
 
72
- //# sourceMappingURL=mongo-static-CSxUjmzn-DN51T3o2.mjs.map
72
+ //# sourceMappingURL=mongo-static-B6oScFYI-CzoifwUM.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mongo-static-CSxUjmzn-DN51T3o2.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/mongo-static-CSxUjmzn.mjs"],"sourcesContent":["import mongoRuntimeAdapter from \"@internal/adapter-mongo/runtime\";\nimport { mongoRaw } from \"@internal/mongo-orm\";\nimport { createMongoExecutionContext, createMongoExecutionStack, enumMemberCodecFor } from \"@internal/mongo-runtime\";\nimport mongoRuntimeTarget from \"@internal/target-mongo/runtime\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { MongoContractSerializer } from \"@internal/family-mongo/ir\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { mongoQuery } from \"@internal/mongo-query-builder\";\nimport { assertDefined } from \"@internal/utils/assertions\";\n//#region package.json\nvar version = \"8.0.0-rc.25-dev.4\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new MongoContractSerializer();\nconst validator = `${mongoRuntimeTarget.targetId}@${version}`;\n/**\n* Validates an emitted Mongo `contract.json` and returns it as the contract type the application\n* names, ready to pass to `mongo({ contract })` and `mongoStatic({ contract })`. Clients built from\n* the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateMongoContract(contract) {\n\treturn contractFromJson(contract);\n}\n//#endregion\n//#region src/static/mongo-static.ts\nfunction buildMongoStaticContext(contract, stack) {\n\tconst context = createMongoExecutionContext({\n\t\tcontract,\n\t\tstack\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, enumMemberCodecFor(context.codecs)))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a mongo builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tquery: mongoQuery({ context }),\n\t\traw: mongoRaw({ context })\n\t};\n}\n/**\n* The query surfaces of a Mongo client without a driver: `query`, `raw` and `enums`. Use it where\n* loading `mongodb` is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = mongoStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction mongoStatic(options) {\n\tconst stack = createMongoExecutionStack({\n\t\ttarget: mongoRuntimeTarget,\n\t\tadapter: mongoRuntimeAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildMongoStaticContext(validateMongoContract(options.contract), stack);\n}\n//#endregion\nexport { validateMongoContract as i, mongoStatic as n, contractFromJson as r, buildMongoStaticContext as t };\n\n//# sourceMappingURL=mongo-static-CSxUjmzn.mjs.map"],"mappings":";;;;;;;;;;;AAWA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,wBAAwB;AAC/C,MAAM,YAAY,GAAG,mBAAmB,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiBpD,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,sBAAsB,UAAU;CACxC,OAAO,iBAAiB,QAAQ;AACjC;AAGA,SAAS,wBAAwB,UAAU,OAAO;CACjD,MAAM,UAAU,4BAA4B;EAC3C;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,QAAQ,mBAAmB,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC;CAC/G,cAAc,OAAO,+DAA+D;CACpF,OAAO;EACN;EACA;EACA;EACA,OAAO,WAAW,EAAE,QAAQ,CAAC;EAC7B,KAAK,SAAS,EAAE,QAAQ,CAAC;CAC1B;AACD;;;;;;;;;;AAUA,SAAS,YAAY,SAAS;CAC7B,MAAM,QAAQ,0BAA0B;EACvC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,wBAAwB,sBAAsB,QAAQ,QAAQ,GAAG,KAAK;AAC9E"}
1
+ {"version":3,"file":"mongo-static-B6oScFYI-CzoifwUM.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/mongo-static-B6oScFYI.mjs"],"sourcesContent":["import mongoRuntimeAdapter from \"@internal/adapter-mongo/runtime\";\nimport { mongoRaw } from \"@internal/mongo-orm\";\nimport { createMongoExecutionContext, createMongoExecutionStack, enumMemberCodecFor } from \"@internal/mongo-runtime\";\nimport mongoRuntimeTarget from \"@internal/target-mongo/runtime\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { MongoContractSerializer } from \"@internal/family-mongo/ir\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { mongoQuery } from \"@internal/mongo-query-builder\";\nimport { assertDefined } from \"@internal/utils/assertions\";\n//#region package.json\nvar version = \"8.0.0-rc.25-dev.6\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new MongoContractSerializer();\nconst validator = `${mongoRuntimeTarget.targetId}@${version}`;\n/**\n* Validates an emitted Mongo `contract.json` and returns it as the contract type the application\n* names, ready to pass to `mongo({ contract })` and `mongoStatic({ contract })`. Clients built from\n* the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateMongoContract(contract) {\n\treturn contractFromJson(contract);\n}\n//#endregion\n//#region src/static/mongo-static.ts\nfunction buildMongoStaticContext(contract, stack) {\n\tconst context = createMongoExecutionContext({\n\t\tcontract,\n\t\tstack\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, enumMemberCodecFor(context.codecs)))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a mongo builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tquery: mongoQuery({ context }),\n\t\traw: mongoRaw({ context })\n\t};\n}\n/**\n* The query surfaces of a Mongo client without a driver: `query`, `raw` and `enums`. Use it where\n* loading `mongodb` is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = mongoStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction mongoStatic(options) {\n\tconst stack = createMongoExecutionStack({\n\t\ttarget: mongoRuntimeTarget,\n\t\tadapter: mongoRuntimeAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildMongoStaticContext(validateMongoContract(options.contract), stack);\n}\n//#endregion\nexport { validateMongoContract as i, mongoStatic as n, contractFromJson as r, buildMongoStaticContext as t };\n\n//# sourceMappingURL=mongo-static-B6oScFYI.mjs.map"],"mappings":";;;;;;;;;;;AAWA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,wBAAwB;AAC/C,MAAM,YAAY,GAAG,mBAAmB,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiBpD,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,sBAAsB,UAAU;CACxC,OAAO,iBAAiB,QAAQ;AACjC;AAGA,SAAS,wBAAwB,UAAU,OAAO;CACjD,MAAM,UAAU,4BAA4B;EAC3C;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,QAAQ,mBAAmB,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC;CAC/G,cAAc,OAAO,+DAA+D;CACpF,OAAO;EACN;EACA;EACA;EACA,OAAO,WAAW,EAAE,QAAQ,CAAC;EAC7B,KAAK,SAAS,EAAE,QAAQ,CAAC;CAC1B;AACD;;;;;;;;;;AAUA,SAAS,YAAY,SAAS;CAC7B,MAAM,QAAQ,0BAA0B;EACvC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,wBAAwB,sBAAsB,QAAQ,QAAQ,GAAG,KAAK;AAC9E"}
package/dist/runtime.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as validateMongoContract, t as buildMongoStaticContext } from "./mongo-static-CSxUjmzn-DN51T3o2.mjs";
1
+ import { i as validateMongoContract, t as buildMongoStaticContext } from "./mongo-static-B6oScFYI-CzoifwUM.mjs";
2
2
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
3
  import mongoRuntimeAdapter from "@prisma/orm-target-mongo/adapter/runtime";
4
4
  import { mongoOrm } from "@prisma/orm-family-mongo/orm";
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/runtime.mjs"],"sourcesContent":["import { i as validateMongoContract, t as buildMongoStaticContext } from \"./mongo-static-CSxUjmzn.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport mongoRuntimeAdapter from \"@internal/adapter-mongo/runtime\";\nimport mongoRuntimeDriver from \"@internal/driver-mongo/runtime\";\nimport { AsyncIterableResult } from \"@internal/framework-components/runtime\";\nimport { mongoOrm } from \"@internal/mongo-orm\";\nimport { createMongoExecutionStack, createMongoRuntime } from \"@internal/mongo-runtime\";\nimport mongoRuntimeTarget from \"@internal/target-mongo/runtime\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { ConnectionString } from \"mongodb-connection-string-url\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { blindCast } from \"@internal/utils/casts\";\n//#region src/runtime/mongo-errors.ts\nfunction mongoError(code, message, options) {\n\treturn structuredError(code, message, {\n\t\t...options,\n\t\tmeta: {\n\t\t\t...options?.meta,\n\t\t\textension: \"mongo\"\n\t\t}\n\t});\n}\n//#endregion\n//#region src/runtime/binding.ts\nconst URL_SCHEME_PATTERN = /^([a-z][a-z\\d+.-]*):\\/\\//i;\nconst MONGO_SCHEMES = /* @__PURE__ */ new Set([\"mongodb\", \"mongodb+srv\"]);\nfunction validateMongoUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a non-empty string\");\n\tconst scheme = URL_SCHEME_PATTERN.exec(trimmed)?.[1];\n\tif (scheme === void 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\tif (!MONGO_SCHEMES.has(scheme)) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must use mongodb:// or mongodb+srv://\");\n\ttry {\n\t\treturn new ConnectionString(trimmed);\n\t} catch {\n\t\tthrow mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\t}\n}\nfunction extractDbNameFromUrl(parsed) {\n\tconst [encodedDbName = \"\"] = parsed.pathname.slice(1).split(\"/\");\n\tif (encodedDbName.length === 0) return;\n\ttry {\n\t\treturn decodeURIComponent(encodedDbName);\n\t} catch {\n\t\tthrow mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\t}\n}\nfunction resolveMongoBinding(options) {\n\tconst providedCount = Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.uri !== void 0) + Number(options.mongoClient !== void 0);\n\tif (providedCount !== 1) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, uri+dbName, or mongoClient+dbName\", { meta: { received: providedCount } });\n\tif (options.binding !== void 0) return options.binding;\n\tif (options.url !== void 0) {\n\t\tconst parsed = validateMongoUrl(options.url);\n\t\tif (options.dbName !== void 0 && options.dbName.trim().length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { url, dbName } requires a non-empty dbName\");\n\t\tconst explicitDbName = options.dbName?.trim();\n\t\tconst dbName = explicitDbName !== void 0 && explicitDbName.length > 0 ? explicitDbName : extractDbNameFromUrl(parsed);\n\t\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must include a database name in its path (e.g. mongodb://host:27017/mydb), or pass dbName explicitly\");\n\t\treturn {\n\t\t\tkind: \"url\",\n\t\t\turl: options.url.trim(),\n\t\t\tdbName\n\t\t};\n\t}\n\tif (options.uri !== void 0) {\n\t\tvalidateMongoUrl(options.uri);\n\t\tconst dbName = options.dbName?.trim();\n\t\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { uri, dbName } requires a non-empty dbName\");\n\t\treturn {\n\t\t\tkind: \"url\",\n\t\t\turl: options.uri.trim(),\n\t\t\tdbName\n\t\t};\n\t}\n\tconst mongoClient = options.mongoClient;\n\tif (mongoClient === void 0) throw new InternalError(\"Invariant violation: expected mongo binding after validation\");\n\tconst dbName = options.dbName?.trim();\n\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { mongoClient, dbName } requires a non-empty dbName\");\n\treturn {\n\t\tkind: \"mongoClient\",\n\t\tclient: mongoClient,\n\t\tdbName\n\t};\n}\nfunction resolveOptionalMongoBinding(options) {\n\tconst providedCount = Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.uri !== void 0) + Number(options.mongoClient !== void 0);\n\tif (providedCount === 0) return;\n\tif (providedCount !== 1) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, uri+dbName, or mongoClient+dbName\", { meta: { received: providedCount } });\n\tif (options.binding !== void 0) return resolveMongoBinding({ binding: options.binding });\n\tif (options.url !== void 0) return resolveMongoBinding(options.dbName !== void 0 ? {\n\t\turl: options.url,\n\t\tdbName: options.dbName\n\t} : { url: options.url });\n\tif (options.uri !== void 0) return resolveMongoBinding({\n\t\turi: options.uri,\n\t\tdbName: options.dbName ?? \"\"\n\t});\n\tif (options.mongoClient !== void 0) return resolveMongoBinding({\n\t\tmongoClient: options.mongoClient,\n\t\tdbName: options.dbName ?? \"\"\n\t});\n\tthrow new InternalError(\"Invariant violation: expected one mongo binding branch\");\n}\n//#endregion\n//#region src/runtime/prepared-row-query.ts\nasync function prepareMongoQuery(runtime, declaration, callback) {\n\tlet description;\n\tconst statement = await runtime.prepare(declaration, (placeholders) => {\n\t\tconst authored = callback(placeholders);\n\t\tif (\"plan\" in authored) {\n\t\t\tdescription = authored;\n\t\t\treturn authored.plan;\n\t\t}\n\t\treturn authored;\n\t});\n\treturn blindCast(description ? createMongoPreparedRowQuery(description, statement) : statement);\n}\nfunction createMongoPreparedRowQuery(description, statement) {\n\treturn Object.freeze({ query(target, params, options) {\n\t\treturn description.consume(statement.query(target, params, options));\n\t} });\n}\n//#endregion\n//#region src/runtime/mongo.ts\n/**\n* Creates a lazy Mongo client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The `orm` and `query` surfaces are\n* available at once; the driver connects on the first query or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-mongo/static';\n* import mongo from '@prisma/orm-mongo/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = mongo({ contract, url: process.env['MONGODB_URL']! });\n* ```\n*/\nfunction mongo(options) {\n\tconst contract = validateMongoContract(options.contract);\n\tlet binding = resolveOptionalMongoBinding(options);\n\tconst stack = createMongoExecutionStack({\n\t\ttarget: mongoRuntimeTarget,\n\t\tadapter: mongoRuntimeAdapter,\n\t\tdriver: mongoRuntimeDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst { context, query, enums, raw } = buildMongoStaticContext(contract, stack);\n\tlet runtimePromise;\n\tlet closed = false;\n\tlet runtimeInstance;\n\tconst closedError = () => mongoError(\"DRIVER.NOT_CONNECTED\", \"Mongo client is closed\");\n\tconst createRuntime = () => {\n\t\tif (runtimeInstance !== void 0) return runtimeInstance;\n\t\tconst driver = stack.driver.create();\n\t\truntimeInstance = {\n\t\t\truntime: createMongoRuntime({\n\t\t\t\tcontext,\n\t\t\t\tadapter: stack.adapter.create(stack),\n\t\t\t\tdriver,\n\t\t\t\t...ifDefined(\"mode\", options.mode),\n\t\t\t\t...ifDefined(\"middleware\", options.middleware)\n\t\t\t}),\n\t\t\tdriver\n\t\t};\n\t\treturn runtimeInstance;\n\t};\n\tconst buildRuntime = async (resolvedBinding) => {\n\t\tconst { runtime, driver } = createRuntime();\n\t\tawait driver.connect(resolvedBinding);\n\t\treturn runtime;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) return Promise.reject(closedError());\n\t\tif (runtimePromise !== void 0) return runtimePromise;\n\t\tif (binding === void 0) return Promise.reject(mongoError(\"RUNTIME.BINDING_MISSING\", \"Mongo binding not configured. Pass url/uri+dbName/mongoClient+dbName/binding to mongo(...) or call db.connect({ ... }).\"));\n\t\truntimePromise = buildRuntime(binding).catch((err) => {\n\t\t\truntimePromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn runtimePromise;\n\t};\n\tfunction queryRows(plan) {\n\t\tasync function* iterate() {\n\t\t\tyield* (await getRuntime()).query(plan);\n\t\t}\n\t\treturn new AsyncIterableResult(iterate());\n\t}\n\tasync function executeStats(plan) {\n\t\treturn (await getRuntime()).execute(plan);\n\t}\n\treturn {\n\t\torm: mongoOrm({\n\t\t\tcontext,\n\t\t\truntime: {\n\t\t\t\tquery: queryRows,\n\t\t\t\texecute: executeStats\n\t\t\t}\n\t\t}),\n\t\tquery,\n\t\traw,\n\t\tcontract,\n\t\tenums,\n\t\tcontext,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw closedError();\n\t\t\tif (runtimePromise !== void 0) {\n\t\t\t\tif (bindingInput !== void 0) throw mongoError(\"DRIVER.ALREADY_CONNECTED\", \"Mongo client is already bound\", {\n\t\t\t\t\twhy: \"connect() was given options after the client was bound to a database.\",\n\t\t\t\t\tfix: \"Call connect() without options, or create a new client for another database.\"\n\t\t\t\t});\n\t\t\t\tconst runtime = await runtimePromise;\n\t\t\t\tif (closed) throw closedError();\n\t\t\t\treturn runtime;\n\t\t\t}\n\t\t\tif (bindingInput !== void 0) binding = resolveMongoBinding(bindingInput);\n\t\t\tif (binding === void 0) throw mongoError(\"RUNTIME.BINDING_MISSING\", \"Mongo binding not configured. Pass url/uri+dbName/mongoClient+dbName/binding to mongo(...) or call db.connect({ ... }).\");\n\t\t\tconst runtime = await getRuntime();\n\t\t\tif (closed) throw closedError();\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tasync prepare(declaration, callback) {\n\t\t\tif (closed) throw closedError();\n\t\t\treturn prepareMongoQuery(createRuntime().runtime, declaration, callback);\n\t\t},\n\t\tasync close() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\tawait runtimePromise?.catch(() => void 0);\n\t\t\tawait runtimeInstance?.runtime.close();\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { mongo as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,WAAW,MAAM,SAAS,SAAS;CAC3C,OAAO,gBAAgB,MAAM,SAAS;EACrC,GAAG;EACH,MAAM;GACL,GAAG,SAAS;GACZ,WAAW;EACZ;CACD,CAAC;AACF;AAGA,MAAM,qBAAqB;AAC3B,MAAM,gCAAgC,IAAI,IAAI,CAAC,WAAW,aAAa,CAAC;AACxE,SAAS,iBAAiB,KAAK;CAC9B,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,WAAW,2BAA2B,sCAAsC;CAC5G,MAAM,SAAS,mBAAmB,KAAK,OAAO,CAAC,GAAG;CAClD,IAAI,WAAW,KAAK,GAAG,MAAM,WAAW,2BAA2B,+BAA+B;CAClG,IAAI,CAAC,cAAc,IAAI,MAAM,GAAG,MAAM,WAAW,2BAA2B,iDAAiD;CAC7H,IAAI;EACH,OAAO,IAAI,iBAAiB,OAAO;CACpC,QAAQ;EACP,MAAM,WAAW,2BAA2B,+BAA+B;CAC5E;AACD;AACA,SAAS,qBAAqB,QAAQ;CACrC,MAAM,CAAC,gBAAgB,MAAM,OAAO,SAAS,MAAM,CAAC,CAAC,CA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ACD;AACD"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/mongo/9-facade/dist/runtime.mjs"],"sourcesContent":["import { i as validateMongoContract, t as buildMongoStaticContext } from \"./mongo-static-B6oScFYI.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport mongoRuntimeAdapter from \"@internal/adapter-mongo/runtime\";\nimport mongoRuntimeDriver from \"@internal/driver-mongo/runtime\";\nimport { AsyncIterableResult } from \"@internal/framework-components/runtime\";\nimport { mongoOrm } from \"@internal/mongo-orm\";\nimport { createMongoExecutionStack, createMongoRuntime } from \"@internal/mongo-runtime\";\nimport mongoRuntimeTarget from \"@internal/target-mongo/runtime\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { ConnectionString } from \"mongodb-connection-string-url\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { blindCast } from \"@internal/utils/casts\";\n//#region src/runtime/mongo-errors.ts\nfunction mongoError(code, message, options) {\n\treturn structuredError(code, message, {\n\t\t...options,\n\t\tmeta: {\n\t\t\t...options?.meta,\n\t\t\textension: \"mongo\"\n\t\t}\n\t});\n}\n//#endregion\n//#region src/runtime/binding.ts\nconst URL_SCHEME_PATTERN = /^([a-z][a-z\\d+.-]*):\\/\\//i;\nconst MONGO_SCHEMES = /* @__PURE__ */ new Set([\"mongodb\", \"mongodb+srv\"]);\nfunction validateMongoUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a non-empty string\");\n\tconst scheme = URL_SCHEME_PATTERN.exec(trimmed)?.[1];\n\tif (scheme === void 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\tif (!MONGO_SCHEMES.has(scheme)) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must use mongodb:// or mongodb+srv://\");\n\ttry {\n\t\treturn new ConnectionString(trimmed);\n\t} catch {\n\t\tthrow mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\t}\n}\nfunction extractDbNameFromUrl(parsed) {\n\tconst [encodedDbName = \"\"] = parsed.pathname.slice(1).split(\"/\");\n\tif (encodedDbName.length === 0) return;\n\ttry {\n\t\treturn decodeURIComponent(encodedDbName);\n\t} catch {\n\t\tthrow mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must be a valid URL\");\n\t}\n}\nfunction resolveMongoBinding(options) {\n\tconst providedCount = Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.uri !== void 0) + Number(options.mongoClient !== void 0);\n\tif (providedCount !== 1) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, uri+dbName, or mongoClient+dbName\", { meta: { received: providedCount } });\n\tif (options.binding !== void 0) return options.binding;\n\tif (options.url !== void 0) {\n\t\tconst parsed = validateMongoUrl(options.url);\n\t\tif (options.dbName !== void 0 && options.dbName.trim().length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { url, dbName } requires a non-empty dbName\");\n\t\tconst explicitDbName = options.dbName?.trim();\n\t\tconst dbName = explicitDbName !== void 0 && explicitDbName.length > 0 ? explicitDbName : extractDbNameFromUrl(parsed);\n\t\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo URL must include a database name in its path (e.g. mongodb://host:27017/mydb), or pass dbName explicitly\");\n\t\treturn {\n\t\t\tkind: \"url\",\n\t\t\turl: options.url.trim(),\n\t\t\tdbName\n\t\t};\n\t}\n\tif (options.uri !== void 0) {\n\t\tvalidateMongoUrl(options.uri);\n\t\tconst dbName = options.dbName?.trim();\n\t\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { uri, dbName } requires a non-empty dbName\");\n\t\treturn {\n\t\t\tkind: \"url\",\n\t\t\turl: options.uri.trim(),\n\t\t\tdbName\n\t\t};\n\t}\n\tconst mongoClient = options.mongoClient;\n\tif (mongoClient === void 0) throw new InternalError(\"Invariant violation: expected mongo binding after validation\");\n\tconst dbName = options.dbName?.trim();\n\tif (dbName === void 0 || dbName.length === 0) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Mongo binding via { mongoClient, dbName } requires a non-empty dbName\");\n\treturn {\n\t\tkind: \"mongoClient\",\n\t\tclient: mongoClient,\n\t\tdbName\n\t};\n}\nfunction resolveOptionalMongoBinding(options) {\n\tconst providedCount = Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.uri !== void 0) + Number(options.mongoClient !== void 0);\n\tif (providedCount === 0) return;\n\tif (providedCount !== 1) throw mongoError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, uri+dbName, or mongoClient+dbName\", { meta: { received: providedCount } });\n\tif (options.binding !== void 0) return resolveMongoBinding({ binding: options.binding });\n\tif (options.url !== void 0) return resolveMongoBinding(options.dbName !== void 0 ? {\n\t\turl: options.url,\n\t\tdbName: options.dbName\n\t} : { url: options.url });\n\tif (options.uri !== void 0) return resolveMongoBinding({\n\t\turi: options.uri,\n\t\tdbName: options.dbName ?? \"\"\n\t});\n\tif (options.mongoClient !== void 0) return resolveMongoBinding({\n\t\tmongoClient: options.mongoClient,\n\t\tdbName: options.dbName ?? \"\"\n\t});\n\tthrow new InternalError(\"Invariant violation: expected one mongo binding branch\");\n}\n//#endregion\n//#region src/runtime/prepared-row-query.ts\nasync function prepareMongoQuery(runtime, declaration, callback) {\n\tlet description;\n\tconst statement = await runtime.prepare(declaration, (placeholders) => {\n\t\tconst authored = callback(placeholders);\n\t\tif (\"plan\" in authored) {\n\t\t\tdescription = authored;\n\t\t\treturn authored.plan;\n\t\t}\n\t\treturn authored;\n\t});\n\treturn blindCast(description ? createMongoPreparedRowQuery(description, statement) : statement);\n}\nfunction createMongoPreparedRowQuery(description, statement) {\n\treturn Object.freeze({ query(target, params, options) {\n\t\treturn description.consume(statement.query(target, params, options));\n\t} });\n}\n//#endregion\n//#region src/runtime/mongo.ts\n/**\n* Creates a lazy Mongo client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The `orm` and `query` surfaces are\n* available at once; the driver connects on the first query or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-mongo/static';\n* import mongo from '@prisma/orm-mongo/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = mongo({ contract, url: process.env['MONGODB_URL']! });\n* ```\n*/\nfunction mongo(options) {\n\tconst contract = validateMongoContract(options.contract);\n\tlet binding = resolveOptionalMongoBinding(options);\n\tconst stack = createMongoExecutionStack({\n\t\ttarget: mongoRuntimeTarget,\n\t\tadapter: mongoRuntimeAdapter,\n\t\tdriver: mongoRuntimeDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst { context, query, enums, raw } = buildMongoStaticContext(contract, stack);\n\tlet runtimePromise;\n\tlet closed = false;\n\tlet runtimeInstance;\n\tconst closedError = () => mongoError(\"DRIVER.NOT_CONNECTED\", \"Mongo client is closed\");\n\tconst createRuntime = () => {\n\t\tif (runtimeInstance !== void 0) return runtimeInstance;\n\t\tconst driver = stack.driver.create();\n\t\truntimeInstance = {\n\t\t\truntime: createMongoRuntime({\n\t\t\t\tcontext,\n\t\t\t\tadapter: stack.adapter.create(stack),\n\t\t\t\tdriver,\n\t\t\t\t...ifDefined(\"mode\", options.mode),\n\t\t\t\t...ifDefined(\"middleware\", options.middleware)\n\t\t\t}),\n\t\t\tdriver\n\t\t};\n\t\treturn runtimeInstance;\n\t};\n\tconst buildRuntime = async (resolvedBinding) => {\n\t\tconst { runtime, driver } = createRuntime();\n\t\tawait driver.connect(resolvedBinding);\n\t\treturn runtime;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) return Promise.reject(closedError());\n\t\tif (runtimePromise !== void 0) return runtimePromise;\n\t\tif (binding === void 0) return Promise.reject(mongoError(\"RUNTIME.BINDING_MISSING\", \"Mongo binding not configured. Pass url/uri+dbName/mongoClient+dbName/binding to mongo(...) or call db.connect({ ... }).\"));\n\t\truntimePromise = buildRuntime(binding).catch((err) => {\n\t\t\truntimePromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn runtimePromise;\n\t};\n\tfunction queryRows(plan) {\n\t\tasync function* iterate() {\n\t\t\tyield* (await getRuntime()).query(plan);\n\t\t}\n\t\treturn new AsyncIterableResult(iterate());\n\t}\n\tasync function executeStats(plan) {\n\t\treturn (await getRuntime()).execute(plan);\n\t}\n\treturn {\n\t\torm: mongoOrm({\n\t\t\tcontext,\n\t\t\truntime: {\n\t\t\t\tquery: queryRows,\n\t\t\t\texecute: executeStats\n\t\t\t}\n\t\t}),\n\t\tquery,\n\t\traw,\n\t\tcontract,\n\t\tenums,\n\t\tcontext,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw closedError();\n\t\t\tif (runtimePromise !== void 0) {\n\t\t\t\tif (bindingInput !== void 0) throw mongoError(\"DRIVER.ALREADY_CONNECTED\", \"Mongo client is already bound\", {\n\t\t\t\t\twhy: \"connect() was given options after the client was bound to a database.\",\n\t\t\t\t\tfix: \"Call connect() without options, or create a new client for another database.\"\n\t\t\t\t});\n\t\t\t\tconst runtime = await runtimePromise;\n\t\t\t\tif (closed) throw closedError();\n\t\t\t\treturn runtime;\n\t\t\t}\n\t\t\tif (bindingInput !== void 0) binding = resolveMongoBinding(bindingInput);\n\t\t\tif (binding === void 0) throw mongoError(\"RUNTIME.BINDING_MISSING\", \"Mongo binding not configured. Pass url/uri+dbName/mongoClient+dbName/binding to mongo(...) or call db.connect({ ... }).\");\n\t\t\tconst runtime = await getRuntime();\n\t\t\tif (closed) throw closedError();\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tasync prepare(declaration, callback) {\n\t\t\tif (closed) throw closedError();\n\t\t\treturn prepareMongoQuery(createRuntime().runtime, declaration, callback);\n\t\t},\n\t\tasync close() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\tawait runtimePromise?.catch(() => void 0);\n\t\t\tawait runtimeInstance?.runtime.close();\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { mongo as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,WAAW,MAAM,SAAS,SAAS;CAC3C,OAAO,gBAAgB,MAAM,SAAS;EACrC,GAAG;EACH,MAAM;GACL,GAAG,SAAS;GACZ,WAAW;EACZ;CACD,CAAC;AACF;AAGA,MAAM,qBAAqB;AAC3B,MAAM,gCAAgC,IAAI,IAAI,CAAC,WAAW,aAAa,CAAC;AACxE,SAAS,iBAAiB,KAAK;CAC9B,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,WAAW,2BAA2B,sCAAsC;CAC5G,MAAM,SAAS,mBAAmB,KAAK,OAAO,CAAC,GAAG;CAClD,IAAI,WAAW,KAAK,GAAG,MAAM,WAAW,2BAA2B,+BAA+B;CAClG,IAAI,CAAC,cAAc,IAAI,MAAM,GAAG,MAAM,WAAW,2BAA2B,iDAAiD;CAC7H,IAAI;EACH,OAAO,IAAI,iBAAiB,OAAO;CACpC,QAAQ;EACP,MAAM,WAAW,2BAA2B,+BAA+B;CAC5E;AACD;AACA,SAAS,qBAAqB,QAAQ;CACrC,MAAM,CAAC,gBAAgB,MAAM,OAAO,SAAS,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG;CAC/D,IAAI,cAAc,WAAW,GAAG;CAChC,IAAI;EACH,OAAO,mBAAmB,aAAa;CACxC,QAAQ;EACP,MAAM,WAAW,2BAA2B,+BAA+B;CAC5E;AACD;AACA,SAAS,oBAAoB,SAAS;CACrC,MAAM,gBAAgB,OAAO,QAAQ,YAAY,KAAK,CAA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AO,IAAI,oBAAoB,QAAQ,CAAC;CACzC;CACA,eAAe,aAAa,MAAM;EACjC,QAAQ,MAAM,WAAW,EAAA,CAAG,QAAQ,IAAI;CACzC;CACA,OAAO;EACN,KAAK,SAAS;GACb;GACA,SAAS;IACR,OAAO;IACP,SAAS;GACV;EACD,CAAC;EACD;EACA;EACA;EACA;EACA;EACA,MAAM,QAAQ,cAAc;GAC3B,IAAI,QAAQ,MAAM,YAAY;GAC9B,IAAI,mBAAmB,KAAK,GAAG;IAC9B,IAAI,iBAAiB,KAAK,GAAG,MAAM,WAAW,4BAA4B,iCAAiC;KAC1G,KAAK;KACL,KAAK;IACN,CAAC;IACD,MAAM,UAAU,MAAM;IACtB,IAAI,QAAQ,MAAM,YAAY;IAC9B,OAAO;GACR;GACA,IAAI,iBAAiB,KAAK,GAAG,UAAU,oBAAoB,YAAY;GACvE,IAAI,YAAY,KAAK,GAAG,MAAM,WAAW,2BAA2B,yHAAyH;GAC7L,MAAM,UAAU,MAAM,WAAW;GACjC,IAAI,QAAQ,MAAM,YAAY;GAC9B,OAAO;EACR;EACA,UAAU;GACT,OAAO,WAAW;EACnB;EACA,MAAM,QAAQ,aAAa,UAAU;GACpC,IAAI,QAAQ,MAAM,YAAY;GAC9B,OAAO,kBAAkB,cAAc,CAAC,CAAC,SAAS,aAAa,QAAQ;EACxE;EACA,MAAM,QAAQ;GACb,IAAI,QAAQ;GACZ,SAAS;GACT,MAAM,gBAAgB,YAAY,KAAK,CAAC;GACxC,MAAM,iBAAiB,QAAQ,MAAM;EACtC;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
package/dist/static.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as contractFromJson, r as mongoStatic } from "./mongo-static-CSxUjmzn-DN51T3o2.mjs";
1
+ import { n as contractFromJson, r as mongoStatic } from "./mongo-static-B6oScFYI-CzoifwUM.mjs";
2
2
  export { contractFromJson, mongoStatic as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-mongo",
3
- "version": "8.0.0-rc.25-dev.4",
3
+ "version": "8.0.0-rc.25-dev.6",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -13,19 +13,19 @@
13
13
  "skills"
14
14
  ],
15
15
  "dependencies": {
16
- "@prisma/orm-family-mongo": "8.0.0-rc.25-dev.4",
17
- "@prisma/orm-framework": "8.0.0-rc.25-dev.4",
18
- "@prisma/orm-target-mongo": "8.0.0-rc.25-dev.4",
19
- "@prisma/orm-toolchain": "8.0.0-rc.25-dev.4",
16
+ "@prisma/orm-family-mongo": "8.0.0-rc.25-dev.6",
17
+ "@prisma/orm-framework": "8.0.0-rc.25-dev.6",
18
+ "@prisma/orm-target-mongo": "8.0.0-rc.25-dev.6",
19
+ "@prisma/orm-toolchain": "8.0.0-rc.25-dev.6",
20
20
  "mongodb-connection-string-url": "^7.0.2",
21
21
  "pathe": "^2.0.3",
22
22
  "tinyglobby": "^0.2.17",
23
23
  "temporal-spec": "1.0.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@internal/mongo": "8.0.0-rc.25-dev.4",
27
- "@repo/tsconfig": "8.0.0-rc.25-dev.4",
28
- "@repo/tsdown": "8.0.0-rc.25-dev.4",
26
+ "@internal/mongo": "8.0.0-rc.25-dev.6",
27
+ "@repo/tsconfig": "8.0.0-rc.25-dev.6",
28
+ "@repo/tsdown": "8.0.0-rc.25-dev.6",
29
29
  "tsdown": "0.22.14",
30
30
  "typescript": "5.9.3"
31
31
  },
@@ -15,7 +15,7 @@ description: >-
15
15
  ORM 7 or earlier (schema.prisma + @prisma/client).
16
16
  metadata:
17
17
  library: '@prisma/orm-mongo'
18
- library_version: '8.0.0-rc.25-dev.4'
18
+ library_version: '8.0.0-rc.25-dev.6'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -504,6 +504,7 @@ Change the code that reads these values:
504
504
 
505
505
  - Code that parses the old text, for example by replacing the space with `T` or appending `Z` before `new Date(...)`, can pass the value to `new Date(...)` or `Temporal.Instant.from(...)` directly for a `TimestamptzString`. A `TimestampString` value has no offset; append `Z` to read it as UTC, as before.
506
506
  - Code that compares a read value with text in the old form, in application code or in tests, compares with the ISO form.
507
+ - Code that sorts or compares two read values as text no longer gets time order for a `TimestamptzString`, or for a `Timetz` at offset zero. Such a value ends in `Z`, and the fraction of a second is written without trailing zeros, or left out when it is zero. As text, `Z` sorts after `.` and the digits, so `2026-11-07T11:56:48Z` sorts after `2026-11-07T11:56:48.5Z`, although it is half a second earlier. Compare two `TimestamptzString` values as instants, for example with `Temporal.Instant.compare(Temporal.Instant.from(a), Temporal.Instant.from(b))`, after handling `infinity` and `-infinity`, which a column can hold and `Temporal.Instant.from` refuses, or sort in the query with `orderBy`, which the database does by time.
507
508
  - Code that shows a value to a user formats it for display, since the value is no longer in the session's time zone.
508
509
 
509
510
  A value the application writes may still be in any form PostgreSQL reads, and it reads back in ISO 8601. A literal default or an enum member on these types must be written in the stored form, because Prisma compares it with the value a query returns:
@@ -152,7 +152,7 @@ Do the steps in this order, and skip a step that does not apply to the project:
152
152
  1. Upgrade the Prisma packages. A project that installs with Yarn and uses MySQL or SQLite adds `temporal-polyfill` to its dependencies (`temporal-polyfill-is-a-peer-dependency-of-mysql`, `temporal-polyfill-is-a-peer-dependency-of-sqlite`).
153
153
  2. Change the contract sources. On PostgreSQL, rewrite the deprecated scalar type names and helpers (`psl-renamed-postgres-scalar-types`, `ts-renamed-postgres-scalar-helpers`, `ts-renamed-postgres-column-helpers`). Remove the application's own declaration of an extension that a composed pack declares (`remove-pack-extension-declaration`). On MongoDB, name one of two indexes that get one name (`mongo-unnamed-indexes-with-one-name-refused`).
154
154
  3. Change MongoDB and PostgreSQL application code: pass the extension packs to `mongo()` and `mongoStatic()` (`mongo-client-takes-extensions`), and give `supabase()` and `postgres()` one valid database input (`supabase-one-binding-input`, `postgres-checks-database-input`).
155
- 4. Run `prisma contract emit` and commit what it writes, including the files under `migrations/`. Fix what it refuses for a Prisma 6 MongoDB schema (`mongo-prisma6-indexes-as-prisma6-reads-them`, `mongo-prisma6-index-names`). This step also covers `mongo-contract-requires-target`, `pack-extension-found-on-search-path` and `contract-artifacts-restamp`.
155
+ 4. Run `prisma contract emit` and commit what it writes, including the files under `migrations/`. Fix what it refuses for a Prisma 6 MongoDB schema (`mongo-prisma6-indexes-as-prisma6-reads-them`, `mongo-prisma6-index-names`). This step also covers `mongo-contract-requires-target`, `pack-extension-found-on-search-path` and `contract-artifacts-restamp`. A PostgreSQL or SQLite contract also gains the capability `insertOnConflictTarget: true` in its `sql` group, in `contract.json` and `contract.d.ts`. A contract emitted without it keeps working, because the runtime adds the adapter's capabilities to the contract's.
156
156
  5. On MongoDB, run the colocated script to name the indexes of the contract snapshots under `migrations/snapshots/` (`mongo-contracts-record-index-names`).
157
157
  6. Bring each database up to date: run `prisma db migrate` for a pgvector, PostGIS, ParadeDB or citext pack (`pack-extension-found-on-search-path`). On MongoDB, run `prisma db sign`, or plan and apply the migration with no operations (`mongo-contracts-record-index-names`). For a Prisma 6 MongoDB schema, run `prisma db verify` before you sign (`mongo-prisma6-index-names`).
158
158
  7. Change the remaining code: scripts and tests that match a MongoDB index operation id (`mongo-index-operations-by-name`), and MySQL writes of a year before 1000 or after 9999 (`mysql-datetime-writes-are-checked`). Check a SQLite `date('now')` default that `db verify` reports (`temporal-polyfill-is-a-peer-dependency-of-sqlite`).
@@ -4,12 +4,11 @@ to: "8.0.0-rc.24"
4
4
  changes:
5
5
  - id: engine-pin-moves-to-0-10-0
6
6
  summary: |
7
- The toolchain now requires `@prisma/cli-engine@0.10.0` (up from 0.9.0). A project that depends on `@prisma/cli-engine` itself must move to `0.10.0`.
7
+ The toolchain now requires `@prisma/cli-engine@0.10.0` (up from 0.9.0). A project that depends on `@prisma/cli-engine` itself must move to `0.10.0`. The detection matches every declaration of `@prisma/cli-engine` in a `pnpm-workspace.yaml`, and in a `package.json` that lists an `@prisma/orm-*` package or names the engine in `overrides` or `resolutions`, unless its value is the plain version `0.10.0`, the version the toolchain peers. An exact pin in npm's object form, `{ ".": "0.10.0" }`, is matched too and needs no change.
8
8
  detection:
9
9
  glob: "**/{package.json,pnpm-workspace.yaml}"
10
10
  matches:
11
- - '"@prisma/cli-engine":\s*"[^"]*(?<![\d.])0\.\d(?!\d)'
12
- - '[''"]?@prisma/cli-engine[''"]?:\s*[''"]?[\^~]?0\.\d(?![\d])'
11
+ - '(?<![\s\S])(?:(?=\s*\{)(?=[\s\S]*(?:"@prisma/orm-[a-z-]+"\s*:|"(?:overrides|resolutions)"\s*:[\s\S]*@prisma/cli-engine(?:@[^"\s]*)?"))|(?!\s*\{))[\s\S]*@prisma/cli-engine(?:@[^''"\s:]*)?[''"]?\s*:(?!\s*[''"]?0\.10\.0[''"]?\s*(?:[,}\r\n#]|$))'
13
12
  - id: prisma-7-commands-answer-v7-command
14
13
  summary: |
15
14
  A Prisma 7 command the ORM answers, such as `prisma migrate dev`, now fails with `CLI.V7_COMMAND` instead of `CLI.COMMAND_MOVED`, still with exit code 2.
@@ -86,6 +85,13 @@ changes:
86
85
  - '(?<![\s\S])(?=[\s\S]*@prisma/orm-family-sql/relational-core/(?:ast|expression)[\x27"])(?=[\s\S]*(?<![\w$])(?:RawExpr|RawQueryAst|RawPart)(?![\w$]))[\s\S]*\.parts(?![\w$])'
87
86
  - id: mysql-explicit-isolation-default
88
87
  summary: Configure ReadCommitted explicitly if MySQL callbacks relied on the previous session-wide override.
88
+ - id: postgres-statement-on-lost-client-refused
89
+ summary: |
90
+ The PostgreSQL driver now refuses a statement on a `pg` client that lost its connection with `DRIVER.NOT_CONNECTED` and the message `Postgres connection is no longer usable.` It checks on a pooled connection, on a held connection, and in a transaction or savepoint, including its `BEGIN`, `COMMIT`, `ROLLBACK` and savepoint statements, and before each later step of a cursor. A client has lost its connection once it emitted `error` or `end` after the driver first used it, once a driver gave up on it (for example by destroying the connection of a transaction that ran out of time), or when `pg` marks it ended or broken. Before, such a statement was sent to the client. On a driver given one `pg.Client` that has already lost its connection, a query, and the start of a transaction or held connection, were already refused at 8.0.0-rc.23 with "Postgres connection lost or closed. Create a new client to reconnect.", and still are; the new message comes on a connection or transaction taken before the loss. The driver keeps this state for the client object, so code that recovers by patching the same object, for example by replacing its `query` method, now fails on the next statement: release the client and take a new one from the pool, or create a new `pg.Client`. The detection matches TypeScript and JavaScript sources that import `pg` and assign or define a `query` property, with `.query =`, `['query'] =`, `Object.defineProperty` or `Object.assign`.
91
+ detection:
92
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
93
+ matches:
94
+ - '(?<![\s\S])(?=[\s\S]*(?:from\s*|require\s*\(\s*|import\s*\(\s*)[''"]pg[''"])[\s\S]*(?:\.query\s*=(?![=>])|\[\s*[''"]query[''"]\s*\]\s*=(?![=>])|defineProperty\s*\([^,]*,\s*[''"]query[''"]|Object\.assign\s*\([^,]*,\s*\{[^}]*\bquery\s*[:,}(])'
89
95
  - id: contract-artifacts-restamp
90
96
  summary: |
91
97
  An extension that writes its own package version into the contracts it emits, such as the Supabase extension, now writes 8.0.0-rc.24. Run `contract emit` once after upgrading so the emitted `contract.json` and `contract.d.ts` match the installed extension.
@@ -105,7 +111,7 @@ Do the steps in this order, and skip a step that does not apply to the project:
105
111
  2. Change the MongoDB contract sources. Run the field-types script first (`mongo-fields-take-a-type`), then the date-types script (`mongo-date-is-a-calendar-date`). The first script writes `field.date()` as `field.scalar(type.DateTime())`, so the second has nothing left to do for it; the second rewrites `Date` to `DateTime` in MongoDB schemas.
106
112
  3. Run `prisma contract emit` and commit what it writes. The MongoDB contracts must not change; the only change to expect is the extension version stamp (`contract-artifacts-restamp`).
107
113
  4. In PostgreSQL `migration.ts` files, call `this.createExtension(...)` and `this.dataTransform(...)` instead of the free functions (`create-extension-not-exported`, `data-transform-not-exported`). Existing `ops.json` files do not change.
108
- 5. Change the remaining code: MySQL callback transactions that relied on READ COMMITTED (`mysql-explicit-isolation-default`), code that walks the `parts` of a raw SQL node (`raw-parts-hold-statement-asts`), and scripts that read the CLI's `--json` planner warnings or check for `CLI.COMMAND_MOVED` (`planner-warnings-json-field`, `prisma-7-commands-answer-v7-command`).
114
+ 5. Change the remaining code: MySQL callback transactions that relied on READ COMMITTED (`mysql-explicit-isolation-default`), PostgreSQL code that reuses a `pg` client after it lost its connection (`postgres-statement-on-lost-client-refused`), code that walks the `parts` of a raw SQL node (`raw-parts-hold-statement-asts`), and scripts that read the CLI's `--json` planner warnings or check for `CLI.COMMAND_MOVED` (`planner-warnings-json-field`, `prisma-7-commands-answer-v7-command`).
109
115
  6. On MongoDB, the next `migration plan` or `db update` checks documents against a changed validator, asks about field type changes that can lose values, and fills new required fields with a temporary value. Read those three entries before planning the next schema change (`mongo-validator-change-checks-documents`, `mongo-type-change-is-asked`, `mongo-new-required-field-gets-temporary-value`).
110
116
 
111
117
 
@@ -113,7 +119,7 @@ Do the steps in this order, and skip a step that does not apply to the project:
113
119
 
114
120
  ### `engine-pin-moves-to-0-10-0`
115
121
 
116
- For every file matched by `detection`, change the `@prisma/cli-engine` version (`0.9.0`, `^0.9.0` or any other 0.x below 0.10) to `0.10.0` and reinstall. Projects assembled by the `prisma` CLI resolve the engine automatically.
122
+ For every file matched by `detection`, change each `@prisma/cli-engine` version that is not exactly `0.10.0`, such as `0.9.0`, `^0.9.0`, `>=0.9.0 <0.10.0` or `^0.10.0`, to `0.10.0` and reinstall. The toolchain peers that exact version, so a range that allows any other version, newer ones included, can install an engine it refuses. A package that declares `@prisma/cli-engine` without any `@prisma/orm-*` package, such as a workspace root, keeps its pin only when no package of the workspace uses that pin with the ORM toolchain; when one does, change it too. The detection does not match such a `package.json` unless it also has an `overrides` or `resolutions` field, so check the workspace root by hand. An `overrides` or `resolutions` entry for `@prisma/cli-engine` at the top level, such as npm's `"@prisma/cli-engine": "0.9.0"` or `"@prisma/cli-engine": { ".": "0.9.0" }`, or Yarn's `"**/@prisma/cli-engine"`, pins the engine for every package of the workspace, so change it even in a root `package.json` that lists no `@prisma/orm-*` package. npm refuses an override of a package that the same `package.json` also depends on directly unless both are written the same, so write such a direct dependency the same as the override. An entry scoped under another package applies only there. npm's nested form, `"some-package": { "@prisma/cli-engine": "0.9.0" }`, applies to every copy of the engine below that package: change it when that package is an `@prisma/orm-*` package, such as `@prisma/orm-toolchain`, or depends on one, and leave it otherwise. pnpm's `"some-package>@prisma/cli-engine"` applies to that package's own dependency on the engine: change it when that package is an `@prisma/orm-*` package, and leave it otherwise. A `pnpm-workspace.yaml` matches whatever its packages are, so change its pin only when a package that takes the engine from it also lists an `@prisma/orm-*` package. Projects assembled by the `prisma` CLI resolve the engine automatically.
117
123
 
118
124
  ### `prisma-7-commands-answer-v7-command`
119
125
 
@@ -314,6 +320,17 @@ A defined per-call level overrides the factory level. An omitted or undefined le
314
320
  Verify behavior against the deployment's configured database default and concurrent transactions. Do not assume the server default is RepeatableRead. This change does not introduce batch transactions, timeout/maxWait options, P2028 handling or retry behavior.
315
321
 
316
322
 
323
+ ## PostgreSQL: a statement on a `pg` client that lost its connection is refused
324
+
325
+ ### `postgres-statement-on-lost-client-refused`
326
+
327
+ The PostgreSQL driver now checks whether a `pg` client has lost its connection before it sends a statement on a pooled connection, on a held connection, and in a transaction or savepoint, including its `BEGIN`, `COMMIT`, `ROLLBACK` and savepoint statements, and before each later step of a cursor, and refuses the statement with `DRIVER.NOT_CONNECTED` and the message `Postgres connection is no longer usable.` if so. A client has lost its connection once it emitted `error` or `end` after the driver first used it, once a driver gave up on it (for example by destroying the connection of a transaction that ran out of time), or when `pg` marks it ended or broken. Before this release, such a statement was sent to the client whatever its state. On a driver given one `pg.Client` that has already lost its connection, a query, and the start of a transaction or held connection, were already refused at 8.0.0-rc.23 with "Postgres connection lost or closed. Create a new client to reconnect.", and still are; the new message comes on a connection or transaction taken before the loss.
328
+
329
+ The driver records the loss against the client object, and nothing clears it. Code that recovers from a lost connection by patching the same client object stops working. For example, a pool wrapper that retries a failed first statement on a new connection by replacing `client.query` on the checked-out client: the retried statement succeeds inside the replaced `query`, and the next statement the driver sends on that client rejects with `DRIVER.NOT_CONNECTED`.
330
+
331
+ In each file the detection matches, check whether the code changes a `pg` client it gave to Prisma 8, or a client of a pool it gave to Prisma 8, to recover from a lost connection. If it does, release the lost client and take a new one from the pool instead (`client.release(error)`, then `pool.connect()`), or create a new `pg.Client`, and let the work run on the new client. A file that patches a client without importing `pg`, or that wraps the client in a `Proxy`, is not found; check pool wrappers by hand. Code that does not reuse a lost client needs no change.
332
+
333
+
317
334
  ## `contract-artifacts-restamp`
318
335
 
319
336
  For every `contract.json` matched by `detection`, run the project's emit command (`prisma contract emit`, or the project's `contract:emit` script) once after upgrading. This entry accounts for the extension's embedded `version` moving to `8.0.0-rc.24`; any other difference in the emitted files comes from an earlier entry in this guide.
@@ -9,7 +9,7 @@ changes:
9
9
  glob: "**/*.{prisma,ts,mts,cts,sql,json}"
10
10
  matches:
11
11
  - '(?<![\w$])Money(?![\w$])'
12
- - 'pg/money@1'
12
+ - '(?<!output: )[''"]pg/money@1[''"](?!\s*:)'
13
13
  - '::\s*(?:money|MONEY)(?![\w$])'
14
14
  - id: pg-is-a-peer-dependency
15
15
  summary: |
@@ -26,6 +26,15 @@ changes:
26
26
  matches:
27
27
  - '"temporal-polyfill"\s*:\s*"[\^~]?1\.0\.[0-7](?![\d])'
28
28
  - '[''"]?temporal-polyfill[''"]?:\s*[''"]?[\^~]?1\.0\.[0-7](?![\d])'
29
+ - id: arktype-and-bson-ranges-move
30
+ summary: |
31
+ The `@prisma/orm-*` packages now depend on `arktype` `^2.2.9` (up from `^2.2.2`), and `@prisma/orm-target-mongo`, which `@prisma/orm-mongo` installs, on `bson` `^7.3.4` (up from `^7.2.0`). A project that declares either itself in a range that allows an older version, or whose lockfile keeps one, can install two copies: its own and the one Prisma 8 uses. With two copies, an `instanceof` check against one copy's class, such as `instanceof type.errors`, does not recognise a value the other copy made and does not narrow its type, and TypeScript reports errors where the two copies' types meet. Move the declared range inside the new one and reinstall, so one copy is installed. The detection matches every declaration of either package, including the catalogs in `pnpm-workspace.yaml` and `.yarnrc.yml` and an `npm:` alias of either; the guide's section says how to tell from the value whether it needs a change, and to check in every case that one copy of each is installed.
32
+ detection:
33
+ glob: "**/{package.json,pnpm-workspace.yaml,.yarnrc.yml}"
34
+ matches:
35
+ - '(?:(?<=\*\*/)|(?<![\w@/.#-]))[''"]?(?:(?:@[\w.-]+/)?[\w-][\w.-]*/)?arktype(?:@[^''"\s:]*)?[''"]?\s*:'
36
+ - '(?:(?<=\*\*/)|(?<![\w@/.#-]))[''"]?(?:(?:@[\w.-]+/)?[\w-][\w.-]*/)?bson(?:@[^''"\s:]*)?[''"]?\s*:'
37
+ - '(?<![\w-])npm:(?:arktype|bson)(?:@|[''"]|\s|$)'
29
38
  - id: config-type-renamed-to-prisma-config
30
39
  summary: |
31
40
  The config type that `defineConfig` returns is renamed from `PrismaNextConfig` to `PrismaConfig`, in `@prisma/orm-toolchain/cli/config-types` and every package that re-exports it. The old name is gone. The detection matches TypeScript sources that name the old type.
@@ -147,18 +156,11 @@ changes:
147
156
  - '(?<![\s\S])(?=[\s\S]*[''"](?:@prisma/orm-sqlite|@internal/sqlite)/contract-builder[''"])[\s\S]*\.\s*Decimal\s*\('
148
157
  - id: sqlite-integer-safe-range
149
158
  summary: |
150
- 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.
159
+ 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. The detection matches a project that depends on the SQLite package or whose config imports it.
151
160
  detection:
152
- glob: "**/*.{prisma,ts,mts,cts,tsx}"
161
+ glob: "**/{package.json,prisma.config.{ts,mts,cts,js,mjs}}"
153
162
  matches:
154
- - '(?:^|\n)[ \t]*[A-Za-z_]\w*[ \t]+(?:Int|IntegerNumber)(?![\w])'
155
- - '=[ \t]*(?:Int|IntegerNumber)(?![\w])'
156
- - 'BigInt[ \t]*\([ \t]*as[ \t]*:[ \t]*number'
157
- - '(?<![\s\S])(?=[\s\S]*[''"](?:@prisma/orm-sqlite|@internal/sqlite)/contract-builder[''"])[\s\S]*\.\s*(?:Int|IntegerNumber)\s*\('
158
- - '(?<![\s\S])(?=[\s\S]*[''"](?:@prisma/orm-sqlite|@internal/sqlite)/contract-builder[''"])[\s\S]*\.\s*BigInt\s*\(\s*\{[^}]*as\s*:\s*[''"]number[''"]'
159
- - '(?<![\w$])(?:integerNumberColumn|sqliteIntegerColumn)(?![\w$])'
160
- - '(?: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)[''"]'
161
- - '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$])'
163
+ - '[''"]@prisma/orm-(?:sqlite|target-sqlite)(?:/[\w./-]*)?[''"]'
162
164
  - id: psl-renamed-mongo-int64
163
165
  summary: |
164
166
  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.
@@ -311,11 +313,11 @@ changes:
311
313
  - 'orm init\b[^\n]*--json'
312
314
  - id: orm-write-inside-transaction-suspends-tx
313
315
  summary: |
314
- An ORM write of more than one statement on `tx.orm`, such as a create with a nested relation, runs in a savepoint. While it runs, other work sent on the same `tx` 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`.
316
+ An ORM write of more than one statement on `tx.orm`, such as a create with a nested relation, runs in a savepoint. While it runs, other work sent on the same `tx` rejects with `RUNTIME.TRANSACTION_SUSPENDED`. In `Promise.all`, that rejection makes the callback throw while the write still runs, so `db.transaction` rejects with `RUNTIME.TRANSACTION_ROLLBACK_FAILED`, whose `cause` is the `RUNTIME.TRANSACTION_SUSPENDED` error, keeps nothing the transaction wrote, and closes the connection. When such a write fails with an error that ends the whole transaction, such as a deadlock on MySQL or MariaDB, the write itself rejects with `RUNTIME.TRANSACTION_ROLLBACK_FAILED`, whose `cause` is the database's error, and the transaction is closed. On PostgreSQL and SQLite many writes are one statement and open no savepoint; on MySQL and MariaDB every write that returns rows opens one. The detection matches TypeScript sources that call `transaction` and `Promise.all` or `Promise.allSettled`.
315
317
  detection:
316
318
  glob: "**/*.{ts,mts,cts,tsx}"
317
319
  matches:
318
- - '(?<![\s\S])(?=[\s\S]*\.transaction\s*\()[\s\S]*Promise\.all'
320
+ - '(?<![\s\S])(?=[\s\S]*\.transaction\s*\()[\s\S]*Promise\.all(?:Settled)?\s*\('
319
321
  - id: foreign-key-with-relation-callback-refused
320
322
  summary: |
321
323
  `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.
@@ -379,19 +381,18 @@ changes:
379
381
  - '(?<![\s\S])(?=[\s\S]*@prisma/orm-(?:mysql|mariadb))[\s\S]*\bmeta\??\.target\b'
380
382
  - id: db-migrate-advances-db-ref
381
383
  summary: |
382
- `prisma db migrate` now advances the `db` ref after a successful apply when the connection comes from `prisma.config.ts` and the CLI does not detect CI. Without `--advance-ref`, it still advances nothing with `--db` or in CI. A `db migrate --advance-ref db` that reads its connection from the config outside CI can drop the flag; one that passes `--db` or runs in CI keeps it. A deploy or script that runs `db migrate` from the config outside a CI runner, and must not change `migrations/app/refs/db.json`, passes the new `--no-advance-ref` or `--db`. A failed ref write is now a warning and the command exits 0, which matters to a script that checks the exit code of `db migrate --advance-ref`. The detection finds `db migrate` commands that pass `--advance-ref`, and those that pass neither `--db` nor `--no-advance-ref`, including a Dockerfile's exec form, a YAML list and a command split with a backslash between `db` and `migrate`; it reads the flags only on the line where `migrate` is; check each against the cases below, and look for others in files it does not search.
384
+ `prisma db migrate` now advances the `db` ref after a successful apply when the connection comes from `prisma.config.ts` and the CLI does not detect CI. Without `--advance-ref`, it still advances nothing with `--db` or in CI. A `db migrate --advance-ref db` that reads its connection from the config outside CI can drop the flag; one that passes `--db` or runs in CI keeps it. A deploy or script that runs `db migrate` from the config outside a CI runner, and must not change `migrations/app/refs/db.json`, passes the new `--no-advance-ref` or `--db`. A failed ref write is now a warning and the command exits 0, which matters to a script that checks the exit code of `db migrate --advance-ref`. The detection finds `prisma db migrate` commands that pass `--advance-ref`, and those that pass neither `--db` nor `--no-advance-ref`, including a Dockerfile's exec form, a YAML list, a command split with a backslash between its words, a command whose `prisma` comes from a shell or Make variable such as `$PRISMA`, `$CLI` or `$(PRISMA)`, and a program that passes the arguments as a list, such as `execa('prisma', ['db', 'migrate'])`; it reads the flags on the line where `migrate` is and on the lines that line continues with a backslash; check each against the cases below, and look for others in files it does not search and in commands that reach `prisma` through a script of another name.
383
385
  detection:
384
386
  glob: "**/{*.json,*.sh,*.bash,*.zsh,*.yml,*.yaml,*.toml,*.md,*.mdx,*.ts,*.mts,*.js,*.mjs,*.cjs,Dockerfile*,*.dockerfile,Procfile*,Makefile,justfile}"
385
387
  matches:
386
- - '(?<![\w-])db(?:\s+|\s*\\\n\s*|["'']?\s*[,\n]\s*(?:-\s+)?["'']?)migrate\b(?:(?=[^\n]*--advance-ref\b)|(?![^\n]*--(?:db|no-advance-ref)\b))'
388
+ - '(?:(?<![\w-])prisma(?![\w-])|\$[({]?[A-Za-z_]\w*[)}]?)(?:[^\S\n](?:[^\n]*?[^\S\n])?|\s*\\\n\s*|["'']?\s*[,\n]\s*(?:-\s+)?\[?\s*["'']?)db(?:\s+|\s*\\\n\s*|["'']?\s*[,\n]\s*(?:-\s+)?["'']?)migrate\b(?:(?=[^\n]*(?:\\\n[^\n]*)*--advance-ref\b)|(?![^\n]*(?:\\\n[^\n]*)*--(?:db|no-advance-ref)\b))'
387
389
  - id: engine-pin-moves-to-0-10-4
388
390
  summary: |
389
- The toolchain now requires `@prisma/cli-engine@0.10.4` (up from 0.10.0). A project that depends on `@prisma/cli-engine` itself must move to `0.10.4`.
391
+ The toolchain now requires `@prisma/cli-engine@0.10.4` (up from 0.10.0). A project that depends on `@prisma/cli-engine` itself must move to `0.10.4`. The detection matches every declaration of `@prisma/cli-engine` in a `pnpm-workspace.yaml`, and in a `package.json` that lists an `@prisma/orm-*` package or names the engine in `overrides` or `resolutions`, unless its value is the plain version `0.10.4`, the version the toolchain peers. An exact pin in npm's object form, `{ ".": "0.10.4" }`, is matched too and needs no change.
390
392
  detection:
391
393
  glob: "**/{package.json,pnpm-workspace.yaml}"
392
394
  matches:
393
- - '"@prisma/cli-engine":\s*"[^"]*(?<![\d.])0\.(?:\d|10\.[0123xX*])(?!\d)'
394
- - '[''"]?@prisma/cli-engine[''"]?:\s*[''"]?(?:[\^~]|[<>]=?\s*)?0\.(?:\d|10\.[0123xX*])(?!\d)'
395
+ - '(?<![\s\S])(?:(?=\s*\{)(?=[\s\S]*(?:"@prisma/orm-[a-z-]+"\s*:|"(?:overrides|resolutions)"\s*:[\s\S]*@prisma/cli-engine(?:@[^"\s]*)?"))|(?!\s*\{))[\s\S]*@prisma/cli-engine(?:@[^''"\s:]*)?[''"]?\s*:(?!\s*[''"]?0\.10\.4[''"]?\s*(?:[,}\r\n#]|$))'
395
396
  - id: consent-required-summary-is-one-fixed-sentence
396
397
  summary: |
397
398
  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.
@@ -416,7 +417,7 @@ The examples write the ORM client as `db.orm.public.<Model>`, which is the Postg
416
417
  Do the steps in this order, and skip a step that does not apply to the project:
417
418
 
418
419
  1. Before you deploy the upgrade, on PostgreSQL with `money` columns, make the database print `money` in the `C` form (`postgres-lc-monetary-not-set`). The old release still forces it on its own connections, so do this first.
419
- 2. Before you run the install for the upgrade, fix the dependencies in `package.json`: declare `pg` and `@types/pg` for the PostgreSQL packages (`pg-is-a-peer-dependency`), move a declared `temporal-polyfill` to `^1.0.8` (`temporal-polyfill-peer-range-moves-to-1-0-8`), and move a declared `@prisma/cli-engine` to `0.10.4` (`engine-pin-moves-to-0-10-4`). Then upgrade the Prisma packages.
420
+ 2. Before you run the install for the upgrade, fix the dependencies in `package.json`: declare `pg` and `@types/pg` for the PostgreSQL packages (`pg-is-a-peer-dependency`), move a declared `temporal-polyfill` to `^1.0.8` (`temporal-polyfill-peer-range-moves-to-1-0-8`), move a declared `arktype` to `^2.2.9` and a declared `bson` to `^7.3.4` (`arktype-and-bson-ranges-move`), and move a declared `@prisma/cli-engine` to `0.10.4` (`engine-pin-moves-to-0-10-4`). Then upgrade the Prisma packages.
420
421
  3. Change the config and the scripts that call the control client: the renamed config type (`config-type-renamed-to-prisma-config`), the modules a hand-assembled config names (`hand-assembled-config-names-generated-file-modules`), `typesModule` and the removed `projectDir` (`control-api-takes-types-module`), the removed `publish-surface` entries (`toolchain-publish-surface-entrypoints-removed`), the arguments of `typescriptContractFromPath` (`typescript-contract-from-path-requires-target`), and the `migrate`, `dbUpdate` and `dbSign` options (`migrate-options-ref`, `db-sign-invocation`, `permit-policy-change`). Change the commands that run `prisma db migrate`, in scripts, deploys and docs, for the `db` ref it now advances (`db-migrate-advances-db-ref`).
421
422
  4. Change the contract sources. Make each TypeScript contract import `defineContract` from its config's target (`typescript-contract-for-another-target-refused`). Save every schema file as UTF-8 (`psl-schema-must-be-utf8`). Rewrite the renamed types and helpers: `sql.String` (`psl-renamed-sql-string`, `ts-renamed-sql-string`), the PostgreSQL and SQLite column helpers (`ts-renamed-postgres-json-column-helper`, `ts-renamed-sqlite-column-helpers`), SQLite's `BigIntNumber` (`sqlite-bigintnumber-deprecated`) and MongoDB's `Int64` (`psl-renamed-mongo-int64`, `ts-removed-mongo-int64-helper`, and optionally `psl-optional-mongo-convenience-names`). Fix each `hasOne` relation without a unique key (`has-one-key-must-be-unique`) and each attribute of a single-table variant that emit refuses (`sti-variant-unscoped-index-refused`). Rename anything named `__proto__` (`sql-proto-names-refused`, `mongo-proto-names-refused`); on MongoDB, read that section first, because a collection of that name needs its documents moved. On Postgres, rename a table or column named `__proto__` in the database before the next `prisma contract infer` (`postgres-infer-proto-name-refused`).
422
423
  5. Run `prisma contract emit` once for every contract and commit what it writes. One emit covers `contract-types-import-from-the-target-package`, `re-emit-for-include-capabilities`, `re-emit-mysql-contract-for-aggregates`, `mysql-reemit-contract`, `sqlite-decimal-codec`, `ts-sqlite-decimal-codec`, `sti-variant-foreign-keys-stored`, `json-default-proto-key-kept` and `contract-artifacts-restamp`. Leave the contract copies under `migrations/` as they are.
@@ -458,7 +459,7 @@ Raw SQL of your own that selects a `money` value as text printed the `C` form, `
458
459
  The CLI needs nothing: it sets `lc_monetary` itself while it reads the database and applies migrations.
459
460
 
460
461
 
461
- ## Dependencies: `pg` and `@types/pg` are peer dependencies, and `temporal-polyfill` moves to `^1.0.8`
462
+ ## Dependencies: `pg` and `@types/pg` are peer dependencies, and `temporal-polyfill`, `arktype` and `bson` move
462
463
 
463
464
  ### `pg-is-a-peer-dependency`
464
465
 
@@ -479,6 +480,12 @@ Without `pg`, the application fails at startup because Node.js cannot find the p
479
480
 
480
481
  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 project that does not declare `temporal-polyfill` itself needs no change: its package manager installs the peer at a version inside the new range.
481
482
 
483
+ ### `arktype-and-bson-ranges-move`
484
+
485
+ `arktype` and `bson` are dependencies of the Prisma 8 packages, not peers, so the package manager installs the version Prisma 8 asks for beside the project's own when the project's range or lockfile keeps an older one. A project that pins `arktype` at `2.2.3`, for example, then has two copies, and code such as `if (result instanceof type.errors)` on a value from the other copy no longer narrows `result`. On MongoDB the same holds for `bson` classes such as `ObjectId`.
486
+
487
+ The detection matches every declaration of `arktype` or `bson`: in a manifest, a catalog (`pnpm-workspace.yaml`, `.yarnrc.yml` or a Bun catalog in `package.json`), an override or a resolution. Read each value. A declaration needs a change unless every version it allows is inside `^2.2.9` (at least 2.2.9 and below 3) for `arktype`, or inside `^7.3.4` (at least 7.3.4 and below 8) for `bson`. So `^2.2.9`, `^2.2.10` or `~2.2.9` stays, and `2.2.3`, `^1.0.0`, `<3`, `*` or `>=7.3.4`, which allows `bson` 8, changes. Change such a declaration to `^2.2.9` for `arktype` and `^7.3.4` for `bson`, then reinstall. A `catalog:` or `workspace:` reference takes its range from the entry it points to, so judge and change that entry instead. An alias such as `"schema": "npm:arktype@2.2.3"` is matched too. It installs the package under another name, which is a separate copy from the one Prisma 8 loads whatever its range, so where its values meet Prisma 8's, declare the package under its own name instead. An override or resolution scoped under another package applies only there, so judge it by that package. npm's nested form, such as `"some-package": { "arktype": "^1.0.0" }`, applies to every copy below that package: change it when that package is an `@prisma/orm-*` package or depends on one, and leave it otherwise. pnpm's `"some-package>arktype"` applies to that package's own dependency: change it when that package is an `@prisma/orm-*` package, and leave it otherwise. Then, for every declaration, changed or not, check that the install holds one copy of each package, for example with `pnpm why arktype`, `npm ls arktype` or `yarn why arktype`, which list each installed copy. Count copies, not the paths that lead to them. A copy kept on purpose under an override scoped to another package, or under an alias, does not count: the check is for the copy that Prisma 8, and the code that passes values to it, load. In a workspace, run the check in every package that declares either one, or once with `pnpm why -r arktype` on pnpm. A range inside the new one can still resolve to a different version from the one Prisma 8 uses, for example when the lockfile keeps an older entry. If more than one copy is listed, even of the same version, write the declaration as the range the Prisma 8 packages use, `^2.2.9` or `^7.3.4`, reinstall and check again, until one copy is listed. A project that does not declare either itself needs no change.
488
+
482
489
 
483
490
  ## `PrismaNextConfig` is now `PrismaConfig`
484
491
 
@@ -519,7 +526,9 @@ In `contract.json`, each extension under `extensions` no longer records where it
519
526
 
520
527
  A file generated before the upgrade keeps working, because the modules it imports are still exported.
521
528
 
522
- Leave the copies of the contract kept beside each migration, under `migrations/snapshots/`, as they are. They keep working, and no command rewrites a snapshot that already exists; only a snapshot written from now on has the new form. Do not edit them or any `migration.ts` by hand.
529
+ The regenerated `contract.d.ts` of a PostgreSQL, SQLite, MySQL or MariaDB contract also lists the aggregate operations, the codec ids under each of them in `AggregateTypes`, the value sets, the tables and the namespaces in byte order, where earlier releases sorted them in the locale's order. So `'pg/float8@1'` now comes before `'pg/float@1'`, and a table whose name starts with a capital letter comes before one that starts with a lowercase letter. Most of the diff of a re-emitted `contract.d.ts` is lines that moved; the types are the same, and no hash changes.
530
+
531
+ Leave the copies of the contract kept beside each migration, under `migrations/snapshots/`, as they are. They keep working, and no command rewrites a snapshot that already exists; only a snapshot written from now on has the new form. Do not edit them or any `migration.ts` by hand. A match under `migrations/snapshots/` needs no change.
523
532
 
524
533
  ### `hand-assembled-config-names-generated-file-modules`
525
534
 
@@ -824,7 +833,7 @@ In a SQLite TypeScript contract, `type.Decimal()` and `type.DecimalString()` giv
824
833
 
825
834
  ### `sqlite-integer-safe-range`
826
835
 
827
- 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.
836
+ This applies to a SQLite schema or TypeScript contract. On PostgreSQL and MongoDB, `Int` does not change; skip this entry there. The detection matches a project that uses SQLite: a `package.json` that depends on `@prisma/orm-sqlite` or `@prisma/orm-target-sqlite`, or a `prisma.config.ts` that imports from one of them. In such a project, find the fields this entry covers: in a schema, every field, value object member and `types {}` alias written `Int`, `IntegerNumber`, `BigInt(as: number)` or `BigIntNumber`; in a TypeScript contract, `type.Int()`, `type.IntegerNumber()`, `type.BigInt({ as: 'number' })` and the column helpers `integerNumberColumn` (`integerColumn` before this release) and `sqliteIntegerColumn`.
828
837
 
829
838
  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:
830
839
 
@@ -1015,6 +1024,8 @@ Run `prisma contract emit` for every SQL contract. The emitted `capabilities.sql
1015
1024
 
1016
1025
  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.
1017
1026
 
1027
+ A match under `migrations/snapshots/` needs no change: every snapshot written before this release lacks the new keys, and the snapshots stay as they are.
1028
+
1018
1029
 
1019
1030
  ## MySQL and MariaDB: scalars get convenience types, and the ORM's aggregates run
1020
1031
 
@@ -1216,6 +1227,22 @@ await tx.orm.public.Post.create({ title, author: (author) => author.create(user)
1216
1227
  await tx.execute(plan);
1217
1228
  ```
1218
1229
 
1230
+ Left in `Promise.all`, the whole transaction fails. The other work rejects with `RUNTIME.TRANSACTION_SUSPENDED`, which makes the callback throw while the write still runs. The transaction cannot be rolled back while the write holds its savepoint, so it rejects with `RUNTIME.TRANSACTION_ROLLBACK_FAILED`, whose `cause` is that `RUNTIME.TRANSACTION_SUSPENDED` error, and the connection is closed instead of given back to the pool. Nothing the transaction wrote is kept.
1231
+
1232
+ Which writes take more than one statement, and so run in a savepoint:
1233
+
1234
+ - On PostgreSQL and SQLite, these take more than one statement:
1235
+ - a write with `.include(...)`, `createAll()`, `updateAll()` and `deleteAll()` included, because the rows are read back with their includes;
1236
+ - a `create()` or `update()` whose data has a relation callback;
1237
+ - an `update()` or `delete()` whose `where` does not name one row by its primary key or a unique key, or that has an `offset` or a `cursor`, because the row is found with a `SELECT` first;
1238
+ - a write on a variant stored in its own table, such as `create()` (the base row and the variant row are two inserts) or `update()` and `delete()` even by primary key, and a write that returns rows of a polymorphic base model with such a variant, because the rows are read back with the variant's table;
1239
+ - on SQLite, a `createAll()` or `createAndCount()` whose rows do not all set the same fields, because SQLite sends one `INSERT` for each set of fields;
1240
+ - since 8.0.0-rc.24, an `updateAll()` or `deleteAll()` that returns rows of a collection with two or more filters, where each `where()`, `whereUnique()`, `variant()` and method from `using` adds one; before, each was one statement. For `updateAll()` the extra statement only adds the savepoint, and the rows it returns are the rows it updated. For `deleteAll()` the release notes list it under "Known problems", because the rows it returns can include a row it did not delete.
1241
+ - On PostgreSQL and SQLite, a write takes one statement and opens no savepoint only when nothing in the list above applies to it. Then `create()`, `upsert()`, `createAll()`, `createAndCount()`, `updateAll()` and `deleteAll()` with at most one filter, `update()` and `delete()` by primary key or unique key, `updateAndCount()` and `deleteAndCount()` are one statement. A read never opens a savepoint.
1242
+ - On MySQL and MariaDB, which have no `RETURNING`, every write that returns rows takes more than one statement, because the ORM reads the rows back with a `SELECT`: `create()`, `createAll()`, `upsert()`, `update()`, `updateAll()`, `delete()` and `deleteAll()`. Only `createAndCount()`, `updateAndCount()` and `deleteAndCount()` take one.
1243
+
1244
+ Treat a write as more than one statement unless the second item of this list covers it. A file the detection matches needs a change only where such a write runs in `Promise.all`, or otherwise at the same time, beside other work on the same `tx`. The detection does not find every such file. Check by hand a callback passed to `transaction` by name and defined in another file, a helper in another file that is given `tx`, and an array of writes built in one place and passed to `Promise.all` in another.
1245
+
1219
1246
  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`.
1220
1247
 
1221
1248
 
@@ -1446,6 +1473,8 @@ A value whose type is wider than the column's is also refused. For example, `fns
1446
1473
 
1447
1474
  To find rows that hold a value the column's type no longer lists, compare with a raw SQL operand, which keeps the codec's input type: ``fns.eq(fns.raw`kind`.returns('pg/text@1'), 'old_value')``.
1448
1475
 
1476
+ A match needs a change only where the type checker reports an error on the comparison. A comparison whose value already has the column's type needs none, and neither does an applied `migration.ts` that type-checks; its `ops.json` does not change.
1477
+
1449
1478
 
1450
1479
  ## Errors from MySQL's shared code carry no `meta.target`
1451
1480
 
@@ -1490,7 +1519,7 @@ In each matched file that reads the `--json` result of `prisma orm init`:
1490
1519
  | The run ends at the empty contract, for example `--to @empty`; connection from `prisma.config.ts`, neither flag | None; `db` is left unchanged, with a warning when it exists |
1491
1520
  | The run ends at the empty contract, `--advance-ref <name>` | Refused before anything is applied; before, the write failed after the apply |
1492
1521
 
1493
- Change the commands the project runs:
1522
+ Change the commands the project runs. A match in prose that mentions the command, and runs nothing, needs no change.
1494
1523
 
1495
1524
  - In a development command that reads the connection from the config, such as a `package.json` script or a README step, remove `--advance-ref db` from `db migrate`. Keep it where the command passes `--db` or runs in CI, because there `db migrate` advances nothing by default.
1496
1525
 
@@ -1510,7 +1539,7 @@ A ref that `db migrate` cannot write, for example on a read-only filesystem, is
1510
1539
 
1511
1540
  ### `engine-pin-moves-to-0-10-4`
1512
1541
 
1513
- 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. Projects assembled by the `prisma` CLI resolve the engine automatically.
1542
+ For every file matched by `detection`, change each `@prisma/cli-engine` version that is not exactly `0.10.4`, such as `0.10.3`, `^0.10.0`, `>=0.9.0 <0.11.0` or `^0.10.4`, to `0.10.4` and reinstall. The toolchain peers that exact version, so a range that allows any other version, newer ones included, can install an engine it refuses. Projects assembled by the `prisma` CLI resolve the engine automatically. A package that declares `@prisma/cli-engine` without any `@prisma/orm-*` package, such as a workspace root, keeps its pin only when no package of the workspace uses that pin with the ORM toolchain; when one does, change it too. The detection does not match such a `package.json` unless it also has an `overrides` or `resolutions` field, so check the workspace root by hand. An `overrides` or `resolutions` entry for `@prisma/cli-engine` at the top level, such as npm's `"@prisma/cli-engine": "0.9.0"` or `"@prisma/cli-engine": { ".": "0.9.0" }`, or Yarn's `"**/@prisma/cli-engine"`, pins the engine for every package of the workspace, so change it even in a root `package.json` that lists no `@prisma/orm-*` package. npm refuses an override of a package that the same `package.json` also depends on directly unless both are written the same, so write such a direct dependency the same as the override. An entry scoped under another package applies only there. npm's nested form, `"some-package": { "@prisma/cli-engine": "0.9.0" }`, applies to every copy of the engine below that package: change it when that package is an `@prisma/orm-*` package, such as `@prisma/orm-toolchain`, or depends on one, and leave it otherwise. pnpm's `"some-package>@prisma/cli-engine"` applies to that package's own dependency on the engine: change it when that package is an `@prisma/orm-*` package, and leave it otherwise. A `pnpm-workspace.yaml` matches whatever its packages are, so change its pin only when a package that takes the engine from it also lists an `@prisma/orm-*` package.
1514
1543
 
1515
1544
  ### `consent-required-summary-is-one-fixed-sentence`
1516
1545
 
@@ -4,12 +4,11 @@ to: "8.0.0-rc.24"
4
4
  changes:
5
5
  - id: engine-pin-moves-to-0-10-0
6
6
  summary: |
7
- The toolchain now peers `@prisma/cli-engine@0.10.0` (up from 0.9.0). An extension package that depends on `@prisma/cli-engine` for its tests or tooling must move to `0.10.0`.
7
+ The toolchain now peers `@prisma/cli-engine@0.10.0` (up from 0.9.0). An extension package that depends on `@prisma/cli-engine` for its tests or tooling must move to `0.10.0`. The detection matches every declaration of `@prisma/cli-engine` in a `pnpm-workspace.yaml`, and in a `package.json` that lists an `@prisma/orm-*` package or names the engine in `overrides` or `resolutions`, unless its value is the plain version `0.10.0`, the version the toolchain peers. An exact pin in npm's object form, `{ ".": "0.10.0" }`, is matched too and needs no change.
8
8
  detection:
9
9
  glob: "**/{package.json,pnpm-workspace.yaml}"
10
10
  matches:
11
- - '"@prisma/cli-engine":\s*"[^"]*(?<![\d.])0\.\d(?!\d)'
12
- - '[''"]?@prisma/cli-engine[''"]?:\s*[''"]?[\^~]?0\.\d(?![\d])'
11
+ - '(?<![\s\S])(?:(?=\s*\{)(?=[\s\S]*(?:"@prisma/orm-[a-z-]+"\s*:|"(?:overrides|resolutions)"\s*:[\s\S]*@prisma/cli-engine(?:@[^"\s]*)?"))|(?!\s*\{))[\s\S]*@prisma/cli-engine(?:@[^''"\s:]*)?[''"]?\s*:(?!\s*[''"]?0\.10\.0[''"]?\s*(?:[,}\r\n#]|$))'
13
12
  - id: mongo-fields-take-a-type
14
13
  summary: |
15
14
  The MongoDB TypeScript builder writes a field as `field.scalar(type.X())`, where `type` holds the type constructors the target and extension packs contribute, as PSL names them: `field.objectId()` is now `field.scalar(type.ObjectId())`, `field.date()` is `field.scalar(type.DateTime())` (on MongoDB `Date` is now a calendar date), `field.vector({ typeParams: { length: 3 } })` is `field.scalar(type.Vector(3))`, and `field.scalar('mongo/string@1')` is `field.scalar(type.String())`. `field.objectId()`, `field.string()`, `field.double()`, `field.int32()`, `field.bool()`, `field.date()`, `field.int64()`, `field.int64Number()`, `field.decimal128()`, `field.binary()`, `field.json()`, `field.bson()`, `field.vector()` and `field.scalar(codecId)` are removed. `type` comes from the `defineContract` callback, or from `@prisma/orm-mongo/contract-builder`. The MongoDB target now contributes these constructors in its descriptor's `authoring.type`, which the adapter contributed before; `Vector` is new. Run `scripts/mongo-type-helpers/rewrite-mongo-field-types.ts` to rewrite them. The contract does not change. The detection matches MongoDB contract sources that call a removed helper.
@@ -106,7 +105,7 @@ Make the changes below in any order, with three exceptions:
106
105
 
107
106
  ### `engine-pin-moves-to-0-10-0`
108
107
 
109
- For every file matched by `detection`, change the `@prisma/cli-engine` version (`0.9.0`, `^0.9.0` or any other 0.x below 0.10) to `0.10.0` and reinstall. In engine 0.10.0 a normalized redirect's `replacement` is a list of steps rather than one string, so code that reads `CommandRedirect.replacement` from a command family reads an array.
108
+ For every file matched by `detection`, change each `@prisma/cli-engine` version that is not exactly `0.10.0`, such as `0.9.0`, `^0.9.0`, `>=0.9.0 <0.10.0` or `^0.10.0`, to `0.10.0` and reinstall. The toolchain peers that exact version, so a range that allows any other version, newer ones included, can install an engine it refuses. A package that declares `@prisma/cli-engine` without any `@prisma/orm-*` package, such as a workspace root, keeps its pin only when no package of the workspace uses that pin with the ORM toolchain; when one does, change it too. The detection does not match such a `package.json` unless it also has an `overrides` or `resolutions` field, so check the workspace root by hand. An `overrides` or `resolutions` entry for `@prisma/cli-engine` at the top level, such as npm's `"@prisma/cli-engine": "0.9.0"` or `"@prisma/cli-engine": { ".": "0.9.0" }`, or Yarn's `"**/@prisma/cli-engine"`, pins the engine for every package of the workspace, so change it even in a root `package.json` that lists no `@prisma/orm-*` package. npm refuses an override of a package that the same `package.json` also depends on directly unless both are written the same, so write such a direct dependency the same as the override. An entry scoped under another package applies only there. npm's nested form, `"some-package": { "@prisma/cli-engine": "0.9.0" }`, applies to every copy of the engine below that package: change it when that package is an `@prisma/orm-*` package, such as `@prisma/orm-toolchain`, or depends on one, and leave it otherwise. pnpm's `"some-package>@prisma/cli-engine"` applies to that package's own dependency on the engine: change it when that package is an `@prisma/orm-*` package, and leave it otherwise. A `pnpm-workspace.yaml` matches whatever its packages are, so change its pin only when a package that takes the engine from it also lists an `@prisma/orm-*` package. In engine 0.10.0 a normalized redirect's `replacement` is a list of steps rather than one string, so code that reads `CommandRedirect.replacement` from a command family reads an array.
110
109
 
111
110
 
112
111
  ## MongoDB fields take a type from `type`
@@ -24,6 +24,15 @@ changes:
24
24
  matches:
25
25
  - '"temporal-polyfill"\s*:\s*"[\^~]?1\.0\.[0-7](?![\d])'
26
26
  - '[''"]?temporal-polyfill[''"]?:\s*[''"]?[\^~]?1\.0\.[0-7](?![\d])'
27
+ - id: arktype-and-bson-ranges-move
28
+ summary: |
29
+ The `@prisma/orm-*` packages now depend on `arktype` `^2.2.9` (up from `^2.2.2`), and `@prisma/orm-target-mongo` on `bson` `^7.3.4` (up from `^7.2.0`). An extension package that declares either itself in a range that allows an older version, or whose lockfile keeps one, can install two copies: its own and the one Prisma 8 uses. With two copies, an `instanceof` check against one copy's class, such as `instanceof type.errors`, does not recognise a value the other copy made and does not narrow its type, and TypeScript reports errors where the two copies' types meet. Move the declared range inside the new one and reinstall, so one copy is installed. The detection matches every declaration of either package, including the catalogs in `pnpm-workspace.yaml` and `.yarnrc.yml` and an `npm:` alias of either; the guide's section says how to tell from the value whether it needs a change, and to check in every case that one copy of each is installed.
30
+ detection:
31
+ glob: "**/{package.json,pnpm-workspace.yaml,.yarnrc.yml}"
32
+ matches:
33
+ - '(?:(?<=\*\*/)|(?<![\w@/.#-]))[''"]?(?:(?:@[\w.-]+/)?[\w-][\w.-]*/)?arktype(?:@[^''"\s:]*)?[''"]?\s*:'
34
+ - '(?:(?<=\*\*/)|(?<![\w@/.#-]))[''"]?(?:(?:@[\w.-]+/)?[\w-][\w.-]*/)?bson(?:@[^''"\s:]*)?[''"]?\s*:'
35
+ - '(?<![\w-])npm:(?:arktype|bson)(?:@|[''"]|\s|$)'
27
36
  - id: config-type-renamed-to-prisma-config
28
37
  summary: |
29
38
  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.
@@ -191,18 +200,11 @@ changes:
191
200
  - '\.\s*BigIntNumber\s*\('
192
201
  - id: sqlite-integer-safe-range
193
202
  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.
203
+ 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. The detection matches a package that depends on a SQLite package or whose config imports one.
195
204
  detection:
196
- glob: "**/*.{prisma,ts,mts,cts,tsx}"
205
+ glob: "**/{package.json,prisma.config.{ts,mts,cts,js,mjs}}"
197
206
  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$])'
207
+ - '[''"](?:@prisma/orm-(?:sqlite|target-sqlite)|@internal/(?:sqlite|target-sqlite|adapter-sqlite))(?:/[\w./-]*)?[''"]'
206
208
  - id: ts-renamed-sqlite-column-helpers
207
209
  summary: |
208
210
  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.
@@ -265,11 +267,11 @@ changes:
265
267
  - '(?<![\w$])ActivityRoute(?![\w$])'
266
268
  - id: orm-write-inside-transaction-suspends-tx
267
269
  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`.
270
+ 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`. In `Promise.all`, that rejection makes the callback throw while the write still runs, so the transaction rejects with `RUNTIME.TRANSACTION_ROLLBACK_FAILED`, whose `cause` is the `RUNTIME.TRANSACTION_SUSPENDED` error, keeps nothing the transaction wrote, and closes the connection. When such a write fails with an error that ends the whole transaction, such as a deadlock on MySQL or MariaDB, the write itself rejects with `RUNTIME.TRANSACTION_ROLLBACK_FAILED`, whose `cause` is the database's error, and the transaction is closed. On PostgreSQL and SQLite many writes are one statement and open no savepoint; on MySQL and MariaDB every write that returns rows opens one. The detection matches TypeScript sources that call `transaction` and `Promise.all` or `Promise.allSettled`.
269
271
  detection:
270
272
  glob: "**/*.{ts,mts,cts,tsx}"
271
273
  matches:
272
- - '(?<![\s\S])(?=[\s\S]*\.transaction\s*\()[\s\S]*Promise\.all'
274
+ - '(?<![\s\S])(?=[\s\S]*\.transaction\s*\()[\s\S]*Promise\.all(?:Settled)?\s*\('
273
275
  - id: sql-runtime-base-own-transaction-removed
274
276
  summary: |
275
277
  `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`.
@@ -420,12 +422,11 @@ changes:
420
422
  - '(?<![\w$])(?:keepDataEdit|keepData|swapsValues)(?![\w$])'
421
423
  - id: engine-pin-moves-to-0-10-4
422
424
  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`.
425
+ 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`. The detection matches every declaration of `@prisma/cli-engine` in a `pnpm-workspace.yaml`, and in a `package.json` that lists an `@prisma/orm-*` package or names the engine in `overrides` or `resolutions`, unless its value is the plain version `0.10.4`, the version the toolchain peers. An exact pin in npm's object form, `{ ".": "0.10.4" }`, is matched too and needs no change.
424
426
  detection:
425
427
  glob: "**/{package.json,pnpm-workspace.yaml}"
426
428
  matches:
427
- - '"@prisma/cli-engine":\s*"[^"]*(?<![\d.])0\.(?:\d|10\.[0123xX*])(?!\d)'
428
- - '[''"]?@prisma/cli-engine[''"]?:\s*[''"]?(?:[\^~]|[<>]=?\s*)?0\.(?:\d|10\.[0123xX*])(?!\d)'
429
+ - '(?<![\s\S])(?:(?=\s*\{)(?=[\s\S]*(?:"@prisma/orm-[a-z-]+"\s*:|"(?:overrides|resolutions)"\s*:[\s\S]*@prisma/cli-engine(?:@[^"\s]*)?"))|(?!\s*\{))[\s\S]*@prisma/cli-engine(?:@[^''"\s:]*)?[''"]?\s*:(?!\s*[''"]?0\.10\.4[''"]?\s*(?:[,}\r\n#]|$))'
429
430
  - id: consent-required-summary-is-one-fixed-sentence
430
431
  summary: |
431
432
  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.
@@ -449,7 +450,7 @@ The examples write the ORM client as `db.orm.public.<Model>`, which is the Postg
449
450
 
450
451
  Make the changes below in any order, with three exceptions:
451
452
 
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
+ 1. Add `pg` and `@types/pg` where they are needed, move a declared `temporal-polyfill` to `^1.0.8`, a declared `arktype` to `^2.2.9` and a declared `bson` to `^7.3.4`, 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`, `arktype-and-bson-ranges-move`, `engine-pin-moves-to-0-10-4`).
453
454
  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
455
  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
 
@@ -468,6 +469,12 @@ For each published extension package whose source files `detection` matches, mov
468
469
 
469
470
  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
 
472
+ ### `arktype-and-bson-ranges-move`
473
+
474
+ `arktype` and `bson` are dependencies of the Prisma 8 packages, not peers, so the package manager installs the version Prisma 8 asks for beside the package's own when the package's range or lockfile keeps an older one. An extension that pins `arktype` at `2.2.3`, for example, then has two copies, and code such as `if (result instanceof type.errors)` on a value from the other copy no longer narrows `result`. On MongoDB the same holds for `bson` classes such as `ObjectId`.
475
+
476
+ The detection matches every declaration of `arktype` or `bson`: in a manifest, a catalog (`pnpm-workspace.yaml`, `.yarnrc.yml` or a Bun catalog in `package.json`), an override or a resolution. Read each value. A declaration needs a change unless every version it allows is inside `^2.2.9` (at least 2.2.9 and below 3) for `arktype`, or inside `^7.3.4` (at least 7.3.4 and below 8) for `bson`. So `^2.2.9`, `^2.2.10` or `~2.2.9` stays, and `2.2.3`, `^1.0.0`, `<3`, `*` or `>=7.3.4`, which allows `bson` 8, changes. Change such a declaration to `^2.2.9` for `arktype` and `^7.3.4` for `bson`, then reinstall. A `catalog:` or `workspace:` reference takes its range from the entry it points to, so judge and change that entry instead. An alias such as `"schema": "npm:arktype@2.2.3"` is matched too. It installs the package under another name, which is a separate copy from the one Prisma 8 loads whatever its range, so where its values meet Prisma 8's, declare the package under its own name instead. An override or resolution scoped under another package applies only there, so judge it by that package. npm's nested form, such as `"some-package": { "arktype": "^1.0.0" }`, applies to every copy below that package: change it when that package is an `@prisma/orm-*` package or depends on one, and leave it otherwise. pnpm's `"some-package>arktype"` applies to that package's own dependency: change it when that package is an `@prisma/orm-*` package, and leave it otherwise. A published extension that declares `arktype` or `bson` under `dependencies` or `peerDependencies` gets the same range there, so an application that installs it gets one copy. Then, for every declaration, changed or not, check that the install holds one copy of each package, for example with `pnpm why arktype`, `npm ls arktype` or `yarn why arktype`, which list each installed copy. Count copies, not the paths that lead to them. A copy kept on purpose under an override scoped to another package, or under an alias, does not count: the check is for the copy that Prisma 8, and the code that passes values to it, load. In a workspace, run the check in every package that declares either one, or once with `pnpm why -r arktype` on pnpm. A range inside the new one can still resolve to a different version from the one Prisma 8 uses, for example when the lockfile keeps an older entry. If more than one copy is listed, even of the same version, write the declaration as the range the Prisma 8 packages use, `^2.2.9` or `^7.3.4`, reinstall and check again, until one copy is listed. A package that does not declare either itself needs no change.
477
+
471
478
  ### `config-type-renamed-to-prisma-config`
472
479
 
473
480
  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.
@@ -973,7 +980,7 @@ model Post {
973
980
 
974
981
  ### `sqlite-integer-safe-range`
975
982
 
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.
983
+ This applies to a SQLite schema or TypeScript contract. On PostgreSQL and MongoDB, `Int` does not change; skip this entry there. The detection matches a package that uses SQLite: a `package.json` that depends on `@prisma/orm-sqlite` or `@prisma/orm-target-sqlite`, or a `prisma.config.ts` that imports from one of them. In such a package, find the fields this entry covers: in a schema, every field, value object member and `types {}` alias written `Int`, `IntegerNumber`, `BigInt(as: number)` or `BigIntNumber`; in a TypeScript contract, `type.Int()`, `type.IntegerNumber()`, `type.BigInt({ as: 'number' })` and the column helpers `integerNumberColumn` (`integerColumn` before this release) and `sqliteIntegerColumn`.
977
984
 
978
985
  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
986
 
@@ -1065,6 +1072,10 @@ Run `prisma contract emit` for every SQL contract. The emitted `capabilities.sql
1065
1072
 
1066
1073
  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
1074
 
1075
+ A match under `migrations/snapshots/` needs no change: every snapshot written before this release lacks the new keys, and the snapshots stay as they are.
1076
+
1077
+ A `contract.d.ts` that `prisma contract emit` writes for a PostgreSQL, SQLite, MySQL or MariaDB contract, such as a pack's contract or an example's, now lists the aggregate operations, the codec ids under each of them in `AggregateTypes`, the value sets, the tables and the namespaces in byte order, where earlier releases sorted them in the locale's order. So `'pg/float8@1'` now comes before `'pg/float@1'`, and a table whose name starts with a capital letter comes before one that starts with a lowercase letter. Most of the diff of a re-emitted `contract.d.ts` is lines that moved; the types are the same, and no hash changes.
1078
+
1068
1079
  ### `mysql-reemit-contract`
1069
1080
 
1070
1081
  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.
@@ -1143,6 +1154,22 @@ await tx.orm.public.Post.create({ title, author: (author) => author.create(user)
1143
1154
  await tx.execute(plan);
1144
1155
  ```
1145
1156
 
1157
+ Left in `Promise.all`, the whole transaction fails. The other work rejects with `RUNTIME.TRANSACTION_SUSPENDED`, which makes the callback throw while the write still runs. The transaction cannot be rolled back while the write holds its savepoint, so it rejects with `RUNTIME.TRANSACTION_ROLLBACK_FAILED`, whose `cause` is that `RUNTIME.TRANSACTION_SUSPENDED` error, and the connection is closed instead of given back to the pool. Nothing the transaction wrote is kept.
1158
+
1159
+ Which writes take more than one statement, and so run in a savepoint:
1160
+
1161
+ - On PostgreSQL and SQLite, these take more than one statement:
1162
+ - a write with `.include(...)`, `createAll()`, `updateAll()` and `deleteAll()` included, because the rows are read back with their includes;
1163
+ - a `create()` or `update()` whose data has a relation callback;
1164
+ - an `update()` or `delete()` whose `where` does not name one row by its primary key or a unique key, or that has an `offset` or a `cursor`, because the row is found with a `SELECT` first;
1165
+ - a write on a variant stored in its own table, such as `create()` (the base row and the variant row are two inserts) or `update()` and `delete()` even by primary key, and a write that returns rows of a polymorphic base model with such a variant, because the rows are read back with the variant's table;
1166
+ - on SQLite, a `createAll()` or `createAndCount()` whose rows do not all set the same fields, because SQLite sends one `INSERT` for each set of fields;
1167
+ - since 8.0.0-rc.24, an `updateAll()` or `deleteAll()` that returns rows of a collection with two or more filters, where each `where()`, `whereUnique()`, `variant()` and method from `using` adds one; before, each was one statement. For `updateAll()` the extra statement only adds the savepoint, and the rows it returns are the rows it updated. For `deleteAll()` the release notes list it under "Known problems", because the rows it returns can include a row it did not delete.
1168
+ - On PostgreSQL and SQLite, a write takes one statement and opens no savepoint only when nothing in the list above applies to it. Then `create()`, `upsert()`, `createAll()`, `createAndCount()`, `updateAll()` and `deleteAll()` with at most one filter, `update()` and `delete()` by primary key or unique key, `updateAndCount()` and `deleteAndCount()` are one statement. A read never opens a savepoint.
1169
+ - On MySQL and MariaDB, which have no `RETURNING`, every write that returns rows takes more than one statement, because the ORM reads the rows back with a `SELECT`: `create()`, `createAll()`, `upsert()`, `update()`, `updateAll()`, `delete()` and `deleteAll()`. Only `createAndCount()`, `updateAndCount()` and `deleteAndCount()` take one.
1170
+
1171
+ Treat a write as more than one statement unless the second item of this list covers it. A file the detection matches needs a change only where such a write runs in `Promise.all`, or otherwise at the same time, beside other work on the same transaction. The detection does not find every such file. Check by hand a callback passed to `transaction` by name and defined in another file, a helper in another file that is given the transaction, and an array of writes built in one place and passed to `Promise.all` in another.
1172
+
1146
1173
  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
1174
 
1148
1175
  ### `sql-runtime-base-own-transaction-removed`
@@ -1544,7 +1571,7 @@ Remove reads of `keepDataEdit`, `keepData` and `swapsValues`. `keepRowsEdit` is
1544
1571
 
1545
1572
  ### `engine-pin-moves-to-0-10-4`
1546
1573
 
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.
1574
+ For every file matched by `detection`, change each `@prisma/cli-engine` version that is not exactly `0.10.4`, such as `0.10.3`, `^0.10.0`, `>=0.9.0 <0.11.0` or `^0.10.4`, to `0.10.4` and reinstall. The toolchain peers that exact version, so a range that allows any other version, newer ones included, can install an engine it refuses. A package that declares `@prisma/cli-engine` without any `@prisma/orm-*` package, such as a workspace root, keeps its pin only when no package of the workspace uses that pin with the ORM toolchain; when one does, change it too. The detection does not match such a `package.json` unless it also has an `overrides` or `resolutions` field, so check the workspace root by hand. An `overrides` or `resolutions` entry for `@prisma/cli-engine` at the top level, such as npm's `"@prisma/cli-engine": "0.9.0"` or `"@prisma/cli-engine": { ".": "0.9.0" }`, or Yarn's `"**/@prisma/cli-engine"`, pins the engine for every package of the workspace, so change it even in a root `package.json` that lists no `@prisma/orm-*` package. npm refuses an override of a package that the same `package.json` also depends on directly unless both are written the same, so write such a direct dependency the same as the override. An entry scoped under another package applies only there. npm's nested form, `"some-package": { "@prisma/cli-engine": "0.9.0" }`, applies to every copy of the engine below that package: change it when that package is an `@prisma/orm-*` package, such as `@prisma/orm-toolchain`, or depends on one, and leave it otherwise. pnpm's `"some-package>@prisma/cli-engine"` applies to that package's own dependency on the engine: change it when that package is an `@prisma/orm-*` package, and leave it otherwise. A `pnpm-workspace.yaml` matches whatever its packages are, so change its pin only when a package that takes the engine from it also lists an `@prisma/orm-*` package.
1548
1575
 
1549
1576
  ### `consent-required-summary-is-one-fixed-sentence`
1550
1577