@prisma/orm-mongo 8.0.0-rc.25-dev.28 → 8.0.0-rc.26

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.
Files changed (210) hide show
  1. package/README.md +6 -5
  2. package/dist/bson.d.mts +2 -1
  3. package/dist/components__runtime.d.mts +3 -1
  4. package/dist/config.d.mts +2 -1
  5. package/dist/config.d.mts.map +1 -1
  6. package/dist/contract-builder.d.mts +11 -12
  7. package/dist/contract-builder.d.mts.map +1 -1
  8. package/dist/contract-types.d.mts +5 -3
  9. package/dist/contract__types.d.mts +3 -1
  10. package/dist/control.d.mts +2 -1
  11. package/dist/control.d.mts.map +1 -1
  12. package/dist/family-contract.d.mts +3 -1
  13. package/dist/family-runtime.d.mts +3 -1
  14. package/dist/family.d.mts +2 -1
  15. package/dist/family__control.d.mts +3 -1
  16. package/dist/init-quick-reference.md +1 -1
  17. package/dist/init.d.mts +2 -1
  18. package/dist/init.d.mts.map +1 -1
  19. package/dist/migration-tools__aggregate.d.mts +3 -1
  20. package/dist/migration-tools__hash.d.mts +3 -1
  21. package/dist/migration-tools__io.d.mts +3 -1
  22. package/dist/migration-tools__spaces.d.mts +3 -1
  23. package/dist/migration.d.mts +3 -1
  24. package/dist/{mongo-static-DVyRmsYP-yCJ9Q75S.mjs → mongo-static-DnxWWp96-D-vo6-SA.mjs} +4 -4
  25. package/dist/mongo-static-DnxWWp96-D-vo6-SA.mjs.map +1 -0
  26. package/dist/orm.d.mts +3 -1
  27. package/dist/query-ast__execution.d.mts +3 -1
  28. package/dist/query-builder.d.mts +3 -1
  29. package/dist/runtime.d.mts +3 -1
  30. package/dist/runtime.d.mts.map +1 -1
  31. package/dist/runtime.mjs +6 -6
  32. package/dist/runtime.mjs.map +1 -1
  33. package/dist/static.d.mts +2 -1
  34. package/dist/static.d.mts.map +1 -1
  35. package/dist/static.mjs +1 -1
  36. package/dist/target.d.mts +2 -1
  37. package/dist/target__codec-ids.d.mts +3 -1
  38. package/dist/target__codec-types.d.mts +3 -1
  39. package/dist/target__migration.d.mts +3 -1
  40. package/dist/target__runtime.d.mts +2 -1
  41. package/dist/value.d.mts +3 -1
  42. package/dist/vite-plugin-contract-emit.d.mts +3 -1
  43. package/package.json +12 -81
  44. package/skills/prisma-8/SKILL.md +8 -8
  45. package/skills/prisma-8/references/contract.md +8 -8
  46. package/skills/prisma-8/references/debug.md +11 -11
  47. package/skills/prisma-8/references/migration-model.md +17 -17
  48. package/skills/prisma-8/references/migration-review.md +21 -21
  49. package/skills/prisma-8/references/migrations.md +58 -42
  50. package/skills/prisma-8/references/queries-postgres.md +51 -8
  51. package/skills/prisma-8/references/queries.md +2 -2
  52. package/skills/prisma-8/references/quickstart.md +11 -11
  53. package/skills/prisma-8/references/runtime.md +3 -3
  54. package/skills/prisma-8/references/supabase.md +2 -2
  55. package/skills/prisma-8/references/upgrade-app.md +56 -23
  56. package/skills/prisma-8/references/upgrade-extension.md +35 -14
  57. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/instructions.md +2385 -0
  58. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/contract-hash-inputs/contract-hash-inputs.ts +2048 -0
  59. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/contract-signature-names/contract-signature-names.ts +667 -0
  60. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/facade-paths-an-application-uses/facade-paths-an-application-uses.ts +667 -0
  61. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/platform-paths-an-extension-uses/platform-paths-an-extension-uses.ts +1996 -0
  62. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/stored-files-format-version/stored-files-format-version.ts +586 -0
  63. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/instructions.md +1 -1
  64. package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/instructions.md +1 -1
  65. package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/instructions.md +1 -1
  66. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/instructions.md +2043 -0
  67. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/contract-hash-inputs/contract-hash-inputs.ts +2048 -0
  68. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/contract-signature-names/contract-signature-names.ts +667 -0
  69. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/facade-paths-an-application-uses/facade-paths-an-application-uses.ts +667 -0
  70. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/platform-paths-an-extension-uses/platform-paths-an-extension-uses.ts +1996 -0
  71. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/stored-files-format-version/stored-files-format-version.ts +586 -0
  72. package/dist/adapter.d.mts +0 -1
  73. package/dist/adapter.mjs +0 -2
  74. package/dist/adapter__control.d.mts +0 -3
  75. package/dist/adapter__control.mjs +0 -3
  76. package/dist/adapter__runtime.d.mts +0 -3
  77. package/dist/adapter__runtime.mjs +0 -3
  78. package/dist/components.d.mts +0 -1
  79. package/dist/components.mjs +0 -2
  80. package/dist/components__authoring.d.mts +0 -1
  81. package/dist/components__authoring.mjs +0 -2
  82. package/dist/components__codec.d.mts +0 -1
  83. package/dist/components__codec.mjs +0 -2
  84. package/dist/components__components.d.mts +0 -1
  85. package/dist/components__components.mjs +0 -2
  86. package/dist/components__control.d.mts +0 -1
  87. package/dist/components__control.mjs +0 -2
  88. package/dist/components__emission.d.mts +0 -1
  89. package/dist/components__emission.mjs +0 -2
  90. package/dist/components__execution.d.mts +0 -1
  91. package/dist/components__execution.mjs +0 -2
  92. package/dist/components__ir.d.mts +0 -1
  93. package/dist/components__ir.mjs +0 -2
  94. package/dist/components__psl-ast.d.mts +0 -1
  95. package/dist/components__psl-ast.mjs +0 -2
  96. package/dist/components__utils.d.mts +0 -1
  97. package/dist/components__utils.mjs +0 -2
  98. package/dist/contract.d.mts +0 -1
  99. package/dist/contract.mjs +0 -2
  100. package/dist/contract__apply-specifier-default-control-policy.d.mts +0 -1
  101. package/dist/contract__apply-specifier-default-control-policy.mjs +0 -2
  102. package/dist/contract__contract-validation-error.d.mts +0 -1
  103. package/dist/contract__contract-validation-error.mjs +0 -2
  104. package/dist/contract__default-namespace.d.mts +0 -1
  105. package/dist/contract__default-namespace.mjs +0 -2
  106. package/dist/contract__enum-accessor.d.mts +0 -1
  107. package/dist/contract__enum-accessor.mjs +0 -2
  108. package/dist/contract__format-version.d.mts +0 -1
  109. package/dist/contract__format-version.mjs +0 -2
  110. package/dist/contract__hashing-utils.d.mts +0 -1
  111. package/dist/contract__hashing-utils.mjs +0 -2
  112. package/dist/contract__hashing.d.mts +0 -1
  113. package/dist/contract__hashing.mjs +0 -2
  114. package/dist/contract__internal__format-version.d.mts +0 -1
  115. package/dist/contract__internal__format-version.mjs +0 -2
  116. package/dist/contract__is-plain-record.d.mts +0 -1
  117. package/dist/contract__is-plain-record.mjs +0 -2
  118. package/dist/contract__resolve-domain-model.d.mts +0 -1
  119. package/dist/contract__resolve-domain-model.mjs +0 -2
  120. package/dist/contract__validate-domain.d.mts +0 -1
  121. package/dist/contract__validate-domain.mjs +0 -2
  122. package/dist/contract__validate-once.d.mts +0 -1
  123. package/dist/contract__validate-once.mjs +0 -2
  124. package/dist/contract__validate-storage.d.mts +0 -1
  125. package/dist/contract__validate-storage.mjs +0 -2
  126. package/dist/driver.d.mts +0 -1
  127. package/dist/driver.mjs +0 -2
  128. package/dist/driver__control.d.mts +0 -3
  129. package/dist/driver__control.mjs +0 -3
  130. package/dist/driver__runtime.d.mts +0 -3
  131. package/dist/driver__runtime.mjs +0 -3
  132. package/dist/family-contract__canonicalization-hooks.d.mts +0 -1
  133. package/dist/family-contract__canonicalization-hooks.mjs +0 -2
  134. package/dist/family-contract__data-type.d.mts +0 -1
  135. package/dist/family-contract__data-type.mjs +0 -2
  136. package/dist/family-contract__entity-kinds.d.mts +0 -1
  137. package/dist/family-contract__entity-kinds.mjs +0 -2
  138. package/dist/family__control-adapter.d.mts +0 -1
  139. package/dist/family__control-adapter.mjs +0 -2
  140. package/dist/family__ir.d.mts +0 -1
  141. package/dist/family__ir.mjs +0 -2
  142. package/dist/family__migration.d.mts +0 -1
  143. package/dist/family__migration.mjs +0 -2
  144. package/dist/family__pack.d.mts +0 -3
  145. package/dist/family__pack.mjs +0 -3
  146. package/dist/family__runtime.d.mts +0 -1
  147. package/dist/family__runtime.mjs +0 -2
  148. package/dist/family__schema-verify.d.mts +0 -1
  149. package/dist/family__schema-verify.mjs +0 -2
  150. package/dist/migration-tools__contract-snapshot-store.d.mts +0 -1
  151. package/dist/migration-tools__contract-snapshot-store.mjs +0 -2
  152. package/dist/mongo-static-DVyRmsYP-yCJ9Q75S.mjs.map +0 -1
  153. package/dist/query-ast.d.mts +0 -1
  154. package/dist/query-ast.mjs +0 -2
  155. package/dist/query-ast__control.d.mts +0 -1
  156. package/dist/query-ast__control.mjs +0 -2
  157. package/dist/query-builder__contract-free.d.mts +0 -1
  158. package/dist/query-builder__contract-free.mjs +0 -2
  159. package/dist/target__codecs.d.mts +0 -1
  160. package/dist/target__codecs.mjs +0 -2
  161. package/dist/target__control.d.mts +0 -1
  162. package/dist/target__control.mjs +0 -2
  163. package/dist/target__data-types.d.mts +0 -1
  164. package/dist/target__data-types.mjs +0 -2
  165. package/dist/target__pack.d.mts +0 -3
  166. package/dist/target__pack.mjs +0 -3
  167. package/dist/target__server-version.d.mts +0 -1
  168. package/dist/target__server-version.mjs +0 -2
  169. package/dist/utils.d.mts +0 -1
  170. package/dist/utils.mjs +0 -2
  171. package/dist/utils__abortable.d.mts +0 -1
  172. package/dist/utils__abortable.mjs +0 -2
  173. package/dist/utils__array-equal.d.mts +0 -1
  174. package/dist/utils__array-equal.mjs +0 -2
  175. package/dist/utils__assertions.d.mts +0 -1
  176. package/dist/utils__assertions.mjs +0 -2
  177. package/dist/utils__canonical-stringify.d.mts +0 -1
  178. package/dist/utils__canonical-stringify.mjs +0 -2
  179. package/dist/utils__casts.d.mts +0 -1
  180. package/dist/utils__casts.mjs +0 -2
  181. package/dist/utils__defined.d.mts +0 -1
  182. package/dist/utils__defined.mjs +0 -2
  183. package/dist/utils__guards.d.mts +0 -1
  184. package/dist/utils__guards.mjs +0 -2
  185. package/dist/utils__hash-content.d.mts +0 -1
  186. package/dist/utils__hash-content.mjs +0 -2
  187. package/dist/utils__internal-error.d.mts +0 -1
  188. package/dist/utils__internal-error.mjs +0 -2
  189. package/dist/utils__json.d.mts +0 -1
  190. package/dist/utils__json.mjs +0 -2
  191. package/dist/utils__promise.d.mts +0 -1
  192. package/dist/utils__promise.mjs +0 -2
  193. package/dist/utils__redact-db-url.d.mts +0 -1
  194. package/dist/utils__redact-db-url.mjs +0 -2
  195. package/dist/utils__result.d.mts +0 -1
  196. package/dist/utils__result.mjs +0 -2
  197. package/dist/utils__simplify-deep.d.mts +0 -1
  198. package/dist/utils__simplify-deep.mjs +0 -2
  199. package/dist/utils__structured-error.d.mts +0 -1
  200. package/dist/utils__structured-error.mjs +0 -2
  201. package/dist/utils__suppress-idle-connection-errors.d.mts +0 -1
  202. package/dist/utils__suppress-idle-connection-errors.mjs +0 -2
  203. package/dist/utils__text.d.mts +0 -1
  204. package/dist/utils__text.mjs +0 -2
  205. package/dist/utils__types.d.mts +0 -1
  206. package/dist/utils__types.mjs +0 -2
  207. package/dist/utils__upgrade-guides.d.mts +0 -1
  208. package/dist/utils__upgrade-guides.mjs +0 -2
  209. package/dist/value__mongodb-types.d.mts +0 -1
  210. package/dist/value__mongodb-types.mjs +0 -2
@@ -0,0 +1,2043 @@
1
+ ---
2
+ from: "8.0.0-rc.25"
3
+ to: "8.0.0-rc.26"
4
+ changes:
5
+ - id: prisma-packages-are-peer-dependencies
6
+ summary: |
7
+ Every `@prisma/orm-*` package an extension's shipped code uses, another extension published from the Prisma repository included, is now a peer dependency, never an ordinary dependency. Move each such entry from `dependencies` (and `optionalDependencies`) to `peerDependencies`, and list it under `devDependencies` too, all at the same exact version.
8
+ detection:
9
+ glob: "**/package.json"
10
+ matches:
11
+ - '"(?:dependencies|optionalDependencies)"\s*:\s*\{[^}]*"@prisma/orm-'
12
+ - id: facade-paths-an-application-uses
13
+ summary: |
14
+ The database packages (`@prisma/orm-postgres`, `@prisma/orm-sqlite`, `@prisma/orm-mysql`, `@prisma/orm-mariadb` and `@prisma/orm-mongo`) now publish only the paths an application, a generated file or the documentation imports. The paths they forwarded from the platform packages and no application needs are removed: every `utils` and `driver` path, every `relational-core` path but `relational-core/ast`, the `control` path of the adapter, driver and target, and most of the `adapter`, `target`, `components`, `contract`, `family-contract` and `family` paths. Each removed module is still published by a platform package, under that package's own name. An extension builds on the platform packages: run this guide's colocated script, which changes each such import to the platform package's path, then list each platform package the extension now imports as a peer dependency.
15
+ detection:
16
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx}"
17
+ matches:
18
+ - "['\"`]@prisma/orm-(postgres|sqlite|mysql|mariadb|mongo)/(utils|driver)(/[A-Za-z0-9_./-]*)?['\"`]"
19
+ - "['\"`]@prisma/orm-(postgres|sqlite|mysql|mariadb|mongo)/(adapter|builder|components|contract|relational-core|query-ast)['\"`]"
20
+ - "['\"`]@prisma/orm-(postgres|sqlite|mysql|mariadb)/family-contract['\"`]"
21
+ - "['\"`]@prisma/orm-(postgres|sqlite|mysql|mariadb|mongo)/(builder/(?!runtime['\"`]|types['\"`])|components/(?!runtime['\"`])|contract/(?!types['\"`])|family-contract/(?!types['\"`])|family/(?!control['\"`])|relational-core/(?!ast['\"`])|migration-tools/(?!aggregate['\"`]|hash['\"`]|io['\"`]|spaces['\"`])|query-ast/(?!execution['\"`])|query-builder/|schema-ir/|value/)"
22
+ - "['\"`]@prisma/orm-postgres/adapter/(?!column-types['\"`])"
23
+ - "['\"`]@prisma/orm-sqlite/adapter/(?!codec-types['\"`]|column-types['\"`])"
24
+ - "['\"`]@prisma/orm-(mysql|mariadb)/adapter/(?!codec-types['\"`])"
25
+ - "['\"`]@prisma/orm-mongo/adapter/"
26
+ - "['\"`]@prisma/orm-postgres/target/(?!codec-ids['\"`]|codec-types['\"`]|full-text['\"`]|migration['\"`]|operation-types['\"`]|planner-target-details['\"`]|runtime['\"`])"
27
+ - "['\"`]@prisma/orm-sqlite/target/(?!codec-ids['\"`]|codec-types['\"`]|migration['\"`]|planner-target-details['\"`]|runtime['\"`])"
28
+ - "['\"`]@prisma/orm-(mysql|mongo)/target/(?!codec-ids['\"`]|codec-types['\"`]|migration['\"`]|runtime['\"`])"
29
+ - "['\"`]@prisma/orm-mariadb/target/(?!migration['\"`]|runtime['\"`])"
30
+ script: ./scripts/facade-paths-an-application-uses/facade-paths-an-application-uses.ts
31
+ - id: platform-paths-an-extension-uses
32
+ summary: |
33
+ The platform packages (`@prisma/orm-framework`, `@prisma/orm-family-sql`, `@prisma/orm-target-postgres` and `@prisma/orm-toolchain`) no longer publish 57 of the paths release 8.0.0-rc.25 published, the ones nothing outside their own package imported, among them the package-level paths `@prisma/orm-target-postgres/target` and `/adapter`, `@prisma/orm-framework/utils` and `@prisma/orm-family-sql/family`. `@prisma/orm-family-sql/contract` and `@prisma/orm-toolchain/migration-tools` stay, with fewer names. `@prisma/orm-framework/utils/internal-error` is now `utils/invariant-error`, and the exported names that contained "internal" have new names: `InternalError` is `InvariantError`, `isInternalError` is `isInvariantError`, `PreparedStatementInternals` is `LoweredPreparedStatement`, `SqlParamRefMutatorInternal` is `SqlRuntimeParamRefMutator`, `MongoParamRefMutatorInternal` is `MongoRuntimeParamRefMutator`, `SupabaseInternalDb` is `SupabaseSchemasDb`, and `SupabaseExtensionContract` is `SupabaseSchemasContract`. Most names of the removed paths are no longer published anywhere. Run the `facade-paths-an-application-uses` script first, then this guide's colocated script, which sends each import whose names a kept path still exports to that path, renames the old names where they came from a Prisma import, and lists what it could not change. Then rewrite what it lists, as the guide says.
34
+ detection:
35
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx}"
36
+ matches:
37
+ - "['\"`]@prisma/orm-framework/(?:contract/resolve-domain-model|psl-parser/tokenizer|target-package-config|type-implementations|utils|utils/internal-error)['\"`]"
38
+ - "['\"`]@prisma/orm-family-sql/(?:builder|contract-emitter|contract-psl|contract-psl/attribute-specs|contract-psl/default-table-name|contract-psl/diagnostics|contract-ts|contract/authored-check-naming|contract/factories|contract/index-type-validation|contract/validators|family|relational-core/functions|relational-core/middleware|schema-ir)['\"`]"
39
+ - "['\"`]@prisma/orm-target-postgres/(?:adapter|adapter/sql-renderer|adapter/types|target|target/aggregates|target/contract-free|target/data-transform|target/ddl|target/default-normalizer|target/diff-database-schema|target/errors|target/issue-planner|target/marker-lock|target/native-type-normalizer|target/op-factory-call|target/planner|target/planner-ddl-builders|target/planner-identity-values|target/planner-produced-postgres-migration|target/planner-schema-lookup|target/planner-sql-checks|target/render-ops|target/render-typescript|target/schema-ir-annotations)['\"`]"
40
+ - "['\"`]@prisma/orm-toolchain/(?:cli-telemetry|cli-telemetry/sender|cli/control-api/testing|cli/init-output|emitter|emitter/type-expression-safety|migration-tools/constants|migration-tools/contract-snapshot-store|migration-tools/errors|migration-tools/graph|migration-tools/metadata|migration-tools/migration-graph|migration-tools/ref-resolution)['\"`]"
41
+ - "(?<![\\w$])(?:InternalError|isInternalError|PreparedStatementInternals|SqlParamRefMutatorInternal|MongoParamRefMutatorInternal|SupabaseInternalDb|SupabaseExtensionContract|isPrismaInternalError)(?![\\w$])"
42
+ - "\\.name\\s*[!=]==?\\s*['\"`]InternalError['\"`]"
43
+ - "case\\s*['\"`]InternalError['\"`]"
44
+ - "['\"`]@prisma/orm-(?:family-sql/contract|toolchain/migration-tools)['\"`]"
45
+ script: ./scripts/platform-paths-an-extension-uses/platform-paths-an-extension-uses.ts
46
+ - id: contract-types-exports-types-only
47
+ summary: |
48
+ The `contract-types` entry of `@prisma/orm-postgres`, `@prisma/orm-sqlite`, `@prisma/orm-mysql`, `@prisma/orm-mariadb` and `@prisma/orm-mongo` now declares types only, as it always exported at run time. Its declarations used to list runtime values, such as `coreHash`, that it never exported, so importing one compiled and then failed when the module loaded. Such an import now fails to compile with TS1362 or TS1361. Import the type with `import type`, or import the value from the path of the same package that exports it: `contract/types` or `family-contract/types` (`family-contract` on MongoDB). Imports of types do not change, and neither do generated `contract.d.ts` files.
49
+ detection:
50
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
51
+ matches:
52
+ - '@prisma/orm-(?:postgres|sqlite|mysql|mariadb|mongo)/contract-types[''"]'
53
+ - id: contract-signature-flag
54
+ summary: |
55
+ `prisma db verify --marker-only` is now `prisma db verify --signature-only`; the old flag is refused. Run this guide's colocated script: it changes the flag wherever it is written as a whole word, in `package.json` scripts, CI workflow files, shell scripts, Markdown and code, including an argument array that spreads the command over several lines.
56
+ detection:
57
+ glob: "**/*"
58
+ matches:
59
+ - '(?<![\w-])--marker-only(?![\w-])'
60
+ script: ./scripts/contract-signature-names/contract-signature-names.ts
61
+ - id: contract-signature-error-codes
62
+ summary: |
63
+ Nine error codes are renamed. Six say SIGNATURE where they said MARKER, such as `CONTRACT.MARKER_MISSING`, now `CONTRACT.SIGNATURE_MISSING`; `MIGRATION.MARKER_MISMATCH` and `MIGRATION.MARKER_NOT_IN_HISTORY`, which reported one condition from two commands, are one code, `MIGRATION.SIGNATURE_NOT_IN_GRAPH`; `MIGRATION.MARKER_CAS_FAILURE` is `MIGRATION.CONCURRENT_CHANGE`. `CONTRACT.MARKER_REQUIRED` and `CONFIG.FAMILY_READ_MARKER_REQUIRED`, which no command raised, are gone. The script renames the nine wherever they are written; remove code that matches the two removed ones.
64
+ detection:
65
+ glob: "**/*"
66
+ matches:
67
+ - '(?<![\w.])(?:CONTRACT|MIGRATION)\.MARKER_[A-Z_]+'
68
+ - 'CONFIG\.FAMILY_READ_MARKER_REQUIRED'
69
+ script: ./scripts/contract-signature-names/contract-signature-names.ts
70
+ - id: contract-signature-json-fields
71
+ summary: |
72
+ In `--json` output the field `marker` is now `signature` (in `db verify`, `db init`, `db update` and each `perSpace` entry of `db init`, `db update` and `db migrate`), `markerHash` of `db migrate` is `signatureHash`, and the `db verify` mode `marker-only` is `signature-only`. The error values `orphanMarker` and `markerChanged` are `orphanSignature` and `signatureChanged`, and the scope of the client's warnings about the contract signature, `marker-verification`, is `contract-signature-verification`. The script renames them where it can tell they are Prisma's; the guide says how to find the rest.
73
+ detection:
74
+ glob: "**/*"
75
+ matches:
76
+ - '--json[\s\S]*\.marker(?:Hash)?(?![\w$])'
77
+ - '--json[\s\S]*\{[^{}]*(?<![\w$.])marker(?:Hash)?(?![\w$])[^{}]*\}\s*=(?![=>])'
78
+ - '\bdb\s+(?:verify|init|update|migrate)\b[^\n]*--json[^\n]*\.marker'
79
+ - "['\"`](?:orphanMarker|markerChanged|marker-only|marker-verification)['\"`]"
80
+ script: ./scripts/contract-signature-names/contract-signature-names.ts
81
+ - id: contract-signature-published-names
82
+ summary: |
83
+ Every name the platform packages published with Marker in it says Signature: a type that stands alone in an import says `ContractSignature`, such as `MarkerDestination`, now `ContractSignatureDestination`, and the adapter methods `readMarker`, `readAllMarkers`, `initMarker` and `updateMarker` are `readSignature`, `readAllSignatures`, `initSignature` and `updateSignature`; the outcome of signing a space, `SpaceSignature`, is `SpaceSignOutcome`. The path `@prisma/orm-target-mysql/target/marker-lock` is `@prisma/orm-target-mysql/target/signature-lock`. The script renames a name where a file imports it from an `@prisma/orm-*` package, and a renamed member where such a file reads, writes or declares it.
84
+ detection:
85
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx}"
86
+ matches:
87
+ - '(?<![\w$])(?:buildSignMarkerBootstrapQueries|MARKER_LOCK_TIMEOUT_SECONDS|withMarkerReadErrorHandling|VERIFY_CODE_MARKER_MISSING|VERIFY_CODE_HASH_MISMATCH|ContractMarkerRecordLike|SpaceMarkerHashConflict|parseContractMarkerRow|rethrowMarkerReadError|errorMarkerReadFailed|errorMarkerRowCorrupt|ContractMarkerRecord|contractHashAtMarker|parseMarkerRowSafely|SpaceMarkerConflict|MarkerCheckSection|VerifyMarkerOption|errorMarkerMissing|ContractMarkerRow|MarkerCheckResult|MarkerDestination|MarkerSwapFailure|SpaceMarkerRecord|acquireMarkerLock|errorHashMismatch|markerSwapFailure|releaseMarkerLock|MarkerOperations|MarkerReadResult|sameMarkerHashes|SpaceSignature|withMarkerLock|MarkerHashes|MarkerInsert|MarkerReader)(?![\w$])[^;]*?\bfrom\s*[''"]@prisma/orm-'
88
+ - '@prisma/orm-[\s\S]*(?:\.\s*(?:bootstrapSignMarkerQueries|databaseMarkerHashBySpace|currentMarkerStorageHash|currentMarkerInvariants|readMarkerDiscriminated|currentMarkerHash|markerRowsBySpace|markerInvariants|markersBySpaceId|holdMarkerLock|markerLocation|readAllMarkers|currentMarker|orphanMarkers|insertMarker|markerReader|updateMarker|verifyMarker|markerCheck|markerDrift|initMarker|lockMarker|markerHash|readMarker|skipMarker|markerOps)(?![\w$])|(?:(?<!\$)\{|[,;])\s*(?:(?:readonly|async|public|private|protected|static|override)\s+)*(?:bootstrapSignMarkerQueries|databaseMarkerHashBySpace|currentMarkerStorageHash|currentMarkerInvariants|readMarkerDiscriminated|currentMarkerHash|markerRowsBySpace|markerInvariants|markersBySpaceId|holdMarkerLock|markerLocation|readAllMarkers|currentMarker|orphanMarkers|insertMarker|markerReader|updateMarker|verifyMarker|markerCheck|markerDrift|initMarker|lockMarker|markerHash|readMarker|skipMarker|markerOps)\s*\??\s*[:(]|\breadonly\s+(?:bootstrapSignMarkerQueries|databaseMarkerHashBySpace|currentMarkerStorageHash|currentMarkerInvariants|readMarkerDiscriminated|currentMarkerHash|markerRowsBySpace|markerInvariants|markersBySpaceId|holdMarkerLock|markerLocation|readAllMarkers|currentMarker|orphanMarkers|insertMarker|markerReader|updateMarker|verifyMarker|markerCheck|markerDrift|initMarker|lockMarker|markerHash|readMarker|skipMarker|markerOps)\s*=)'
89
+ - '@prisma/orm-target-mysql/target/marker-lock'
90
+ script: ./scripts/contract-signature-names/contract-signature-names.ts
91
+ - id: postgres-client-parts-early-access-names
92
+ summary: |
93
+ The PostgreSQL facade's `internal/options`, `internal/static-context`, `internal/transaction-members` and `internal/validate-contract` entries are removed. The parts of `postgres()` they exported have Early Access names on existing entries, and `PostgresRuntimeImpl` is renamed. Import `ea_connectWithBinding`, `ea_resolveOptionalPostgresBinding`, `Ea_PostgresBindingRules`, `ea_validateTransactionOptions`, `ea_validateCursorOptions`, `ea_toDriverCursorOptions`, `ea_buildPostgresQueryMembers` and `Ea_PostgresRuntimeImpl` from `@prisma/orm-postgres/runtime`, and `ea_buildPostgresStaticContext` and `ea_validatePostgresContract` from `@prisma/orm-postgres/static`.
94
+ detection:
95
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
96
+ matches:
97
+ - '@prisma/orm-postgres/internal/'
98
+ - '@internal/postgres/internal/'
99
+ - '(?<![\w$])PostgresRuntimeImpl(?![\w$])'
100
+ - id: sql-prepared-query-early-access-names
101
+ summary: |
102
+ The `runtime/internal/prepared-query` entry of `@prisma/orm-family-sql` is removed, and so is `family-runtime/internal/prepared-query` on `@prisma/orm-postgres`, `@prisma/orm-mysql`, `@prisma/orm-mariadb` and `@prisma/orm-sqlite`. Import `ea_preparedStatementQuery`, `ea_preparedStatementExecute`, `ea_transactionStart`, `ea_createTransactionStart`, `Ea_PreparedStatementQueryTarget`, `Ea_PreparedStatementExecuteTarget` and `Ea_TransactionStartTarget` from `@prisma/orm-family-sql/runtime` (or a facade's `family-runtime` entry). The entry's other names are no longer exported.
103
+ detection:
104
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
105
+ matches:
106
+ - 'runtime/internal/prepared-query'
107
+ - id: extension-code-reads-required-capabilities
108
+ summary: |
109
+ A contract of every database, MongoDB included, stores what it requires as `requiredCapabilities` in place of `capabilities`, with each key prefixed by who provides it: `conn.interactiveTransactions` for the connection, and `db.` for every other key. Extension code that reads `contract.capabilities` reads `contract.requiredCapabilities`: the list is sorted capability keys, so `contract.capabilities.sql.returning` becomes `contract.requiredCapabilities.includes('db.returning')`, and `contract.capabilities.postgres.distinctOn` becomes `contract.requiredCapabilities.includes('db.distinctOn')`. A contract built by hand, such as one in a test, renames its field and keys the same way. `computeProfileHash` from `@prisma/orm-framework/contract/hashing` takes `requiredCapabilities` in place of `capabilities`. `mysqlAdapterCapabilities`, `mariadbAdapterCapabilities`, `sqliteAdapterCapabilities`, `lockOptionCapabilities` and `lockStrengthCapabilities` are lists of keys too, such as `['conn.interactiveTransactions', 'db.enums', …]`.
110
+ detection:
111
+ glob: "**/*.{ts,mts,cts,js,mjs,cjs}"
112
+ matches:
113
+ - '\bcontract\s*(?:\?\.|\.)\s*capabilities\b'
114
+ - '\.capabilities\s*(?:\?\.|\.)\s*(?:sql|postgres)\b|\.capabilities\s*(?:\?\.)?\[\s*[''"](?:sql|postgres)\b'
115
+ - '\bcapabilities[''"]?\s*:\s*\{\s*[''"]?(?:sql|postgres)[''"]?\s*:'
116
+ - '\bcomputeProfileHash\s*\('
117
+ - '\b(?:(?:mysql|mariadb|sqlite)AdapterCapabilities|lockOptionCapabilities|lockStrengthCapabilities)\b'
118
+ - 'Object\.(?:entries|keys|values)\(\s*[\w.?]*\.(?:required)?[cC]apabilities\b'
119
+ - id: extension-stored-contract-needs-the-upgrade-script
120
+ summary: |
121
+ This release refuses to read a `contract.json` that a release candidate wrote, for every database, with `CONTRACT.VALIDATION_FAILED`, because it stores `capabilities`. A migration snapshot a release candidate wrote is refused before that, with `MIGRATION.CONTRACT_SNAPSHOT_CONTENT_MISMATCH`, because its storage hash was computed by the old hash rules. Run the `contract-hash-inputs` script of this release on the extension package, which rewrites both, and then `prisma contract emit`, as the `contract-hash-inputs` instructions say, and publish the rewritten files. For PostgreSQL, see also `extension-contract-lists-required-capabilities` and the entries after it.
122
+ detection:
123
+ glob: "**/contract.json"
124
+ matches:
125
+ - '(?<![\s\S])(?![\s\S]*"requiredCapabilities")(?![\s\S]*"target"\s*:\s*"postgres")(?=[\s\S]*"targetFamily")[\s\S]*"capabilities"\s*:'
126
+ - id: required-capabilities-as-list
127
+ summary: |
128
+ A contract's `requiredCapabilities` and a component's `capabilities` are lists of keys, such as `['db.returning']`, not maps grouped by namespace as `8.0.0-rc.25` wrote them (`{ sql: { returning: true }, postgres: { distinctOn: true } }`) or by prefix as a development build did (`{ db: { returning: true } }`). Code that read `requiredCapabilities.db.returning` checks `requiredCapabilities.includes('db.returning')`, and a target, adapter or driver declares `capabilities: ['db.returning']`, each key renamed as `extension-code-reads-required-capabilities` says; one that still declares the grouped form is refused with `CONTRACT.PACK_CONTRIBUTION_INVALID`. Removed: `mergeCapabilityMatrices` and `CapabilityMatrix` (`@prisma/orm-framework/components`, replaced by `unionCapabilityKeys`), `isCapabilityKey`, `CapabilityKey`, `capabilitiesFromKeys`, `CapabilitiesFromKeys`, `capabilityKeysOf` and `CapabilityKeysOf` (`@prisma/orm-family-sql/contract-ts/contract-builder`), `isCapabilityProvider` (`@prisma/orm-family-sql/contract`), `missingCapability` and `CapabilityRequirement` (`@prisma/orm-family-sql/relational-core`), and `postgresRequiredCapabilities` and `PostgresRequiredCapabilities` (`@prisma/orm-postgres/config`). Changed: `DatabaseCapabilities` and `ConnectionCapabilities` are lists of keys, `InteractiveTransactionsCapability` is the key `'conn.interactiveTransactions'`, and `GatedMethod`'s second type argument is a key such as `'db.distinctOn'`.
129
+ detection:
130
+ glob: "**/*.{ts,tsx,mts,cts,js,mjs,cjs}"
131
+ matches:
132
+ - 'requiredCapabilities\??\.(db|conn)\b'
133
+ - 'requiredCapabilities(\?\.)?\[\s*[''"](db|conn)[''"]'
134
+ - '\b(mergeCapabilityMatrices|CapabilityMatrix|isCapabilityKey|CapabilityKey|capabilitiesFromKeys|CapabilitiesFromKeys|capabilityKeysOf|CapabilityKeysOf|isCapabilityProvider|missingCapability|CapabilityRequirement|[Pp]ostgresRequiredCapabilities)\b'
135
+ - '\b(DatabaseCapabilities|ConnectionCapabilities|InteractiveTransactionsCapability)\b'
136
+ - '\bGatedMethod\s*<[^>]*\{\s*[''"]?(db|conn|sql|postgres)\b'
137
+ - '\bcapabilities[''"]?\s*:\s*\{\s*[''"]?(db|conn|sql|postgres)\b'
138
+ - '[cC]apabilities\s*(?::[^=;]*)?=\s*(?:Object\.freeze\(\s*)?\{\s*[''"]?(?:db|conn|sql|postgres)[''"]?\s*:'
139
+ - 'Object\.(?:entries|keys|values)\(\s*[\w.?]*\.(?:required)?[cC]apabilities\b'
140
+ - id: extension-contract-lists-required-capabilities
141
+ summary: |
142
+ A PostgreSQL contract now lists every capability it requires. An extension's shipped contract requires what the oldest PostgreSQL version the extension supports provides, and the driver's: `defineContract({ requiredCapabilities: [...postgres15, ...postgresDriver], ... })`, or `requiredCapabilities: [...postgres15, ...postgresDriver]` for a `prismaContract` source. Each key names who provides it: `db.` for the database, `conn.` for the connection. Then run `prisma contract emit`, after the `contract-hash-inputs` script, and sign each test database again with `prisma db sign`.
143
+ detection:
144
+ glob: "**/*.{ts,mts,cts,js,mjs,cjs}"
145
+ matches:
146
+ - '@prisma/orm-postgres/(?:config|contract-builder)[''"]'
147
+ - '@internal/postgres/(?:config|contract-builder)[''"]'
148
+ - '\bprisma(?:7)?Contract\s*\('
149
+ - id: extension-descriptor-declares-no-capabilities
150
+ summary: |
151
+ An extension's descriptors no longer declare capabilities. Remove the `capabilities` field from the extension's pack metadata and descriptors: an extension descriptor or pack ref that declares one no longer type-checks, and `prisma contract emit` no longer adds an extension's flags to the application's contract.
152
+ detection:
153
+ glob: "**/*.{ts,mts,cts}"
154
+ matches:
155
+ - 'kind\s*:\s*[''"]extension[''"][\s\S]*\bcapabilities\s*:\s*\{'
156
+ - id: extension-capability-flags-removed
157
+ summary: |
158
+ PostgreSQL contracts no longer list `postgres.orderBy`, `postgres.limit`, `postgres.lateral`, `postgres.jsonAgg`, `postgres.returning`, `sql.enums`, `postgres.pgvector.cosine`, `postgres.postgis.geometry` or `postgres.paradedb/bm25`. Nothing read them, and no `db.` key replaces them. Remove any code that reads or writes them.
159
+ detection:
160
+ glob: "**/*.{ts,mts,cts,js,mjs,cjs}"
161
+ matches:
162
+ - '\bpostgres\.(?:orderBy|limit|lateral|jsonAgg|returning)\b'
163
+ - 'pgvector\.cosine|postgis\.geometry|paradedb/bm25'
164
+ - id: extension-client-goes-by-the-contract
165
+ summary: |
166
+ The SQL runtime no longer adds the target's, adapter's, driver's and extensions' capabilities to the contract's. `createExecutionContext` ignores its `driver` option, and Prisma 8.0 removes it. A contract stores what it requires as `requiredCapabilities`, a sorted list of keys prefixed `db.` or `conn.`, such as `db.returning`. A contract built by hand, as in a test, lists every capability the code uses there, and `transaction()` needs it to require `conn.interactiveTransactions`.
167
+ detection:
168
+ glob: "**/*.{ts,mts,cts}"
169
+ matches:
170
+ - '\bcreateExecutionContext\s*\('
171
+ - '\.transaction\s*\('
172
+ - '\.capabilities\s*(?:\?\.|\.)\s*(?:sql|postgres)\b|\.capabilities\s*(?:\?\.)?\[\s*[''"](?:sql|postgres)\b'
173
+ - '\bcapabilities[''"]?\s*:\s*\{\s*[''"]?(?:sql|postgres)[''"]?\s*:'
174
+ - id: extension-capability-exports-moved
175
+ summary: |
176
+ `postgresAdapterCapabilities` is now empty, and Prisma 8.0 removes it. `POSTGRES_MIN_SERVER_VERSION`'s new home is `@prisma/orm-target-postgres/target/server-version-range`; its old import path keeps working until Prisma 8.0 removes it. `renderLoweredSql` ignores its last argument, the capabilities, and Prisma 8.0 removes it. `PostgresDatabaseSchemaNode.pgVersion` is replaced by `serverVersionNumber`.
177
+ detection:
178
+ glob: "**/*.{ts,mts,cts,js,mjs,cjs}"
179
+ matches:
180
+ - '\bpostgresAdapterCapabilities\b'
181
+ - '\bPOSTGRES_MIN_SERVER_VERSION\b'
182
+ - '\brenderLoweredSql\s*\('
183
+ - '\bpgVersion\b'
184
+ - id: data-type-param-keys
185
+ summary: |
186
+ A data type with a parameter schema now declares its parameters beside it as `paramKeys`, each one `'required'` or `'optional'`, in `sqlDataType(...)` from `@prisma/orm-family-sql/contract/data-type`, `mongoDataType(...)` from `@prisma/orm-family-mongo/contract/data-type` and `dataType(...)` from `@prisma/orm-framework/components/codec`. A declaration with `params` and no `paramKeys` no longer type-checks, and fails at run time with an `InvariantError`. A declaration without `params` must now have parameters that name no keys and narrow no values: the broad `DataTypeParams`, `{}` or `Record<never, never>`. So a declaration without `params` whose hooks are typed with other parameters, taken by `normalize`, `catalogParams` or `render` or returned by `fromReported`, or given as a type argument, no longer type-checks either: it must declare `params`. `params` is now typed as a Standard Schema (`StandardSchemaV1` from `@standard-schema/spec`), so a schema built by any copy of arktype is accepted without a cast and its refusals are honoured. A type constructor may map an argument only onto a key the data type's `paramKeys` declares.
187
+ detection:
188
+ glob: "**/*.{ts,mts,cts}"
189
+ matches:
190
+ - '(?:(?<![\w$])(?:sqlDataType|mongoDataType)|(?<![\w$]|[\w$)\]]\.)dataType)\s*(?:<[\s\S]*?>)?\s*\([\s\S]*?\bparams\s*[:,}]'
191
+ - '(?:(?<![\w$])(?:sqlDataType|mongoDataType)|(?<![\w$]|[\w$)\]]\.)dataType)\s*(?:<[\s\S]*?>)?\s*\([\s\S]*?\b(?:normalize|catalogParams|render|fromReported)\b'
192
+ - id: data-type-schema-key-helpers-removed
193
+ summary: |
194
+ `objectSchemaKeys`, `requiredSchemaKeys` and `schemaKeysAllowing` are no longer exported by `@prisma/orm-framework/components` and `@prisma/orm-framework/components/codec`. Read a data type's parameters from its `paramKeys` instead, or call `requiredParamKeys(type)`. `DataType.params` is a Standard Schema: check parameters with `dataTypeParamsProblem(type, params)` or `params['~standard'].validate(value)`, not by calling it.
195
+ detection:
196
+ glob: "**/*.{ts,mts,cts}"
197
+ matches:
198
+ - '(?<![\w$])(?:objectSchemaKeys|requiredSchemaKeys|schemaKeysAllowing)(?![\w$])'
199
+ - '\.params\s*(?:\?\.)?\s*\('
200
+ - id: data-type-params-not-arktype
201
+ summary: |
202
+ `DataType.params`, `SqlDataType.params`, `DataTypeSpec.params` and `SqlDataTypeSpec.params` are a Standard Schema, not arktype's `Type`, so arktype's members on them no longer type-check: `dataType.params.and(...)`, `typeof dataType.params.infer`, `.allows(...)`, `.json` and the rest. `DataTypeSpec` from `@prisma/orm-framework/components/codec`, `SqlDataTypeSpec` from `@prisma/orm-family-sql/contract/data-type` and `MongoDataTypeSpec` from `@prisma/orm-family-mongo/contract/data-type` now depend on their parameter type, so an interface that extends one with no type argument, or with a type parameter, no longer compiles, and a function generic over the parameters that removes its own fields from a spec by rest destructuring and passes the rest on no longer type-checks.
203
+ detection:
204
+ glob: "**/*.{ts,mts,cts}"
205
+ matches:
206
+ - '\.params\s*(?:\?\.|\.)\s*(?:and|or|merge|pipe|narrow|infer|inferIn|inferOut|json|expression|allows|assert|keyof|omit|pick|partial|describe|configure|onUndeclaredKey|onDeepUndeclaredKey|toJsonSchema|brand|satisfying)(?![\w$])'
207
+ - '\bextends\s+(?:Sql|Mongo)?DataTypeSpec(?![\w$])'
208
+ - '\{[^{}]*\.\.\.\s*([\w$]+)\s*\}\s*[=:][\s\S]*?(?:(?<![\w$])(?:sqlDataType|mongoDataType)|(?<![\w$]|[\w$)\]]\.)dataType)\s*(?:<[\s\S]*?>)?\s*\(\s*[^,()]+,\s*\1\s*,?\s*\)'
209
+ - id: index-type-options-standard-schema
210
+ summary: |
211
+ An index type's options validator, `options` in `defineIndexTypes().add(...)` from `@prisma/orm-family-sql/contract/index-types`, is now typed as a Standard Schema (`StandardSchemaV1` from `@standard-schema/spec`) of the options an author writes, instead of arktype's `Type`. A registration written with arktype's `type(...)` needs no change, including one with a morph, a default or `.pipe`. Code that reads a registered entry's `options` back and calls it, whether from `entries`, from `registry.get(...)`, or through a value typed `IndexTypeEntry`, no longer type-checks: call `options['~standard'].validate(value)` and read its `issues` instead.
212
+ detection:
213
+ glob: "**/*.{ts,mts,cts}"
214
+ matches:
215
+ - '^(?=[\s\S]*(?:\.entries\s*(?:\[|\.\w)|IndexTypeEntry|IndexTypeRegistry|indexTypeRegistryOf|defineIndexTypes|indexTypes))[\s\S]*\.options\s*(?:\?\.)?\('
216
+ - id: extension-index-types-checked-for-prisma-schemas
217
+ summary: |
218
+ A Prisma schema read through `defineConfig` now receives each configured extension's index types, and checks them when it loads, as a TypeScript contract already did. An extension whose `indexTypes` registers a type another extension or the target also registers, or registers a type whose `accessMethod` differs from its literal, now makes every such schema fail to load with `CONTRACT.PACK_CONTRIBUTION_INVALID`, even a schema that does not use the type. Rename the conflicting type, or remove its `accessMethod`.
219
+ detection:
220
+ glob: "**/*.{ts,mts,cts,js,mjs,cjs}"
221
+ matches:
222
+ - '\bdefineIndexTypes\s*\('
223
+ - id: control-api-ref-resolution-takes-migration-dir
224
+ summary: |
225
+ `resolveContractRef`, `resolveContractRefToSnapshot`, `resolveFromForPlan` and `resolveToForPlan`, from `@prisma/orm-toolchain/cli/control-api`, take one more required field in their options or context, `migrationDirResolution: { cwd, spaceMigrationsDir }`: the folder a path argument is resolved against, and the migrations folder of the space, such as `<project>/migrations/app`. A call without it no longer compiles.
226
+ detection:
227
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
228
+ matches:
229
+ - '\b(?:resolveContractRef|resolveContractRefToSnapshot|resolveFromForPlan|resolveToForPlan)\s*\('
230
+ - id: read-the-database-config
231
+ summary: |
232
+ A family's control instance has two new required members, `readDatabaseConfig` and `databaseConfigLocation`, and so do the SQL family's control adapter (`SqlControlAdapter`, which also gains the required `recordDatabasePolicies`), the MongoDB family's control adapter (`MongoControlAdapter`) and the MongoDB runner's `ContractSignatureOperations`. The database's policies are read from what `readDatabaseConfig` returns, never from a contract signature's `meta.policies`.
233
+ detection:
234
+ glob: "**/*.{ts,tsx,mts,cts}"
235
+ matches:
236
+ - '\b(ControlFamilyInstance|SqlControlAdapter|MongoControlAdapter|MarkerOperations|ContractSignatureOperations|SqlControlFamilyInstance|MongoControlFamilyInstance)\b'
237
+ - id: policy-helpers-renamed
238
+ summary: |
239
+ `compareMarkerDatabasePolicies` and `MarkerDatabasePoliciesComparison` are renamed `compareDatabasePolicies` and `DatabasePoliciesComparison`, `databasePoliciesOf` takes the database's config (`DatabaseConfigRecord`) in place of a signature, and `errorMarkerPoliciesCorrupt` is replaced by `errorDatabasePoliciesCorrupt`, whose code is `CONTRACT.DATABASE_POLICIES_CORRUPT`; a role that may not read the policies gets the new `CONTRACT.DATABASE_POLICIES_READ_FAILED`.
240
+ detection:
241
+ glob: "**/*.{ts,tsx,mts,cts}"
242
+ matches:
243
+ - '\b(compareMarkerDatabasePolicies|MarkerDatabasePoliciesComparison|databasePoliciesOf|errorMarkerPoliciesCorrupt)\b'
244
+ - 'CONTRACT\.(?:MARKER_ROW_CORRUPT|SIGNATURE_ROW_CORRUPT)'
245
+ - id: name-the-prisma-schema
246
+ summary: |
247
+ On PostgreSQL, Prisma's own tables are now in the schema `prisma`, not `prisma_contract`, and the `marker` table is replaced by `prisma.signatures`, one row per contract space, and `prisma.config`, which holds the database's policies. Extension code and tests that name `prisma_contract` in SQL, such as a query of `prisma_contract.marker` or a test helper that drops the schema to reset the database, must name `prisma`; a query of which contract a space is at must read `prisma.signatures`, and a query of the policies must read `prisma.config`.
248
+ detection:
249
+ glob: "**/*"
250
+ contains:
251
+ - "prisma_contract"
252
+ - id: prisma-tables-api-breaks
253
+ summary: |
254
+ `@prisma/orm-target-postgres` no longer exports `buildControlTableBootstrapQueries` or `buildSignMarkerBootstrapQueries`, and `PostgresControlAdapter.signatureLocation` is typed `string`. A contract signature read (`ContractSignatureReadResult`) can return the new kind `earlier-release`, the runner's error codes include `MIGRATION.PRISMA_TABLES_MISSING`, and `ControlClient` has a new required method, `bringPrismaSpaceUpToDate`.
255
+ detection:
256
+ glob: "**/*.{ts,tsx,mts,cts}"
257
+ contains:
258
+ - "buildControlTableBootstrapQueries"
259
+ - "buildSignMarkerBootstrapQueries"
260
+ - "markerLocation"
261
+ - "signatureLocation"
262
+ - "PostgresControlAdapter"
263
+ - "MarkerReadResult"
264
+ - "ContractSignatureReadResult"
265
+ - "SqlMigrationRunnerErrorCode"
266
+ - "ControlClient"
267
+ - id: sqlite-prisma-tables-renamed
268
+ summary: |
269
+ On SQLite, Prisma's own tables `_prisma_marker` and `_prisma_ledger` are replaced by `prisma_signatures`, `prisma_config` and `prisma_ledger`. Extension code and tests that name the old tables in SQL must name the new ones: `prisma_signatures` for which contract a space is at (`signed_at` in place of `updated_at`), `prisma_config` for the policies, `prisma_ledger` for the ledger.
270
+ detection:
271
+ glob: "**/*"
272
+ matches:
273
+ - '\b_prisma_(?:marker|ledger)\b'
274
+ - id: sqlite-prisma-tables-api-breaks
275
+ summary: |
276
+ `@prisma/orm-target-sqlite` no longer exports `MARKER_TABLE_NAME`, `LEDGER_TABLE_NAME` or `CONTROL_TABLE_NAMES` (and the `./target/control-tables` entry is gone), nor `buildControlTableBootstrapQueries` or `buildSignBootstrapQueries`. The table names are `PRISMA_TABLE_NAMES` and `RESERVED_TABLE_NAMES` from `./target/contract-free`. The SQLite migration runner, and a direct sign of a SQLite database, refuse with `MIGRATION.PRISMA_TABLES_MISSING` until Prisma's own tables exist; they no longer create them.
277
+ detection:
278
+ glob: "**/*.{ts,tsx,mts,cts}"
279
+ contains:
280
+ - "MARKER_TABLE_NAME"
281
+ - "LEDGER_TABLE_NAME"
282
+ - "CONTROL_TABLE_NAMES"
283
+ - "target/control-tables"
284
+ - "buildControlTableBootstrapQueries"
285
+ - "buildSignBootstrapQueries"
286
+ - id: kept-enum-member-route-removed
287
+ summary: |
288
+ The CLI no longer gives its own way to keep the data of an enum member that keeps its name: the two runs of `db update` through a temporary member, and the dropping of a target's `keepDataAdvice` for members that swap stored values. A target that still reports such a member as data loss gets its question with only the `keepDataAdvice` and `keepDataEdit` it gives. `KeepDataEdit.swapsValues` stays in the type, and nothing reads it.
289
+ detection:
290
+ glob: "**/*.{ts,mts,cts}"
291
+ matches:
292
+ - '(?<![\w$])swapsValues(?![\w$])'
293
+ - id: mongo-runner-checked-policies-renamed
294
+ summary: |
295
+ The MongoDB runner's execute option `checkedPolicies` is renamed `policiesInForce`, and every contract space's runner now receives it. Code that passes `checkedPolicies` to the runner's `execute` must pass `policiesInForce` instead; the runner ignores the old name. Only that option is renamed: the `checkedPolicies` parameter of `updateSignature` (on `ContractSignatureOperations` and `MongoControlAdapter`) and of `signatureSwapFailure` keeps its name, so leave those as they are.
296
+ detection:
297
+ glob: "**/*.{ts,mts,cts}"
298
+ matches:
299
+ - '(?<![\w$])checkedPolicies(?![\w$])'
300
+ - id: extension-migration-calls-use-framework-interface
301
+ summary: |
302
+ The MongoDB, MySQL and SQLite targets no longer publish a union of their own migration calls: `OpFactoryCall` from `@prisma/orm-target-mongo/target` and `/target/control`, `MysqlOpFactoryCall` and `SqliteOpFactoryCall` are gone, so a later 8.x release can add a migration factory. The published entry points use the framework's `OpFactoryCall` interface from `@prisma/orm-framework/components/control`, whose `factoryName` is any string: MongoDB's `planCalls()` result and `PlannerProducedMongoMigration` hold such calls, `renderOps()` and `renderCallsToTypeScript()` take them (`renderOps()` returns MongoDB operations), and SQLite's `RenameColumnCall.companions` and `RenameTableCall.companions` hold them. What to do:
303
+
304
+ - Import the framework's `OpFactoryCall` in place of the removed names.
305
+ - Where code reads a call's own properties, such as a MongoDB `CreateIndexCall`'s `collection`, narrow with `instanceof` the call class the target exports, and give a call of another class a default branch, as the example below shows.
306
+ - A SQLite rename call's `indexReplacements` still gives each drop and create as its own class.
307
+ - MongoDB's `planCalls()` no longer takes `statementCalls`.
308
+ - MongoDB's `renderOps()` lowers a call that is not one of the MongoDB target's, such as an extension's, through its own `toOp()`, and refuses an operation that is not a MongoDB one with `MIGRATION.INVALID_OPERATION_ENTRY`. Give it calls whose operations are MongoDB operations.
309
+
310
+ Migration files do not change: they call the migration factories, which are unchanged.
311
+ detection:
312
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
313
+ matches:
314
+ - '\b(?:MysqlOpFactoryCall|SqliteOpFactoryCall|planCalls|renderCallsToTypeScript|PlannerProducedMongoMigration|companions|statementCalls)\b'
315
+ - 'import\s+(?:type\s+)?\{[^}]*\bOpFactoryCall\b[^}]*\}\s*from\s*[''"]@prisma/orm-target-mongo'
316
+ - 'import\s+(?:type\s+)?\{[^}]*\brenderOps\b[^}]*\}\s*from\s*[''"]@prisma/orm-target-mongo'
317
+ - 'import\s+(?:type\s+)?\*\s+as\s+\w+\s+from\s*[''"]@prisma/orm-target-mongo'
318
+ - id: fragment-on-the-client
319
+ summary: |
320
+ The ORM client that `orm()` returns no longer has a `fragment` member: it holds only the contract's namespaces. `OrmClientRootMembers` is replaced by `FragmentMember`, and `fragmentMember<Contract>()` returns the member. The facade clients offer `fragment` themselves (`db.fragment`, `tx.fragment`, the static entry), and `SqliteOrm` and `MysqlOrm` are now only the namespace's models. A facade or client that offers `orm` adds `...fragmentMember<Contract>()` to its static members and to its transactions' members. The detection matches a file that names `OrmClientRootMembers`, `SqliteOrm` or `MysqlOrm`, calls `orm(`, or calls `fragment` on an ORM client or with field declarations.
321
+ detection:
322
+ glob: "**/*.{ts,tsx,mts,cts}"
323
+ matches:
324
+ - '(?<![\w$])(?:OrmClientRootMembers|SqliteOrm|MysqlOrm)(?![\w$])'
325
+ - '(?<![\w$.])orm\('
326
+ - '\.fragment\(\s*[^\s()]'
327
+ - '(?<![\w$])orm\.fragment\('
328
+ - id: aggregate-operation-names-after-8-0
329
+ summary: |
330
+ `orm()` refuses a contributed aggregate operation with `ORM.AGGREGATE_OPERATION_RESERVED` only when its name is one of the members a collection has in Prisma 8.0. An operation named like a member added later to the base collection class is installed, and its reducer takes the name on the collection. It never takes a name from a member that a user's own collection class declares. One new refusal: an operation named like a member every JavaScript object inherits, such as `valueOf` or `toString`, is now refused with the same error, where it used to be skipped without one. Rename such an operation.
331
+ - id: update-all-explicit-type-argument
332
+ summary: |
333
+ `updateAll` and `updateAndCount` on an ORM collection now have two type parameters, because they also take a callback. A call that passes one explicit type argument, such as `drafts.updateAll<typeof drafts>({ ... })`, no longer compiles (TS2558). Remove the type argument: TypeScript infers both. Calls without a type argument do not change.
334
+ detection:
335
+ glob: "**/*.{ts,mts,cts,tsx}"
336
+ matches:
337
+ - '\.(?:updateAll|updateAndCount)\s*<'
338
+ - id: orm-fns-comparison-takes-field-input-type
339
+ summary: |
340
+ In an ORM callback, `fns.eq`, `fns.ne`, `fns.gt`, `fns.gte`, `fns.lt`, `fns.lte`, `fns.in` and `fns.notIn` now type a plain value compared with a model field as that field's input type, such as an enum's member union, as `p.status.eq(...)` and the `where` shorthand object already did. A value that is not of that type, such as `fns.eq(p.status, 'NOT_A_MEMBER')`, no longer compiles. Do not edit such a call: report it to the user with the value or narrowing you would propose, note that the condition would then match different rows than before, and ask.
341
+ detection:
342
+ glob: "**/*.{ts,tsx,mts,cts}"
343
+ matches:
344
+ - '(?<![\w$])fns\.(?:eq|ne|gte?|lte?|in|notIn)\('
345
+ - id: prepared-declaration-param-spec-can-be-a-list
346
+ summary: |
347
+ `ParamSpec`, the type of each parameter in a prepared declaration (`@prisma/orm-family-sql/runtime`, and the `family-runtime` entry of each SQL database package, such as `@prisma/orm-postgres/family-runtime`), gains `many?: { elementNullable: boolean }`, for a parameter that holds a list. Code that is generic over a declaration, such as a function that wraps `prepare`, `prepareQuery` or `delegatingRuntime`, implements `PrepareMember` or `DelegatingRuntime`, or maps each parameter of a declaration to a value type, may no longer type-check where it treats every parameter as one value. Treat a spec with `many` as a list of its codec's values, or pass the declaration type on unchanged. The `ParamSpec` of `@prisma/orm-framework/operations`, for operation signatures, is a different type and does not change: leave code that uses only that one as it is.
348
+ detection:
349
+ glob: "**/*.{ts,mts,cts,tsx}"
350
+ matches:
351
+ - '\b(?:PrepareMember|prepareQuery|DelegatingRuntime|delegatingRuntime|ParamSpec)\b'
352
+ - id: extension-middleware-handles-later-activities
353
+ summary: |
354
+ A middleware's hooks can now receive an activity, an ended result or a value of a kind a later 8.x release adds. `Activity` and `ActivityEndedResult` gain a member whose `kind` is a `FutureCase`, and `ActivityContext.mode` and `.scope`, `TransactionEnded.outcome`, `StatementEnded.outcome` and `.source`, `ClientActivityEnded.outcome` and `.source` and `ActivityFinalizedResult.outcome` accept any string beside their named values. Where a middleware checks every kind or value, with a `switch` or a `never` assignment, give it a branch for the rest, and act there as for a value it does not know: for example, cache nothing or pass the activity on. A middleware that narrows away `'statement'` and `'transaction'` and then reads a client activity's `contentHash` must instead check that the kind is a client kind, whose name always contains a hyphen (such as `orm-call`). `FutureCase` (from `@prisma/orm-framework/utils/types`) only stands for a later kind in the type, and no code can write it; at run time a later kind arrives under its own name, so check for the kinds the middleware knows. Likewise `StatementActivity.returns` accepts any string beside `'rows'` and `'stats'`, and `StatementEnded` gains a member whose `returns` is a `FutureCase`: read `rowCount` after `returns === 'rows'` and `stats` after `returns === 'stats'`, not in an `else` branch.
355
+ detection:
356
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
357
+ matches:
358
+ - '\b(?:activity(?:Started|Ended|Finalized)|onQuery|onExecute|onActivity|onRow|beforeEncode)\s*[(:]'
359
+ - id: extension-switches-over-later-values
360
+ summary: |
361
+ Sets of values that a later 8.x release may grow now say so in their types, so a `switch` that handles every value needs a `default` branch. They include a column default (`ColumnDefault`, kinds `'literal'` and `'function'`), a field's type (`ContractFieldType`, kinds `'scalar'`, `'valueObject'` and `'union'`), the partial filter of a document index (`Expr`), the database policies a ref declares (`ChangeStrategy`, `DataLossLevel`, `AccessWideningLevel`), a migration statement (`ResolvedMigrationStatement`, `ResolvedRenameStatement` and `MigrationStatementJson`, told apart by `kind` and `entity`), a migration subject (`MigrationSubject` and `MigrationSubjectJson`), a written value and its form (`WrittenValue`, `WrittenScalar`, `WrittenForm`), an argument type's kind (`ArgTypeKind`), the parts of the PSL document a target builds from a database (`PslDefaultValue`, `PslDefaultFunctionValue.name`, `PslAttributeArgument`, `PslAttributeTarget`), a string literal's quote (`StringLiteralQuote`), the PSL parser's symbols, scope resolutions, token kinds, syntax kinds and diagnostic codes (`PslSymbol`, `ScopeResolution`, `TokenKind`, `SyntaxKind`, `PslDiagnosticCode`), and what `init` passes a target's init contribution (`ContractSourceFormat`, and `ContractEntryInput` with kinds `'starter'` and `'prisma7-schema'`). Each is written `NonExhaustive<…>`, from `@prisma/orm-framework/utils/types`. A union of strings gains `(string & {})`; a union of objects gains a member whose `kind` is a `FutureCase`, a value no release has and no code can write, which stands for one a later release adds, and a migration statement also gains members whose `entity` is a `FutureCase`. Where code checks every value, with a `switch` or a `const unreachable: never = value` assignment, add a `default` branch. To keep the compiler's check that every kind the code knows is handled, assign the value there to `FutureCase` in place of `never`, as in `const later: FutureCase = value.kind`: a kind the code forgets is still a compile error. If your extension hands applications any of these sets, re-export the two helper types from every entry of the extension, as Prisma's own extensions do, since an entry can reach a set through types it does not name: `export type { FutureCase, NonExhaustive } from '@prisma/orm-framework/utils/types'`. Without it, an application file that imports only your extension and exports a value taken from such a set fails declaration emit with TS2742 under pnpm. An extension does not release with Prisma, so after an application upgrades Prisma the extension can be handed a value it does not know: in the `default` branch, refuse with the extension's own ordinary error, naming the unknown value and saying the extension needs a newer release, and never treat it as one of the values it knows. Where code reads a member's own property in an `else` branch, check for the kind it means instead. For example, ``arg.kind === 'positional' ? arg.value : `${arg.name}: ${arg.value}` `` over a `PslAttributeArgument` becomes a check of both kinds, `'positional'` giving `arg.value` and `'named'` giving `` `${arg.name}: ${arg.value}` ``, with any other kind refused, and a `contractEntry(input)` that handles `'prisma7-schema'` and then reads `input.mode` first checks `input.kind === 'starter'`. A table keyed by one of these sets, such as a `Record` from each value to a message, accepts any key once the set is open, so a lookup with a value a later release adds returns `undefined` although its type says otherwise: check that the key is present, for example with `Object.hasOwn(table, key)`, before using what it returns.
362
+ detection:
363
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
364
+ matches:
365
+ - '\b(?:ColumnDefault|ContractFieldType|ChangeStrategy|DataLossLevel|AccessWideningLevel|ResolvedMigrationStatement|ResolvedRenameStatement|MigrationStatementJson|MigrationSubject|MigrationSubjectJson|WrittenValue|WrittenScalar|WrittenForm|ArgTypeKind|PslDefaultValue|PslDefaultFunctionValue|PslAttributeArgument|PslAttributeTarget|StringLiteralQuote|PslSymbol|ScopeResolution|TokenKind|SyntaxKind|PslDiagnosticCode|ContractSourceFormat|ContractEntryInput|Expr)\b'
366
+ - '\bcontractEntry\s*[(:]'
367
+ - "\\.kind === 'positional' \\?"
368
+ - id: extension-more-open-sets-of-values
369
+ summary: |
370
+ More sets of values that a later 8.x release may grow now say so in their types. Each is written `NonExhaustive<…>`, from `@prisma/orm-framework/utils/types`. A union of strings gains `(string & {})`; a union of objects gains a member whose `kind`, or whichever property tells its members apart (`reason`, `status`, `by`, `setting`, `format`), is a `FutureCase`, a value no release has and no code can write, which stands for one a later release adds. The sets:
371
+
372
+ - an attribute spec's argument types (`ArgType` and `InspectableArgType`, by `kind`);
373
+ - the declaration that owns a field in `UnsupportedAttribute.owner` and `UnresolvedTypeReference.owner`;
374
+ - why a tagged literal has no written value (`ParsedWrittenScalar`'s `reason`);
375
+ - the syntax of an `unwritable` `ReadRefusal`, and the result of `temporalToText()`;
376
+ - a PostgreSQL extension node's `location`, and the `objectType` of a PostgreSQL, MySQL or SQLite migration operation's target details;
377
+ - a branch of an ORM `combine()` include, and the `aliasSource` of a prepared statement's `decodeContext`;
378
+ - why a tagged literal's text cannot be canonicalized (`TaggedLiteralCanonicalization`'s `reason`; `describeTaggedLiteralFailure()` now takes any string);
379
+ - why `readWrittenScalar()` read no value (`WrittenScalarResult`'s `reason`, and its `found`), and why a generator function did not resolve (`GeneratorFunctionResolution`'s `reason`);
380
+ - what a family's `signSpaces()` returns (`SpaceSignOutcome`'s `status`, and `SpaceSignConflict`'s `reason`), the `by` of a `FailedTypeChange` a target's runner reports, and the `setting` of a `DatabasePolicyDifference`;
381
+ - the `format` of a contract source (`ContractSourceProvider`, as the config loaders return it).
382
+
383
+ What to do:
384
+
385
+ - Where code checks every value, with a `switch` or a `const unreachable: never = value` assignment, add a `default` branch. To keep the compiler's check that every kind the code knows is handled, assign the value there to `FutureCase` in place of `never`, as in `const later: FutureCase = value.kind`: a kind the code forgets is still a compile error. If your extension hands applications any of these sets, re-export the two helper types from every entry of the extension, as Prisma's own extensions do, since an entry can reach a set through types it does not name: `export type { FutureCase, NonExhaustive } from '@prisma/orm-framework/utils/types'`. Without it, an application file that imports only your extension and exports a value taken from such a set fails declaration emit with TS2742 under pnpm.
386
+ - An extension does not release with Prisma, so after an application upgrades Prisma the extension can be handed a value it does not know. In the `default` branch, refuse with the extension's own ordinary error, naming the unknown value and saying the extension needs a newer release, and never treat it as one of the values it knows.
387
+ - For `ContractSourceProvider`'s `format`, branch on `'psl'` and `'typescript'` by name, and treat any other format as one the integration does not read, never as TypeScript.
388
+ - A `describeUnsupportedAttribute` that reads `owner.node` first checks that `owner.kind` is `'model'`, `'compositeType'` or `'mixin'`, since the new member has no `node`.
389
+ detection:
390
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
391
+ matches:
392
+ - '\b(?:ArgType|InspectableArgType|UnsupportedAttribute|UnresolvedTypeReference|describeUnsupportedAttribute|ParsedWrittenScalar|ReadRefusal|temporalToText|PostgresExtensionSchemaNode|IncludeCombineBranch|decodeContext|aliasSource)\b'
393
+ - '\.objectType\b'
394
+ - '\b(?:TaggedLiteralCanonicalization|describeTaggedLiteralFailure|canonicalizeTaggedLiteralBody|WrittenScalarResult|readWrittenScalar|GeneratorFunctionResolution|SpaceSignOutcome|SpaceSignConflict|signSpaces|FailedTypeChange|DatabasePolicyDifference|ContractSourceProvider|loadConfig|loadConfigForFile|loadConfigForSections)\b'
395
+ - id: stored-files-format-version
396
+ summary: |
397
+ Every file Prisma stores now names its format version. An extension's bundled `contract.json`, and each contract snapshot under `migrations/snapshots/<hash>/`, has `"formatVersion": 1` where it had `"schemaVersion": "1"`. Every `migration.json` and `migrations/refs/head.json` starts with `"formatVersion": 1`. Until `8.0.0`, a release still reads a bundled `migration.json` or head ref without it, as the format a release candidate wrote. A bundled contract or snapshot a release candidate wrote stores what it requires as `capabilities`, which this release refuses until the `contract-hash-inputs` step of this release rewrites it. `8.0.0` refuses such a file, with `CONTRACT.FORMAT_VERSION_MISSING` or `MIGRATION.FORMAT_VERSION_MISSING`, so an extension published without it fails to load there. Run the colocated script on the extension package, rebuild and republish before `8.0.0`. No hash changes.
398
+ detection:
399
+ glob: "**/*.json"
400
+ matches:
401
+ - '"schemaVersion"\s*:\s*"1"[\s\S]*"targetFamily"\s*:|"targetFamily"\s*:[\s\S]*"schemaVersion"\s*:\s*"1"'
402
+ - '(?<![\s\S])(?![\s\S]*"formatVersion")[\s\S]*"migrationHash"\s*:'
403
+ - '(?<![\s\S])(?![\s\S]*"formatVersion")(?=[\s\S]*"hash"\s*:)[\s\S]*"invariants"\s*:'
404
+ script: ./scripts/stored-files-format-version/stored-files-format-version.ts
405
+ - id: descriptor-self-consistency-takes-contract-json
406
+ summary: |
407
+ `assertDescriptorSelfConsistency`, from `@prisma/orm-postgres/migration-tools/spaces` (and the same path in the other facades and `@prisma/orm-toolchain`), takes the bundled contract as `contractJson` instead of its `target`, `targetFamily` and `storage`. It reads the contract's format version first.
408
+ detection:
409
+ glob: "**/*.{ts,mts,cts,tsx}"
410
+ matches:
411
+ - '\bassertDescriptorSelfConsistency\s*\('
412
+ - id: contract-space-from-json-reads-stored-files
413
+ summary: |
414
+ `contractSpaceFromJson`, from `@prisma/orm-postgres/migration-tools/spaces` (and the same path in the other facades and `@prisma/orm-toolchain`), takes the extension's id as `spaceId`, which its errors name, and reads its `contractJson`, each migration's `metadata` and its `headRef` as the stored files they are: each is read through its `formatVersion` (until `8.0.0`, a file a release candidate wrote without it is still read), and a `migration.json` or head ref in format version 1 with a field it does not know is refused. `headRef` is typed `unknown`; pass the imported `refs/head.json`, not an object built in code.
415
+ detection:
416
+ glob: "**/*.{ts,mts,cts,tsx}"
417
+ matches:
418
+ - '\bcontractSpaceFromJson\s*[<(]'
419
+ - id: canonicalize-contract-takes-version-from-serializer
420
+ summary: |
421
+ `canonicalizeContract` and `canonicalizeContractToObject`, from `@prisma/orm-framework/contract/hashing` (and `contract/hashing` in each facade), no longer take a `schemaVersion` option and write no version of their own. The canonical contract carries the `formatVersion` that the `serializeContract` you pass returns.
422
+ detection:
423
+ glob: "**/*.{ts,mts,cts,tsx}"
424
+ matches:
425
+ - '\bcanonicalizeContract(ToObject)?\s*\([\s\S]*?\bschemaVersion\s*:'
426
+ - id: contract-serializer-prints-version-1
427
+ summary: |
428
+ A target's contract serializer that extends `SqlContractSerializerBase` (from `@prisma/orm-family-sql/family/ir`) or `MongoContractSerializerBase` (from `@prisma/orm-family-mongo/family/ir`) overrides the protected `printContractV1` where it overrode `serializeContract`. The base class's `serializeContract` adds `formatVersion: 1` around what `printContractV1` returns, and `deserializeContract` reads the version before it parses the rest.
429
+ detection:
430
+ glob: "**/*.{ts,mts,cts,tsx}"
431
+ matches:
432
+ - '\boverride\s+serializeContract\s*\('
433
+ - id: contract-hash-inputs
434
+ summary: |
435
+ Every storage, profile and execution hash takes a new value, once: each now covers only its own section of the contract, and no longer the target or the family, and the rules that compute them do not change again within Prisma 8. An extension bundles its contract, migrations, head ref and snapshots with the old hashes, and this release refuses to load it. Run the colocated script on the extension package, rebuild, and publish a new version, with no new migration in it. The script also renames each contract's `capabilities` to `requiredCapabilities`, with keys prefixed by who provides them (`db.` or `conn.`), which this release requires.
436
+ script: ./scripts/contract-hash-inputs/contract-hash-inputs.ts
437
+ ---
438
+
439
+ # 8.0.0-rc.25 → 8.0.0-rc.26 — Extension author upgrade instructions
440
+
441
+ This release changes every hash Prisma stores, so an extension built for an earlier release does not load in it, and this release's version of the extension does not load in an earlier one. Publish a new version of the extension for this release, with no new migration in it.
442
+
443
+ ## Order of the steps
444
+
445
+ Make the changes below in this order, and skip a step that does not apply to the extension:
446
+
447
+ 1. Fix `package.json` before you run the install: move every `@prisma/orm-*` package the extension's shipped code uses to `peerDependencies`, and list it under `devDependencies` too, at `8.0.0-rc.26` (`prisma-packages-are-peer-dependencies`). Move the `prisma` package the extension builds with to `8.0.0-rc.37` or later, the first release built on this one; an earlier `prisma` runs the toolchain of `8.0.0-rc.25` beside this release's packages. Once the bundled files are upgraded, its commands fail with `CONTRACT.VALIDATION_FAILED` and "The contract file has no format version": that is this release's `CONTRACT.FORMAT_VERSION_MISSING` error, which the old toolchain reports under its own code. Then install.
448
+ 2. Run the three scripts that rewrite import paths and names, in this order, and make the changes by hand that each one lists: `facade-paths-an-application-uses`, then `platform-paths-an-extension-uses`, then `contract-signature-names` (`contract-signature-flag` and the entries after it). Each later script reads what the earlier one wrote. Then change the imports of the PostgreSQL client's parts to their Early Access names (`postgres-client-parts-early-access-names`, `sql-prepared-query-early-access-names`), and any value imported from a database package's `contract-types` (`contract-types-exports-types-only`). Until step 5 emits the contract, its `contract.d.ts` still has the old shape, so a type check before then also reports errors that name the contract's `capabilities` or `requiredCapabilities`; do not fix those by hand.
449
+ 3. Make the code changes, in any order: capabilities (`extension-code-reads-required-capabilities`, `required-capabilities-as-list`, `extension-descriptor-declares-no-capabilities`, `extension-capability-flags-removed`, `extension-client-goes-by-the-contract`, `extension-capability-exports-moved`), data types and index types (`data-type-param-keys` and the entries after it, `index-type-options-standard-schema`, `extension-index-types-checked-for-prisma-schemas`), the control API's contract resolvers (`control-api-ref-resolution-takes-migration-dir`), the database's config and Prisma's tables (`read-the-database-config`, `policy-helpers-renamed`, `name-the-prisma-schema`, `prisma-tables-api-breaks`, `sqlite-prisma-tables-renamed`, `sqlite-prisma-tables-api-breaks`), MongoDB and migration calls (`kept-enum-member-route-removed`, `mongo-runner-checked-policies-renamed`, `extension-migration-calls-use-framework-interface`), the ORM client (`fragment-on-the-client`, `aggregate-operation-names-after-8-0`, `orm-fns-comparison-takes-field-input-type`, `update-all-explicit-type-argument`, `prepared-declaration-param-spec-can-be-a-list`), sets of values that may grow (`extension-middleware-handles-later-activities`, `extension-switches-over-later-values`, `extension-more-open-sets-of-values`), and the stored-file APIs (`descriptor-self-consistency-takes-contract-json`, `contract-space-from-json-reads-stored-files`, `canonicalize-contract-takes-version-from-serializer`, `contract-serializer-prints-version-1`).
450
+ 4. On PostgreSQL, write the list of capabilities the extension's contract requires (`extension-contract-lists-required-capabilities`, its step 1). Do not run `prisma contract emit` yet.
451
+ 5. Bring the bundled files up to date: run the `stored-files-format-version` script, then the `contract-hash-inputs` script, then `prisma contract emit` once. That one emit also covers `extension-stored-contract-needs-the-upgrade-script`. If the emitted contract's storage hash differs from the one the script printed, follow `contract-hash-inputs` under "When the emitted contract gets a different storage hash". Then build, run the tests, sign each test database again (`extension-contract-lists-required-capabilities`, its step 4), and publish a new version with no new migration.
452
+
453
+ ## Every Prisma package an extension uses is a peer dependency
454
+
455
+ ### `prisma-packages-are-peer-dependencies`
456
+
457
+ An extension used to hold `@prisma/orm-framework`, its family (`@prisma/orm-family-sql` or `@prisma/orm-family-mongo`) and `@prisma/orm-toolchain` as ordinary dependencies, and only the target, such as `@prisma/orm-target-postgres`, as a peer dependency. Now every `@prisma/orm-*` package it uses is a peer dependency. The application lists those packages itself, beside its database package, and a package manager never gives a package its own copy of a peer dependency, so the extension shares the application's one copy of each. A version that does not match the application's is reported at install, instead of becoming a second copy whose values the application's copy does not recognise. When the packages that disagree are ones the application lists itself, npm refuses the install, and pnpm, Yarn and Bun install and print a peer dependency warning. A successful install does not prove the versions match, so read the peer warnings it prints. A monorepo whose applications are on different Prisma versions can still get two copies under npm workspaces and Bun's hoisted linker; keep such applications on one version, or use pnpm, Yarn or Bun's isolated linker.
458
+
459
+ In the extension's `package.json`, for every `@prisma/orm-*` entry under `dependencies` or `optionalDependencies`, an `@prisma/orm-extension-*` package included:
460
+
461
+ 1. Move it to `peerDependencies`, keeping its exact version.
462
+ 2. Add the same entry, at the same version, to `devDependencies`, so the extension's own build and tests install it. Add any entry already under `peerDependencies` to `devDependencies` too, if it is not there.
463
+
464
+ A package of ours that only the extension's tests use, such as a database package the tests run against, stays under `devDependencies` alone, at the same version; it is not a peer.
465
+
466
+ Before:
467
+
468
+ ```json
469
+ "dependencies": {
470
+ "@prisma/orm-family-sql": "8.0.0-rc.26",
471
+ "@prisma/orm-framework": "8.0.0-rc.26",
472
+ "@prisma/orm-toolchain": "8.0.0-rc.26"
473
+ },
474
+ "peerDependencies": {
475
+ "@prisma/orm-target-postgres": "8.0.0-rc.26"
476
+ }
477
+ ```
478
+
479
+ After:
480
+
481
+ ```json
482
+ "devDependencies": {
483
+ "@prisma/orm-family-sql": "8.0.0-rc.26",
484
+ "@prisma/orm-framework": "8.0.0-rc.26",
485
+ "@prisma/orm-target-postgres": "8.0.0-rc.26",
486
+ "@prisma/orm-toolchain": "8.0.0-rc.26"
487
+ },
488
+ "peerDependencies": {
489
+ "@prisma/orm-family-sql": "8.0.0-rc.26",
490
+ "@prisma/orm-framework": "8.0.0-rc.26",
491
+ "@prisma/orm-target-postgres": "8.0.0-rc.26",
492
+ "@prisma/orm-toolchain": "8.0.0-rc.26"
493
+ }
494
+ ```
495
+
496
+ Leave out a `dependencies` field that ends up empty. Then reinstall. The extension's code does not change.
497
+
498
+ ## The database packages publish only what an application uses
499
+
500
+ ### `facade-paths-an-application-uses`
501
+
502
+ #### What changed
503
+
504
+ From release 8.0 every path a Generally Available Prisma package publishes is kept until 9.0 (see [the versioning policy](https://github.com/prisma/orm/blob/v8.0.0-rc.26/docs/oss/versioning.md) for each package's level). So each database package (`@prisma/orm-postgres`, `@prisma/orm-sqlite`, `@prisma/orm-mysql`, `@prisma/orm-mariadb`, `@prisma/orm-mongo`) now publishes only what applications and generated files import, where it used to forward the platform packages whole. An extension builds on the platform packages, the packages a database package is built from, and each removed path is still published by one of them, under its own name:
505
+
506
+ - `@prisma/orm-framework`: the contract types, the components and the general helpers.
507
+ - `@prisma/orm-family-sql`, or `@prisma/orm-family-mongo` for MongoDB: the database family's contract, query and migration code.
508
+ - `@prisma/orm-target-<database>`, such as `@prisma/orm-target-postgres`: the target, adapter and driver of one database.
509
+ - `@prisma/orm-toolchain`: the command-line tooling, such as the migration tools.
510
+
511
+ This guide's script rewrites each import of a removed path to the platform package. The application guide has a script of the same file name, which sends a few imports to the database package's own modules instead. The folder each sits in, `upgrading/app/` or `upgrading/extension/`, tells them apart.
512
+
513
+ #### Where the guide and its script are
514
+
515
+ This guide is part of the `prisma-8` skill. The skill ships inside the database package; after you install the new version, `prisma skills sync` copies it into the agent skills folder of each harness the project uses: `.agents/skills/prisma-8/`, `.claude/skills/prisma-8/`, `.cursor/skills/prisma-8/` or `.windsurf/skills/prisma-8/`. Any one of these copies will do. The script sits beside this guide in that copy, for example:
516
+
517
+ ```text
518
+ .agents/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/facade-paths-an-application-uses/facade-paths-an-application-uses.ts
519
+ ```
520
+
521
+ Run it from that copy, not from the one under `node_modules/@prisma/orm-<database>/skills/`: Node does not strip types from a file under `node_modules`, so it refuses to run the script there. You need Node.js 24 or later, which Prisma 8 already requires; it runs the TypeScript file directly. It may print an `ExperimentalWarning` about type stripping, which is harmless.
522
+
523
+ The script works on the folder you give it, or on the working directory, and every folder below it except `node_modules`, `dist`, `build` and folders whose name starts with a dot. In a monorepo, one run at the repository root covers every package in it; a run in each package that imports Prisma works too.
524
+
525
+ #### Run the script
526
+
527
+ Commit your work first, so the script's changes can be reviewed and undone with git. Then run the script from the folder that holds the skills copy, usually the extension root, and give it the folder to work on; `.` is the working directory, which is also the default. With the copy in `.agents/`:
528
+
529
+ ```sh
530
+ node .agents/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/facade-paths-an-application-uses/facade-paths-an-application-uses.ts .
531
+ ```
532
+
533
+ With another copy, replace `.agents` with `.claude`, `.cursor` or `.windsurf`. The script prints each file it changed. For example:
534
+
535
+ ```ts
536
+ // before
537
+ import { extractCodecLookup } from '@prisma/orm-postgres/components/control';
538
+ import postgresPack from '@prisma/orm-postgres/target/pack';
539
+
540
+ // after the script
541
+ import { extractCodecLookup } from '@prisma/orm-framework/components/control';
542
+ import postgresPack from '@prisma/orm-target-postgres/target/pack';
543
+ ```
544
+
545
+ #### Change by hand what the script cannot
546
+
547
+ ##### Move the paths the database package still publishes
548
+
549
+ The script leaves a path the database package still publishes. In the extension's own code, change each one by hand to the platform path that owns it, from the reference below. Both names reach the same module, but an extension that names the database package depends on it, and the database package is the application's choice. Move a `vi.mock(…)` or `require.resolve(…)` of the path with its import, so they still name one module:
550
+
551
+ ```ts
552
+ // before
553
+ import type { Char } from '@prisma/orm-postgres/target/codec-types';
554
+ import { delegatingRuntime } from '@prisma/orm-postgres/family-runtime';
555
+ vi.mock('@prisma/orm-postgres/family-runtime');
556
+
557
+ // after
558
+ import type { Char } from '@prisma/orm-target-postgres/target/codec-types';
559
+ import { delegatingRuntime } from '@prisma/orm-family-sql/runtime';
560
+ vi.mock('@prisma/orm-family-sql/runtime');
561
+ ```
562
+
563
+ This command lists every string in the extension's own code that names the database package, imports and mocks alike:
564
+
565
+ ```sh
566
+ grep -rnE --include='*.ts' --include='*.mts' --include='*.cts' --include='*.tsx' --include='*.js' --include='*.mjs' --include='*.cjs' --include='*.jsx' --exclude-dir=node_modules --exclude-dir=dist --exclude-dir=build --exclude-dir='.?*' \
567
+ "['\"\`]@prisma/orm-(postgres|sqlite|mysql|mariadb|mongo)['\"\`/]" *
568
+ ```
569
+
570
+ A hit in a file Prisma generated, such as a `contract.d.ts`, stays.
571
+
572
+ An extension wraps the database package's client when it builds its own client from the database package's Early Access parts, the names that start with `ea_` or `Ea_`, as `@prisma/orm-extension-supabase` does: it takes `ea_buildPostgresQueryMembers`, `ea_connectWithBinding` and others from `@prisma/orm-postgres/runtime`, and `ea_buildPostgresStaticContext` and `ea_validatePostgresContract` from `@prisma/orm-postgres/static`. Such an extension keeps the database package as a peer dependency, and its imports of those parts stay. The script still rewrites the removed paths in it.
573
+
574
+ ##### Mocks
575
+
576
+ Nothing to do: this script sends a `vi.mock(…)` or `require.resolve(…)` of a removed path to the same platform path as an `import` of it.
577
+
578
+ #### List the platform packages in `package.json`
579
+
580
+ An extension that does not yet list the platform packages as peer dependencies applies the `prisma-packages-are-peer-dependencies` change in this guide first. Its search below is still needed afterwards: the script's imports may name a platform package that change did not add.
581
+
582
+ The script's imports name platform packages, so the extension must list each one it now imports. This command prints the packages the code names; in a monorepo, run it in each package:
583
+
584
+ ```sh
585
+ grep -rnoE --include='*.ts' --include='*.mts' --include='*.cts' --include='*.tsx' --include='*.js' --include='*.mjs' --include='*.cjs' --include='*.jsx' --exclude-dir=node_modules --exclude-dir=dist --exclude-dir=build --exclude-dir='.?*' \
586
+ '@prisma/orm-(framework|family-sql|family-mongo|target-[a-z]+|toolchain)' * \
587
+ | sed 's/.*://' | sort -u
588
+ ```
589
+
590
+ Add each one that `package.json` does not list yet to both `peerDependencies`, so the extension shares the application's copy, and `devDependencies`, so its own build and tests install it, then reinstall. On the release candidates every package has the database package's version, as the `prisma-packages-are-peer-dependencies` change in this guide says:
591
+
592
+ ```json
593
+ "peerDependencies": {
594
+ "@prisma/orm-family-sql": "<version of @prisma/orm-family-sql>",
595
+ "@prisma/orm-framework": "<version of @prisma/orm-framework>"
596
+ },
597
+ "devDependencies": {
598
+ "@prisma/orm-family-sql": "<version of @prisma/orm-family-sql>",
599
+ "@prisma/orm-framework": "<version of @prisma/orm-framework>"
600
+ }
601
+ ```
602
+
603
+ Without them, the type check below reports `TS2307 Cannot find module` for paths that are published.
604
+
605
+ When the extension's own code no longer imports the database package, remove it from `peerDependencies`, and keep it under `devDependencies` if the extension's tests run against it. Files Prisma generated for the tests, such as a test's `contract.d.ts`, import the database package and need no change.
606
+
607
+ An extension with a generated contract does not need the database package for it. Point the emitted `contract.d.ts` at a module of the extension's own: name it in the config's contract entry, map that name in `package.json` `imports`, and make the module re-export the platform packages' types. Then re-emit the contract. The PostgreSQL extensions pgvector, PostGIS and citext are set up this way in their repository.
608
+
609
+ ```ts
610
+ // prisma.config.ts
611
+ import { typescriptContract } from '@prisma/orm-family-sql/contract-ts/config-types';
612
+
613
+ contract: {
614
+ ...typescriptContract(contract, 'src/contract.json'),
615
+ typesModule: '#contract-types',
616
+ },
617
+ ```
618
+
619
+ ```json
620
+ "imports": {
621
+ "#contract-types": "./src/contract-types.ts"
622
+ }
623
+ ```
624
+
625
+ ```ts
626
+ // src/contract-types.ts
627
+ export type {
628
+ Contract,
629
+ ExecutionHashBase,
630
+ FieldTypesFromDomain,
631
+ NamespaceId,
632
+ ProfileHashBase,
633
+ StorageHashBase,
634
+ ValueObjectTypesFromStorage,
635
+ } from '@prisma/orm-framework/contract/types';
636
+ export type {
637
+ ColumnTypesFromStorage,
638
+ ContractWithTypeMaps,
639
+ RelationKeys,
640
+ TypeMaps,
641
+ } from '@prisma/orm-family-sql/contract/types';
642
+ ```
643
+
644
+ What the extension publishes decides what else it needs:
645
+
646
+ - If its bundler inlines the contract's types into its built files, as pgvector, PostGIS and citext do, the published package contains no `contract.d.ts` and needs neither the module nor the `imports` entry. Their published `package.json` lists only `dist` in `files` and has no `imports`.
647
+ - If its published files include a `contract.d.ts` that imports `#contract-types`, it must publish the module that name maps to, listed in `files` and built to a `.d.ts` if the source is not shipped, and keep the `imports` entry in its published `package.json`. Otherwise its users' builds fail to resolve the import.
648
+
649
+ #### Check the result
650
+
651
+ Run this in the folder you ran the script in. It searches the files the script reads, outside folders whose name starts with a dot, for a path the database packages no longer publish. This command lists every `@prisma/orm-<database>/…` path in them, then drops the paths each database package still publishes:
652
+
653
+ ```sh
654
+ grep -rnoE --include='*.ts' --include='*.mts' --include='*.cts' --include='*.tsx' --include='*.js' --include='*.mjs' --include='*.cjs' --include='*.jsx' --exclude-dir=node_modules --exclude-dir=dist --exclude-dir=build --exclude-dir='.?*' \
655
+ '@prisma/orm-(postgres|sqlite|mysql|mariadb|mongo)/[A-Za-z0-9_./$-]*' * \
656
+ | grep -vE ':@prisma/orm-postgres/(adapter/column-types|builder/runtime|builder/types|components/runtime|config|contract-builder|contract-types|contract/types|control|family|family-contract/types|family-runtime|family/control|init|migration|migration-tools/aggregate|migration-tools/hash|migration-tools/io|migration-tools/spaces|orm-client|package.json|runtime|serverless|static|target|target/codec-ids|target/codec-types|target/full-text|target/migration|target/operation-types|target/planner-target-details|target/runtime|vite-plugin-contract-emit)$|:@prisma/orm-sqlite/(adapter/codec-types|adapter/column-types|builder/runtime|builder/types|components/runtime|config|contract-builder|contract-types|contract/types|control|family-contract/types|family-runtime|family/control|init|migration|migration-tools/aggregate|migration-tools/hash|migration-tools/io|migration-tools/spaces|orm-client|package.json|runtime|static|target/codec-ids|target/codec-types|target/migration|target/planner-target-details|target/runtime|vite-plugin-contract-emit)$|:@prisma/orm-mysql/(adapter/codec-types|builder/runtime|builder/types|components/runtime|config|contract-builder|contract-types|contract/types|control|define-contract|family-contract/types|family-runtime|family/control|init|migration|migration-tools/aggregate|migration-tools/hash|migration-tools/io|migration-tools/spaces|orm-client|package.json|runtime|static|target/codec-ids|target/codec-types|target/migration|target/runtime|vite-plugin-contract-emit)$|:@prisma/orm-mariadb/(adapter/codec-types|builder/runtime|builder/types|components/runtime|config|contract-builder|contract-types|contract/types|control|family-contract/types|family-runtime|family/control|migration|migration-tools/aggregate|migration-tools/hash|migration-tools/io|migration-tools/spaces|orm-client|package.json|runtime|static|target/migration|target/runtime|vite-plugin-contract-emit)$|:@prisma/orm-mongo/(bson|components/runtime|config|contract-builder|contract-types|contract/types|control|family|family-contract|family-runtime|family/control|init|migration|migration-tools/aggregate|migration-tools/hash|migration-tools/io|migration-tools/spaces|orm|package.json|query-ast/execution|query-builder|runtime|static|target|target/codec-ids|target/codec-types|target/migration|target/runtime|value|vite-plugin-contract-emit)$'
657
+ ```
658
+
659
+ Each line it prints is a file, a line and a path that is no longer published. A template literal with `${…}` in it shows as a path that ends at `$`, and a path built from parts shows as its first part. Change each one by the reference below. Two kinds of line the reference does not cover:
660
+
661
+ - `@prisma/orm-postgres/adapter/operation-types` in a stored migration snapshot comes from a release before `8.0.0-rc.12`, which removed that path. The script leaves it. Leave it too, or point it at `@prisma/orm-postgres/target/operation-types`.
662
+ - An `@prisma/orm-postgres/internal/…` path, or a `family-runtime/internal/prepared-query` path, belongs to the `postgres-client-parts-early-access-names` change in this guide.
663
+
664
+ Then run the type check, such as `tsc --noEmit`: an import of a path that is no longer published fails with `TS2307 Cannot find module`.
665
+
666
+
667
+ #### Reference
668
+
669
+ ##### The paths that stay
670
+
671
+ Each database package still publishes these paths, and the script leaves them. The bare `target` and `family` exist only on PostgreSQL and MongoDB: each default-exports a pack, the object that describes the target or the family to the contract builder, `target` the database's and `family` its family's. `package.json` always stays. MariaDB has no `init`, the module `prisma orm init` loads for a database: its package does not publish one, so the missing `yes` is not a mistake.
672
+
673
+ | Path | PostgreSQL | SQLite | MySQL | MariaDB | MongoDB |
674
+ | --- | --- | --- | --- | --- | --- |
675
+ | `adapter/codec-types` | | yes | yes | yes | |
676
+ | `adapter/column-types` | yes | yes | | | |
677
+ | `bson` | | | | | yes |
678
+ | `builder/runtime` | yes | yes | yes | yes | |
679
+ | `builder/types` | yes | yes | yes | yes | |
680
+ | `components/runtime` | yes | yes | yes | yes | yes |
681
+ | `config` | yes | yes | yes | yes | yes |
682
+ | `contract-builder` | yes | yes | yes | yes | yes |
683
+ | `contract-types` | yes | yes | yes | yes | yes |
684
+ | `contract/types` | yes | yes | yes | yes | yes |
685
+ | `control` | yes | yes | yes | yes | yes |
686
+ | `define-contract` | | | yes | | |
687
+ | `family` | yes | | | | yes |
688
+ | `family-contract` | | | | | yes |
689
+ | `family-contract/types` | yes | yes | yes | yes | |
690
+ | `family-runtime` | yes | yes | yes | yes | yes |
691
+ | `family/control` | yes | yes | yes | yes | yes |
692
+ | `init` | yes | yes | yes | | yes |
693
+ | `migration` | yes | yes | yes | yes | yes |
694
+ | `migration-tools/aggregate` | yes | yes | yes | yes | yes |
695
+ | `migration-tools/hash` | yes | yes | yes | yes | yes |
696
+ | `migration-tools/io` | yes | yes | yes | yes | yes |
697
+ | `migration-tools/spaces` | yes | yes | yes | yes | yes |
698
+ | `orm` | | | | | yes |
699
+ | `orm-client` | yes | yes | yes | yes | |
700
+ | `query-ast/execution` | | | | | yes |
701
+ | `query-builder` | | | | | yes |
702
+ | `runtime` | yes | yes | yes | yes | yes |
703
+ | `serverless` | yes | | | | |
704
+ | `static` | yes | yes | yes | yes | yes |
705
+ | `target` | yes | | | | yes |
706
+ | `target/codec-ids` | yes | yes | yes | | yes |
707
+ | `target/codec-types` | yes | yes | yes | | yes |
708
+ | `target/full-text` | yes | | | | |
709
+ | `target/migration` | yes | yes | yes | yes | yes |
710
+ | `target/operation-types` | yes | | | | |
711
+ | `target/planner-target-details` | yes | yes | | | |
712
+ | `target/runtime` | yes | yes | yes | yes | yes |
713
+ | `value` | | | | | yes |
714
+ | `vite-plugin-contract-emit` | yes | yes | yes | yes | yes |
715
+
716
+ ##### What the script writes
717
+
718
+ The script:
719
+
720
+ - rewrites only a path that release `8.0.0-rc.25` published and this change removes. It leaves every other path: one an older release removed, and the `internal/…` paths that the `postgres-client-parts-early-access-names` change in this guide removes.
721
+ - changes every string that is exactly such a path, in single quotes, double quotes, or backticks with nothing interpolated, wherever it is in the file, and edits nothing else.
722
+ - cannot rewrite a path built from parts.
723
+
724
+ The paths below are under `@prisma/orm-<database>/`, and each row skips the paths that stay.
725
+
726
+ | Removed path | Its replacement | Example |
727
+ | --- | --- | --- |
728
+ | under `adapter/`, `driver/` and `target/` | the same path in `@prisma/orm-target-<database>` | `@prisma/orm-postgres/target/types` becomes `@prisma/orm-target-postgres/target/types`; `@prisma/orm-mariadb/adapter/control` becomes `@prisma/orm-target-mariadb/adapter/control` |
729
+ | under `components/`, `contract/` and `utils/` | the same path in `@prisma/orm-framework` | `@prisma/orm-postgres/utils/casts` becomes `@prisma/orm-framework/utils/casts` |
730
+ | under `family-contract/` | the family package, with `family-contract` renamed to `contract`; `canonicalization-hooks` goes to `contract/normal-form`, its name in this release, where `normalizeSqlStorage` or `normalizeMongoStorage` replaces the old hooks object (see the `contract-hash-inputs` change) | `@prisma/orm-postgres/family-contract/index-types` becomes `@prisma/orm-family-sql/contract/index-types`; `@prisma/orm-mongo/family-contract/data-type` becomes `@prisma/orm-family-mongo/contract/data-type` |
731
+ | under `family/` | the same path in `@prisma/orm-family-sql`, or `@prisma/orm-family-mongo` for MongoDB | `@prisma/orm-postgres/family/pack` becomes `@prisma/orm-family-sql/family/pack`; `@prisma/orm-mongo/family/ir` becomes `@prisma/orm-family-mongo/family/ir` |
732
+ | under `builder/`, `relational-core/` and `schema-ir/` (PostgreSQL, SQLite, MySQL and MariaDB) | the same path in `@prisma/orm-family-sql` | `@prisma/orm-sqlite/relational-core/plan` becomes `@prisma/orm-family-sql/relational-core/plan` |
733
+ | under `query-ast/`, `query-builder/` and `value/` (MongoDB) | the same path in `@prisma/orm-family-mongo` | `@prisma/orm-mongo/query-ast/control` becomes `@prisma/orm-family-mongo/query-ast/control` |
734
+ | `migration-tools/contract-snapshot-store` | the same path in `@prisma/orm-toolchain` | `@prisma/orm-postgres/migration-tools/contract-snapshot-store` becomes `@prisma/orm-toolchain/migration-tools/contract-snapshot-store`. The `platform-paths-an-extension-uses` change, in the same release, then stops publishing that path; its guide says what to do |
735
+
736
+ A row also covers its folder's own path, with no subpath, where the database package published one:
737
+
738
+ - On PostgreSQL, SQLite, MySQL and MariaDB: `adapter`, `builder`, `components`, `contract`, `driver`, `family-contract`, `relational-core` and `utils`.
739
+ - On MongoDB: `adapter`, `components`, `contract`, `driver`, `query-ast` and `utils`.
740
+
741
+ ##### The platform path that owns each path that stays
742
+
743
+ | Path that stays, under `@prisma/orm-<database>/` | The platform path that owns it |
744
+ | --- | --- |
745
+ | `adapter/codec-types`, `adapter/column-types` | the same path in `@prisma/orm-target-<database>` |
746
+ | `target/codec-ids`, `target/codec-types`, `target/full-text`, `target/migration`, `target/operation-types`, `target/planner-target-details`, `target/runtime` | the same path in `@prisma/orm-target-<database>` |
747
+ | the bare `target`, imported for its default (PostgreSQL and MongoDB) | `@prisma/orm-target-<database>/target/pack` |
748
+ | the bare `family`, imported for its default (PostgreSQL and MongoDB) | `@prisma/orm-family-sql/family/pack`, or `@prisma/orm-family-mongo/family/pack` |
749
+ | `builder/runtime`, `builder/types`, `orm-client`, `relational-core/ast` | the same path in `@prisma/orm-family-sql` |
750
+ | `family/control` | `@prisma/orm-family-sql/family/control`, or `@prisma/orm-family-mongo/family/control` |
751
+ | `family-contract/types` (PostgreSQL, SQLite, MySQL and MariaDB), the bare `family-contract` (MongoDB) | `@prisma/orm-family-sql/contract/types`, or `@prisma/orm-family-mongo/contract` |
752
+ | `family-runtime` | `@prisma/orm-family-sql/runtime`, or `@prisma/orm-family-mongo/runtime` |
753
+ | `orm`, `query-builder`, `query-ast/execution`, `value` (MongoDB) | the same path in `@prisma/orm-family-mongo` |
754
+ | `components/runtime`, `contract/types` | the same path in `@prisma/orm-framework` |
755
+ | `migration-tools/aggregate`, `migration-tools/hash`, `migration-tools/io`, `migration-tools/spaces`, `vite-plugin-contract-emit` | the same path in `@prisma/orm-toolchain` |
756
+ | `migration` | `@prisma/orm-target-<database>/target/migration`; on MariaDB, `@prisma/orm-target-mysql/target/migration`, with `Migration` from `@prisma/orm-target-mariadb/target/migration` |
757
+
758
+ The other paths that stay are the database package's own modules: `config`, `contract-builder`, `contract-types`, `control`, `define-contract`, `init`, `runtime`, `serverless`, `static` and `bson`.
759
+
760
+ `runtime` also re-exports a few names from the platform packages. Import each from its owner:
761
+
762
+ | Database | Name in `runtime` | Its platform owner |
763
+ | --- | --- | --- |
764
+ | PostgreSQL | `param` | `@prisma/orm-family-sql/relational-core/expression` |
765
+ | PostgreSQL | `InteractiveTransactionsCapability` | `@prisma/orm-family-sql/runtime` |
766
+ | PostgreSQL | `PostgresFullTextMethods` | `@prisma/orm-target-postgres/target/full-text` |
767
+ | PostgreSQL | `IsolationLevel` | `postgresIsolationLevels` from `@prisma/orm-target-postgres/target/runtime` |
768
+ | SQLite | `param` | `@prisma/orm-family-sql/relational-core/expression` |
769
+ | SQLite | `IsolationLevel` | `sqliteIsolationLevels` from `@prisma/orm-target-sqlite/target/runtime` |
770
+ | MySQL | `param` | `@prisma/orm-family-sql/relational-core/expression` |
771
+ | MySQL | `MysqlPoolOptions` | `@prisma/orm-target-mysql/driver/runtime` |
772
+ | MySQL | `IsolationLevel` | `mysqlIsolationLevels` from `@prisma/orm-target-mysql/target/runtime` |
773
+ | MariaDB | `param`, `IsolationLevel`, `MariadbPoolOptions` | the MySQL owners above, `MariadbPoolOptions` being `MysqlPoolOptions`; MariaDB's `runtime` takes them from `@prisma/orm-mysql/runtime` |
774
+ | MongoDB | `MongoBinding` | `@prisma/orm-target-mongo/driver/runtime` |
775
+ | every database | `isStructuredError` | `@prisma/orm-framework/utils/structured-error` |
776
+
777
+ The rest of `runtime` is the database package's own, with no platform owner. An extension does not import a database package's own module, unless it wraps that package's client as described above.
778
+
779
+ ## The platform packages publish only the paths extensions use
780
+
781
+ ### `platform-paths-an-extension-uses`
782
+
783
+ #### What changed
784
+
785
+ From release 8.0 every path and name a Generally Available Prisma package publishes is kept until 9.0, except a name that starts with a maturity level (`ea_`, `preview_` or `rc_`, or `Ea_`, `Preview_` or `Rc_` for a type or a class), which may still change in a later release. An Early Access package, such as `@prisma/orm-sqlite`, makes no such promise (see [the versioning policy](https://github.com/prisma/orm/blob/v8.0.0-rc.26/docs/oss/versioning.md)). So the platform packages, the packages an extension builds on, stop publishing the paths that nothing outside their own package imported:
786
+
787
+ - `@prisma/orm-framework`: `contract/resolve-domain-model`, `psl-parser/tokenizer`, and the package-level paths `utils`, `type-implementations` and `target-package-config`. Each module under them, such as `utils/casts`, is still published.
788
+ - `@prisma/orm-family-sql`: `contract/authored-check-naming`, `contract/factories`, `contract/index-type-validation`, `contract/validators`, `contract-emitter`, `contract-psl`, `contract-psl/attribute-specs`, `contract-psl/default-table-name`, `contract-psl/diagnostics`, `relational-core/functions`, `relational-core/middleware`, and the package-level paths `builder`, `contract-ts`, `family` and `schema-ir`.
789
+ - `@prisma/orm-target-postgres`: `adapter/sql-renderer`, `adapter/types`, twenty `target/…` paths, such as `target/planner`, `target/ddl` and `target/op-factory-call`, and the package-level paths `target` and `adapter`.
790
+ - `@prisma/orm-toolchain`: `cli/control-api/testing`, `cli/init-output`, `cli-telemetry`, `cli-telemetry/sender`, `emitter`, `emitter/type-expression-safety`, and seven `migration-tools/…` paths, such as `migration-tools/contract-snapshot-store` and `migration-tools/errors`.
791
+
792
+ Two package-level paths stay but export fewer names: `@prisma/orm-family-sql/contract` and `@prisma/orm-toolchain/migration-tools` now export only the names of the paths their package still publishes.
793
+
794
+ Since release 8.0.0-rc.25, `@prisma/orm-family-sql/contract` no longer exports 41 names. `checkSqlDefaultText` is published at `@prisma/orm-family-sql/family/control`. `sqlContractCanonicalizationHooks` went in the `contract-hash-inputs` change, in the same release, which says what replaces it. These 39 are not published anywhere: `AuthoredCheckInput`, `CheckConstraintSchema`, `CodecTraitsLookup`, `col`, `ColumnDefaultFunctionSchema`, `ColumnDefaultLiteralSchema`, `ColumnDefaultSchema`, `ContractEnumSchema`, `createNamespaceEntrySchema`, `createSqlContractSchema`, `createSqlStorageSchema`, `fk`, `ForeignKeyReferenceSchema`, `ForeignKeySchema`, `ForeignKeySourceSchema`, `index`, `IndexSchema`, `lowerAuthoredCheck`, `model`, `pk`, `ReferentialActionSchema`, `reservedSqlDefaultText`, `resolveSqlToOneRelationStorage`, `SqlToOneRelationStorage`, `StorageTableSchema`, `StorageValueSetSchema`, `table`, `unique`, `validateExecutionDefaultsTargetMappedColumns`, `validateIndexTypes`, `validateModel`, `validateModelStorageReferences`, `validateRelationJoinFields`, `validateSqlContractFully`, `ValidateSqlContractFullyOptions`, `validateSqlStorageConsistency`, `validateStorage`, `validateStorageSemantics`, `valueObjectStorageTypeMissingMessage`.
795
+
796
+ Where a kept path exports the same declaration, the script sends the import there: `Migration` from `@prisma/orm-target-postgres/target` goes to `target/migration`, `RlsPolicyOperation` from `target/ddl` to `target/rls-canonicalize`, `checkSqlDefaultText` from `@prisma/orm-family-sql/contract` to `family/control`, and `createFunctions` from `relational-core/functions` to `@prisma/orm-family-sql/builder/runtime`. About 570 names, such as the PostgreSQL planner, its DDL nodes and the migration graph tools, are no longer published.
797
+
798
+ Some names were also renamed, because "internal" says "not for you" while every published name is promised like any other:
799
+
800
+ | Before | After |
801
+ | --- | --- |
802
+ | `InternalError`, `isInternalError` and `assertNever` from `@prisma/orm-framework/utils/internal-error` | `InvariantError`, `isInvariantError` and `assertNever` from `@prisma/orm-framework/utils/invariant-error` |
803
+ | The `isPrismaInternalError` field of an `InternalError` | The `isPrismaInvariantError` field of an `InvariantError` |
804
+ | `PreparedStatementInternals` from `@prisma/orm-family-sql/runtime` | `LoweredPreparedStatement` |
805
+ | `SqlParamRefMutatorInternal` from `@prisma/orm-family-sql/relational-core` | `SqlRuntimeParamRefMutator` |
806
+ | `MongoParamRefMutatorInternal` from `@prisma/orm-family-mongo/runtime` | `MongoRuntimeParamRefMutator` |
807
+ | `SupabaseInternalDb` from `@prisma/orm-extension-supabase/runtime` | `SupabaseSchemasDb` |
808
+ | `SupabaseExtensionContract` from `@prisma/orm-extension-supabase/runtime` | `SupabaseSchemasContract` |
809
+
810
+ An `InvariantError` from this release has only the new field, and its `name` is `'InvariantError'`, so a check for `isPrismaInternalError` or for `error.name === 'InternalError'` no longer recognises it. To recognise it, call `isInvariantError(error)`.
811
+
812
+ #### Run the scripts
813
+
814
+ The `facade-paths-an-application-uses` change, in the same release, sends imports of removed database-package paths to the platform packages, and some of those paths are removed here. So run its script first, then this one. This guide's script sits beside it in the agent skills copy of the `prisma-8` skill, for example:
815
+
816
+ ```text
817
+ .agents/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/platform-paths-an-extension-uses/platform-paths-an-extension-uses.ts
818
+ ```
819
+
820
+ Commit your work first, so the script's changes can be reviewed and undone with git. Then run it from the folder that holds the skills copy, and give it the folder to work on; `.` is the working directory, which is also the default:
821
+
822
+ ```sh
823
+ node .agents/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/platform-paths-an-extension-uses/platform-paths-an-extension-uses.ts .
824
+ ```
825
+
826
+ As with the other script, run it from the skills copy, not from `node_modules`, with Node.js 24 or later. It reads each file with the project's own TypeScript compiler, so run it in a project whose `typescript` package is installed; if it finds none, it says so and stops without changing any file. It skips `node_modules`, `dist`, `build` and folders whose name starts with a dot.
827
+
828
+ The script:
829
+
830
+ - sends each named import, type-only import and `export { … } from` to the kept path that exports the same declaration, splitting an import whose names now live on different paths:
831
+
832
+ ```ts
833
+ // Before:
834
+ import { createFunctions, type Functions } from '@prisma/orm-family-sql/relational-core/functions';
835
+ // After:
836
+ import { createFunctions } from '@prisma/orm-family-sql/builder/runtime';
837
+ import { type Functions } from '@prisma/orm-family-sql/builder/types';
838
+ ```
839
+ - moves a namespace import, an `export *`, a side-effect import, a dynamic `import()`, a `require` or an `import()` type only when one path publishes everything the old one did. It moves a dynamic `import()` or a `require` and lists it, so you check the names it uses.
840
+ - renames each name in the table above where it came from a Prisma import: the import itself, every use of that binding in the file, and `ns.InternalError` on a namespace binding. A file that does not import it is left alone, even if it has its own name of that spelling.
841
+ - in a file that re-exports a renamed name, keeps the name the file exports (`export { InvariantError as InternalError } from '…/utils/invariant-error'`), so the files that import from it still compile, and lists the file.
842
+ - renames the `isPrismaInternalError` field in a file that imports from a Prisma package, and a check of an error's `name` against `'InternalError'`, in a comparison or a `case`, in a file that imports `InternalError` or `isInternalError` from Prisma. Elsewhere it lists them, because `InternalError` may be the project's own error.
843
+ - prints each file it changed, then, under `Not changed:`, each import it left and each place it wants checked.
844
+
845
+ The script reads only source files. Rename the old names in your Markdown and other docs by hand.
846
+
847
+ #### What the script lists
848
+
849
+ - An import of a name no published path exports any more, such as `planIssues` from `@prisma/orm-target-postgres/target` or `target/issue-planner`, `MigrationToolsError` from `@prisma/orm-toolchain/migration-tools`, `validateSqlContractFully` from `@prisma/orm-family-sql/contract`, `Tokenizer` from `@prisma/orm-framework/psl-parser/tokenizer` or `BuiltinFunctions` from `@prisma/orm-family-sql/relational-core/functions`.
850
+ - A namespace import, an `export *`, a dynamic `import()` or a `require` of a path whose names are no longer published together, and one it moved, so you check the names it uses.
851
+ - A `vi.mock` or `jest.mock` of a path this change moves. Point the mock at the module the code under test now imports, and rename what its factory returns.
852
+ - A file that re-exports a renamed name under its old name. Rename the name where the project imports it, then drop the alias.
853
+ - A check of `name` against `'InternalError'` in a file with no Prisma import of `InternalError`, or of `isPrismaInternalError` in a file that imports nothing from Prisma. If it means Prisma's error, use `isInvariantError`.
854
+ - A `vi.mock` or `jest.mock` with a factory of a kept path that exports a renamed name, such as `@prisma/orm-family-sql/runtime`. Rename what its factory returns.
855
+
856
+ Code that called the emitter or the PSL interpreter directly, usually an extension's test of its own contributions, goes through the control client instead, and the script prints this advice beside each of those names. Give the database package's `defineConfig` the contract: the path of a `.prisma` or `.ts` file, or a contract built in memory, passed through `typescriptContract(contract)` from `@prisma/orm-family-sql/contract-ts/config-types`. Then pass the `source`, `output` and `typesModule` of the config's contract to the control client's `emit`. In a test, the database package is a development dependency:
857
+
858
+ ```ts
859
+ import assert from 'node:assert/strict';
860
+ import { typescriptContract } from '@prisma/orm-family-sql/contract-ts/config-types';
861
+ import { defineConfig } from '@prisma/orm-postgres/config';
862
+ import { createPostgresControlClient } from '@prisma/orm-postgres/control';
863
+ import { contract } from './contract';
864
+
865
+ const config = defineConfig({ contract: typescriptContract(contract) });
866
+ const contractConfig = config.contract;
867
+ assert(contractConfig?.typesModule !== undefined, 'the config has no contract');
868
+
869
+ const client = createPostgresControlClient();
870
+ try {
871
+ const emitted = await client.emit({
872
+ contractConfig: {
873
+ source: contractConfig.source,
874
+ output: contractConfig.output ?? 'contract.json',
875
+ typesModule: contractConfig.typesModule,
876
+ },
877
+ });
878
+ if (!emitted.ok) assert.fail(emitted.failure.summary);
879
+ const { contractJson } = emitted.value;
880
+
881
+ const rendered = await client.renderContractDts({
882
+ contract: JSON.parse(contractJson),
883
+ typesModule: contractConfig.typesModule,
884
+ });
885
+ if (!rendered.ok) assert.fail(rendered.failure.summary);
886
+ } finally {
887
+ await client.close();
888
+ }
889
+ ```
890
+
891
+ The example is for PostgreSQL. Each database package has its own `defineConfig` in `config` and its own control client in `control`; MongoDB takes its `typescriptContract` from its own family package:
892
+
893
+ | Database | Control client | `typescriptContract` from |
894
+ | --- | --- | --- |
895
+ | PostgreSQL | `createPostgresControlClient` from `@prisma/orm-postgres/control` | `@prisma/orm-family-sql/contract-ts/config-types` |
896
+ | SQLite | `createSqliteControlClient` from `@prisma/orm-sqlite/control` | `@prisma/orm-family-sql/contract-ts/config-types` |
897
+ | MySQL | `createMysqlControlClient` from `@prisma/orm-mysql/control` | `@prisma/orm-family-sql/contract-ts/config-types` |
898
+ | MariaDB | `createMariadbControlClient` from `@prisma/orm-mariadb/control` | `@prisma/orm-family-sql/contract-ts/config-types` |
899
+ | MongoDB | `createMongoControlClient` from `@prisma/orm-mongo/control` | `@prisma/orm-family-mongo/contract-ts/config-types` |
900
+
901
+ The script names the project's own database package when its `package.json` lists exactly one. A test of an extension's contributions passes the extension's descriptors as `extensions` to both `defineConfig` and `createPostgresControlClient`. Each removed name maps to a part of this example:
902
+
903
+ | Before | After |
904
+ | --- | --- |
905
+ | `emit(…)` from `@prisma/orm-toolchain/emitter` | the client's `emit`, whose result carries `contractJson` and `contractDts`, the declarations `emit` wrote |
906
+ | `interpretPslDocumentToSqlContract(…)` from `@prisma/orm-family-sql/contract-psl` | the client's `emit`, with the path of the `.prisma` file as the `contract` of `defineConfig` |
907
+ | `generateContractDts(…)` from `@prisma/orm-toolchain/emitter` | the client's `renderContractDts`, given the parsed `contract.json` and the config's `typesModule` |
908
+ | `getEmittedArtifactPaths(…)` from `@prisma/orm-toolchain/emitter` | no call: the `.d.ts` is written beside the `.json`, and its path is the `.json` path with the `.json` extension replaced by `.d.ts` |
909
+
910
+ Every other name that is no longer published was a part of how Prisma builds itself. For a type, write the type your code needs in your own code; for `BuiltinFunctions`, the published `Functions` type from `@prisma/orm-family-sql/builder/types` covers the built-in functions and the extensions' functions together. For a function, copy what your extension uses into it, or open an issue on the Prisma repository that says what you need it for, so we can decide whether to publish it.
911
+
912
+ #### Check the result
913
+
914
+ Type-check and test the extension. A local binding of the same name as a renamed import, such as a parameter destructured as `{ InternalError }`, keeps its name, and so does a member read through a local binding that has the name of a namespace import, such as `errors.InternalError` on a parameter `errors`. Then run the script again: once you have rewritten everything it listed, it changes nothing and lists nothing.
915
+
916
+ ## `contract-types` exports types only
917
+
918
+ ### `contract-types-exports-types-only`
919
+
920
+ `contract-types` is the entry a generated `contract.d.ts` imports its types from. At run time it exports nothing. Its type declarations used to say it also exported runtime values, such as `coreHash` or `CODEC_INSTANCE_KIND`, so this compiled and then failed when the module loaded, with `SyntaxError: The requested module '@prisma/orm-postgres/contract-types' does not provide an export named 'coreHash'`:
921
+
922
+ ```ts
923
+ import { coreHash } from '@prisma/orm-postgres/contract-types';
924
+ ```
925
+
926
+ It now fails to compile: `error TS1362: 'coreHash' cannot be used as a value because it was exported using 'export type'`. Code that worked before still compiles: importing a type, and `typeof coreHash`, are unchanged.
927
+
928
+ In each file the detection matches, look at each import from `contract-types`:
929
+
930
+ - If it imports only types, nothing changes. You may write it as `import type`.
931
+ - If the compiler reports a name in it as a value, import that name from the path of the same database package that exports it. Look for the name in `contract/types`, then in `family-contract/types` (on MongoDB, `family-contract`). No value comes from the codec types entry. Keep the type names in the `contract-types` import.
932
+
933
+ ```ts
934
+ // before
935
+ import { coreHash, type Contract } from '@prisma/orm-postgres/contract-types';
936
+ // after
937
+ import type { Contract } from '@prisma/orm-postgres/contract-types';
938
+ import { coreHash } from '@prisma/orm-postgres/contract/types';
939
+ ```
940
+
941
+ An extension that builds on the platform packages can import the same value from the platform package instead, as the `facade-paths-an-application-uses` script does for the other paths. Run the type checker after that script.
942
+
943
+ ## The contract marker is now the contract signature
944
+
945
+ Each database records, per contract space, which contract it was last signed with: the contract's hashes, when it was signed, and the invariants it holds. Prisma called this record the contract marker; it is now the contract signature, after `db sign`, the command that writes it. Every name the platform packages published with the old word now says signature.
946
+
947
+ If you do nothing:
948
+
949
+ - An extension or target that imports a renamed name, such as `ContractMarkerRecord` or `MarkerDestination`, no longer type-checks, and an import of `@prisma/orm-target-mysql/target/marker-lock` fails to resolve.
950
+ - A target that implements `SqlControlAdapter` or `MongoControlAdapter` no longer implements them: the methods are now `readSignature`, `readAllSignatures`, `initSignature`, `updateSignature` and the others below, and the property `markerLocation` is `signatureLocation`.
951
+ - Code that matches an error code such as `CONTRACT.MARKER_MISSING` stops matching, and a runner that returns `MIGRATION.MARKER_ORIGIN_MISMATCH` or `MIGRATION.MARKER_CAS_FAILURE` (now `MIGRATION.SIGNATURE_ORIGIN_MISMATCH` and `MIGRATION.CONCURRENT_CHANGE`) no longer type-checks against `SqlMigrationRunnerErrorCode` or `MongoMigrationRunnerErrorCode`.
952
+ - A `log` that filters the client's warnings by their scope, `marker-verification`, stops matching them: the scope is now `contract-signature-verification`.
953
+ - In JavaScript, or a project that does not type-check, `verifyMarker: false` on a client is ignored without an error, and the check the client makes on its first use of the database comes back on.
954
+ - A CI step or script that runs `prisma db verify --marker-only` fails.
955
+
956
+ The new word renames no table, column, row, lock name or grant by itself, and a target's own tables keep their names. Other changes of this release do move Prisma's own tables: on PostgreSQL to `prisma.signatures` and `prisma.config` (`name-the-prisma-schema`, `prisma-tables-api-breaks`), and on SQLite to `prisma_signatures`, `prisma_config` and `prisma_ledger` (`sqlite-prisma-tables-renamed`). On MySQL and MariaDB the table is still named `_prisma_marker`.
957
+
958
+ ### `contract-signature-flag`, `contract-signature-error-codes`, `contract-signature-json-fields`, `contract-signature-published-names`
959
+
960
+ #### What changed
961
+
962
+ The flag, the codes, the values and the `--json` fields change as for an application: `db verify --marker-only` is `--signature-only`; the codes `CONTRACT.MARKER_*` and `MIGRATION.MARKER_LOCK_TIMEOUT` and `MIGRATION.MARKER_ORIGIN_MISMATCH` say `SIGNATURE`, `MIGRATION.MARKER_MISMATCH` and `MIGRATION.MARKER_NOT_IN_HISTORY` are one code, `MIGRATION.SIGNATURE_NOT_IN_GRAPH`, and `MIGRATION.MARKER_CAS_FAILURE` is `MIGRATION.CONCURRENT_CHANGE`; `CONTRACT.MARKER_REQUIRED` and `CONFIG.FAMILY_READ_MARKER_REQUIRED` and their factories `errorMarkerRequired` and `errorFamilyReadMarkerSqlRequired` are gone; the `--json` fields `marker` and `markerHash` are `signature` and `signatureHash`; the error values `orphanMarker` and `markerChanged` are `orphanSignature` and `signatureChanged`; the scope of the client's warnings, `marker-verification`, is `contract-signature-verification`. The `meta` of `migration status`'s warning for a signature outside the migration graph names the space as `spaceId`, as `db migrate`'s error with the same code does; it said `space`.
963
+
964
+ The published path `@prisma/orm-target-mysql/target/marker-lock` is `@prisma/orm-target-mysql/target/signature-lock`. A type that stands alone in an import says `ContractSignature`, so it is not read as a function or attribute signature; a member of an interface says `signature`. Each published name below is renamed:
965
+
966
+ | Before | Now |
967
+ | --- | --- |
968
+ | `acquireMarkerLock` | `acquireSignatureLock` |
969
+ | `bootstrapSignMarkerQueries` | `bootstrapSignQueries` |
970
+ | `buildSignMarkerBootstrapQueries` | `buildSignBootstrapQueries` |
971
+ | `contractHashAtMarker` | `contractHashAtSignature` |
972
+ | `ContractMarkerRecord` | `ContractSignatureRecord` |
973
+ | `ContractMarkerRecordLike` | `ContractSignatureRecordLike` |
974
+ | `ContractMarkerRow` | `ContractSignatureRow` |
975
+ | `currentMarker` | `currentSignature` |
976
+ | `currentMarkerHash` | `currentSignatureHash` |
977
+ | `currentMarkerInvariants` | `currentSignatureInvariants` |
978
+ | `currentMarkerStorageHash` | `currentSignatureStorageHash` |
979
+ | `databaseMarkerHashBySpace` | `databaseSignatureHashBySpace` |
980
+ | `errorHashMismatch` | `errorSignatureMismatch` |
981
+ | `errorMarkerMissing` | `errorSignatureMissing` |
982
+ | `errorMarkerReadFailed` | `errorSignatureReadFailed` |
983
+ | `errorMarkerRowCorrupt` | `errorSignatureRowCorrupt` |
984
+ | `holdMarkerLock` | `holdSignatureLock` |
985
+ | `initMarker` | `initSignature` |
986
+ | `insertMarker` | `insertSignature` |
987
+ | `lockMarker` | `lockSignature` |
988
+ | `MARKER_LOCK_TIMEOUT_SECONDS` | `SIGNATURE_LOCK_TIMEOUT_SECONDS` |
989
+ | `markerCheck` | `signatureCheck` |
990
+ | `MarkerCheckResult` | `ContractSignatureCheckResult` |
991
+ | `MarkerCheckSection` | `ContractSignatureCheckSection` |
992
+ | `MarkerDestination` | `ContractSignatureDestination` |
993
+ | `markerDrift` | `signatureDrift` |
994
+ | `markerHash` | `signatureHash` |
995
+ | `MarkerHashes` | `ContractSignatureHashes` |
996
+ | `MarkerInsert` | `ContractSignatureInsert` |
997
+ | `markerInvariants` | `signatureInvariants` |
998
+ | `markerLocation` | `signatureLocation` |
999
+ | `MarkerOperations` | `ContractSignatureOperations` |
1000
+ | `markerOps` | `signatureOps` |
1001
+ | `MarkerReader` | `ContractSignatureReader` |
1002
+ | `markerReader` | `signatureReader` |
1003
+ | `MarkerReadResult` | `ContractSignatureReadResult` |
1004
+ | `markerRowsBySpace` | `signatureRowsBySpace` |
1005
+ | `markersBySpaceId` | `signaturesBySpaceId` |
1006
+ | `MarkerSwapFailure` | `ContractSignatureSwapFailure` |
1007
+ | `markerSwapFailure` | `signatureSwapFailure` |
1008
+ | `orphanMarkers` | `orphanSignatures` |
1009
+ | `parseContractMarkerRow` | `parseContractSignatureRow` |
1010
+ | `parseMarkerRowSafely` | `parseSignatureRowSafely` |
1011
+ | `readAllMarkers` | `readAllSignatures` |
1012
+ | `readMarker` | `readSignature` |
1013
+ | `readMarkerDiscriminated` | `readSignatureDiscriminated` |
1014
+ | `releaseMarkerLock` | `releaseSignatureLock` |
1015
+ | `rethrowMarkerReadError` | `rethrowSignatureReadError` |
1016
+ | `sameMarkerHashes` | `sameContractSignatureHashes` |
1017
+ | `skipMarker` | `skipSignature` |
1018
+ | `SpaceMarkerConflict` | `SpaceSignConflict` |
1019
+ | `SpaceMarkerHashConflict` | `SpaceSignatureHashConflict` |
1020
+ | `SpaceMarkerRecord` | `SpaceSignatureRecord` |
1021
+ | `SpaceSignature` | `SpaceSignOutcome` |
1022
+ | `updateMarker` | `updateSignature` |
1023
+ | `VERIFY_CODE_HASH_MISMATCH` | `VERIFY_CODE_SIGNATURE_MISMATCH` |
1024
+ | `VERIFY_CODE_MARKER_MISSING` | `VERIFY_CODE_SIGNATURE_MISSING` |
1025
+ | `verifyMarker` | `verifyContractSignature` |
1026
+ | `VerifyMarkerOption` | `VerifyContractSignatureOption` |
1027
+ | `withMarkerLock` | `withSignatureLock` |
1028
+ | `withMarkerReadErrorHandling` | `withSignatureReadErrorHandling` |
1029
+
1030
+ The client option `verifyMarker` is now `verifyContractSignature`, and its type `VerifyMarkerOption` is `VerifyContractSignatureOption`. The option turns on or off the check the client makes, on its first use of the database, of the database's contract signature against the contract the application carries. It is not named `verifySignature`, because beside options such as `jwtSecret` on `supabase()` that would read as checking a cryptographic signature.
1031
+
1032
+ #### Run the script
1033
+
1034
+ Commit your work first. Then run the script that sits beside this guide in the `prisma-8` skill, with the folder to work on; `.` is the working directory, which is also the default. With the copy in `.agents/`:
1035
+
1036
+ ```sh
1037
+ node .agents/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/contract-signature-names/contract-signature-names.ts .
1038
+ ```
1039
+
1040
+ It is the same script as the application guide's. In a code file that imports a renamed name from an `@prisma/orm-*` package, it renames that import and the file's uses of it; a name the file re-exports keeps the name the file exports (`export { ContractSignatureRow as ContractMarkerRow }`), so your own users are not broken. An object that holds the import in shorthand keeps its key: `{ errorMarkerMissing }` becomes `{ errorMarkerMissing: errorSignatureMissing }`. In a file that imports from such a package, it renames each renamed member where the file reads it (`.readMarker`), writes it as a key (`markerLocation: …`), or declares it in a class, interface or object (`async readMarker(…) {`, `markerLocation = …`, `readMarker = async (…) => …`), and in a type that names it as a string (`Pick<SqlControlAdapter<'postgres'>, 'readMarker'>`, `SqlControlAdapter<'postgres'>['readMarker']`). A variable, parameter, function or export your code declares keeps its name. In a file that uses a renamed name through an import, it reads the code with the project's own TypeScript compiler, so that a local binding of that name, such as a parameter destructured as `{ errorMarkerMissing }`, keeps its name, and so does a member read through a local binding that has the name of a namespace import, such as a parameter `errors` in a file that imports `@prisma/orm-framework/errors` as the namespace `errors`; if it finds no `typescript` package, it says so and stops without changing any file. It also renames the path, the flag, the codes, the values and the `--json` fields, as the application guide says, prints each file it changed, and a second run changes nothing.
1041
+
1042
+ ```ts
1043
+ // before
1044
+ import type { ContractMarkerRecord } from '@prisma/orm-framework/contract';
1045
+ import { withMarkerLock } from '@prisma/orm-target-mysql/target/marker-lock';
1046
+ async readMarker(driver, space): Promise<ContractMarkerRecord | null> { … }
1047
+
1048
+ // after the script
1049
+ import type { ContractSignatureRecord } from '@prisma/orm-framework/contract';
1050
+ import { withSignatureLock } from '@prisma/orm-target-mysql/target/signature-lock';
1051
+ async readSignature(driver, space): Promise<ContractSignatureRecord | null> { … }
1052
+ ```
1053
+
1054
+ #### Read the script's changes before you commit them
1055
+
1056
+ The script finds names by searching the text of your code. It uses TypeScript only to tell a local binding of a renamed name from the import. So read its diff, and expect to fix a few lines by hand:
1057
+
1058
+ - **Names of your own that match Prisma's.** In a file that imports from an `@prisma/orm-*` package, a name of your own that is in the table of renamed names below is renamed whoever owns it, where it is a member, a key, a property read, or a quoted name after `[` or in `Pick<…>` and `Omit<…>`: your own `{ markerHash: … }`, `pin.currentMarker`, `updateMarker() {}`, `pin['currentMarker']`, `['markerHash', 'lat']` or `Pick<Mine, 'readMarker'>` becomes `signatureHash`, `currentSignature`, `updateSignature`, `pin['currentSignature']`, `['signatureHash', 'lat']` or `Pick<Mine, 'readSignature'>`. In a file that runs `db verify`, `db init`, `db update` or `db migrate` with `--json`, every `.marker`, `marker:` key (in an object, a type literal or an interface, `markerHash?:` included), `'marker'` string and destructured `marker` is renamed, yours included. A variable, parameter, function or export you declare keeps its name, and a destructured field keeps your local name (`const { signature: marker } = …`). Where one of your objects crosses into a file the script did not change, revert the rename, or rename the other file to match.
1059
+ - **Shapes it misses.** A member destructured under its own name, `const { readMarker, markerLocation } = adapter`, keeps the old names: the script cannot tell your object from Prisma's there, and renaming it would make your own destructuring read `undefined`. TypeScript reports each one; in a JavaScript project nothing does, and the old name reads `undefined` at run time, so read the results of the searches below.
1060
+ - **Files it can misread.** In `.tsx` and `.jsx`, an apostrophe in JSX text (`<p>Don't …</p>`) and a quote inside a regular expression (`/['"]/`) can make it misjudge where a string ends, and miss or wrongly make a rename after it. Read its changes to such files closely, and search them for what is left.
1061
+
1062
+ #### Change by hand what the script cannot
1063
+
1064
+ - **Two codes that are now one.** Code that handled `MIGRATION.MARKER_MISMATCH` and `MIGRATION.MARKER_NOT_IN_HISTORY` apart now has two branches for `MIGRATION.SIGNATURE_NOT_IN_GRAPH`, and only the first is reached: merge them, telling `db migrate`'s error from `migration status`'s warning by the command that raised it.
1065
+ - **The two removed codes and factories.** Remove code that calls `errorMarkerRequired` or `errorFamilyReadMarkerSqlRequired`, or matches their codes.
1066
+ - **A name in a file with no Prisma import.** A file that implements a Prisma interface without importing from Prisma, for example through a type imported from another of your files, is left as it was; the type check names each such member. In JavaScript, nothing names it, so search. This search lists the old names left; change each one that is Prisma's:
1067
+
1068
+ ```sh
1069
+ grep -rnwE --exclude-dir=node_modules --exclude-dir=dist --exclude-dir=build --exclude-dir=upgrading 'ContractMarkerRecord|ContractMarkerRecordLike|ContractMarkerRow|MARKER_LOCK_TIMEOUT_SECONDS|MarkerCheckResult|MarkerCheckSection|MarkerDestination|MarkerHashes|MarkerInsert|MarkerOperations|MarkerReadResult|MarkerReader|MarkerSwapFailure|SpaceMarkerConflict|SpaceMarkerHashConflict|SpaceMarkerRecord|SpaceSignature|VERIFY_CODE_HASH_MISMATCH|VERIFY_CODE_MARKER_MISSING|VerifyMarkerOption|acquireMarkerLock|bootstrapSignMarkerQueries|buildSignMarkerBootstrapQueries|contractHashAtMarker|currentMarker|currentMarkerHash|currentMarkerInvariants|currentMarkerStorageHash|databaseMarkerHashBySpace|errorHashMismatch|errorMarkerMissing|errorMarkerReadFailed|errorMarkerRowCorrupt|holdMarkerLock|initMarker|insertMarker|lockMarker|markerCheck|markerDrift|markerHash|markerInvariants|markerLocation|markerOps|markerReader|markerRowsBySpace|markerSwapFailure|markersBySpaceId|orphanMarkers|parseContractMarkerRow|parseMarkerRowSafely|readAllMarkers|readMarker|readMarkerDiscriminated|releaseMarkerLock|rethrowMarkerReadError|sameMarkerHashes|skipMarker|updateMarker|verifyMarker|withMarkerLock|withMarkerReadErrorHandling' .
1070
+ ```
1071
+
1072
+ - **`--json` output read away from the command.** As in the application guide, find the readers with this search:
1073
+
1074
+ ```sh
1075
+ grep -rnE --exclude-dir=node_modules --exclude-dir=dist --exclude-dir=build --exclude-dir=upgrading '\.marker(Hash)?\b|\[.marker(Hash)?.\]|\{[^}]*\bmarker(Hash)?\b[^}]*\}[[:space:]]*[=:)]' .
1076
+ ```
1077
+
1078
+ - **Your target's own table and messages.** A target that stores signatures in a table of its own keeps its table name; rename only what the code calls it, if you want the code to match. Messages your target writes that say "marker" are yours to reword.
1079
+
1080
+ The searches leave out the `upgrading` folder of the skill copy, whose guides name the old names.
1081
+
1082
+ ## The parts of the PostgreSQL client have Early Access names
1083
+
1084
+ ### `postgres-client-parts-early-access-names`, `sql-prepared-query-early-access-names`
1085
+
1086
+ An extension that builds a client from the same parts as `postgres()` imported them from entries named `internal`. Those entries are removed. Each name is now exported from an entry any user can import, with the Early Access prefix: `ea_` on a function or constant, `Ea_` on a type or class. An Early Access name may change in any release.
1087
+
1088
+ Change each import and each use of the name. The values and types are the same; only their names and import paths change.
1089
+
1090
+ | Before | After |
1091
+ | --- | --- |
1092
+ | `connectWithBinding`, `resolveOptionalPostgresBinding`, `PostgresBindingRules`, `validateTransactionOptions`, `validateCursorOptions`, `toDriverCursorOptions` from `@prisma/orm-postgres/internal/options` | `ea_connectWithBinding`, `ea_resolveOptionalPostgresBinding`, `Ea_PostgresBindingRules`, `ea_validateTransactionOptions`, `ea_validateCursorOptions`, `ea_toDriverCursorOptions` from `@prisma/orm-postgres/runtime` |
1093
+ | `buildPostgresQueryMembers` from `@prisma/orm-postgres/internal/transaction-members` | `ea_buildPostgresQueryMembers` from `@prisma/orm-postgres/runtime` |
1094
+ | `PostgresRuntimeImpl` from `@prisma/orm-postgres/runtime` | `Ea_PostgresRuntimeImpl` from `@prisma/orm-postgres/runtime` |
1095
+ | `buildPostgresStaticContext` from `@prisma/orm-postgres/internal/static-context` | `ea_buildPostgresStaticContext` from `@prisma/orm-postgres/static` |
1096
+ | `PostgresStaticContext` from `@prisma/orm-postgres/internal/static-context` | `PostgresStaticContext` from `@prisma/orm-postgres/static` |
1097
+ | `validatePostgresContract` from `@prisma/orm-postgres/internal/validate-contract` | `ea_validatePostgresContract` from `@prisma/orm-postgres/static` |
1098
+ | `preparedStatementQuery`, `preparedStatementExecute`, `transactionStart`, `createTransactionStart`, `PreparedStatementQueryTarget`, `PreparedStatementExecuteTarget`, `TransactionStartTarget` from `@prisma/orm-family-sql/runtime/internal/prepared-query` | `ea_preparedStatementQuery`, `ea_preparedStatementExecute`, `ea_transactionStart`, `ea_createTransactionStart`, `Ea_PreparedStatementQueryTarget`, `Ea_PreparedStatementExecuteTarget`, `Ea_TransactionStartTarget` from `@prisma/orm-family-sql/runtime` |
1099
+
1100
+ Through a facade, the prepared-query names come from its `family-runtime` entry, for example `@prisma/orm-postgres/family-runtime`, in place of `family-runtime/internal/prepared-query`.
1101
+
1102
+ The prepared-query entry's other names (`settlementOf`, `transactionSettlement`, `wasRefusedBeforeBegin`, `SettledTransactionTarget`, `TransactionSettlementState`, `TransactionStart`) are no longer exported, and have no replacement.
1103
+
1104
+ The upgrade to 8.0.0-rc.25 described two uses of them: forwarding the settlement member of a transaction an extension wraps, and building a `TransactionSettlementState` object by hand. The runtime finds the settlement member by looking it up on the transaction object, and no exported type requires it. So a wrapper that keeps the wrapped transaction as its prototype (`Object.create(transaction)`), or copies the wrapped transaction's own properties onto itself (`Object.assign(wrapper, transaction)`), still forwards the member without naming it. A wrapper that forwards it by name (`[transactionSettlement]: transaction[transactionSettlement]`), or code that builds or types a `TransactionSettlementState`, has nothing left to import. If your extension needs one of these names, open an issue at https://github.com/prisma/orm/issues and say what it uses the name for.
1105
+
1106
+ ## A contract stores what it requires as `requiredCapabilities`
1107
+
1108
+ These changes apply to an extension for any database. The PostgreSQL entries of this guide, from `extension-contract-lists-required-capabilities` on, cover what else changes for PostgreSQL.
1109
+
1110
+ ### `extension-code-reads-required-capabilities`
1111
+
1112
+ A contract used to store the capabilities it requires as `capabilities`, each key in the namespace of its vocabulary: `sql.` for a key the SQL databases share and `postgres.` for PostgreSQL's own. It now stores them as `requiredCapabilities`, each key in the namespace of who provides it: `conn.` for the connection, whose only key is `conn.interactiveTransactions`, and `db.` for every other key, which the database provides. The field holds the keys as a list, sorted and without duplicates. A MongoDB contract's list stays empty, under its new name.
1113
+
1114
+ Change code that reads the list:
1115
+
1116
+ | Before | After |
1117
+ | --- | --- |
1118
+ | `contract.capabilities` | `contract.requiredCapabilities` |
1119
+ | `contract.capabilities.sql.returning` | `contract.requiredCapabilities.includes('db.returning')` |
1120
+ | `contract.capabilities.postgres.distinctOn` | `contract.requiredCapabilities.includes('db.distinctOn')` |
1121
+ | `contract.capabilities.sql.interactiveTransactions` | `contract.requiredCapabilities.includes('conn.interactiveTransactions')` |
1122
+ | Code that walks the groups and their flags, such as `Object.entries(contract.capabilities).flatMap(([namespace, flags]) => Object.entries(flags)…)` | Iterate `contract.requiredCapabilities` directly: each entry is a key such as `db.returning`. Renaming the field alone still compiles, because `Object.entries` accepts an array, but walks the characters of each key. |
1123
+ | `computeProfileHash({ target, targetFamily, capabilities })` | `computeProfileHash({ requiredCapabilities })`, which no longer takes `target` or `targetFamily` (the `contract-hash-inputs` step) |
1124
+
1125
+ A contract built by hand, not emitted, such as a JSON object in a test, renames its field and its keys the same way:
1126
+
1127
+ ```json
1128
+ "requiredCapabilities": ["conn.interactiveTransactions", "db.jsonAgg", "db.returning"]
1129
+ ```
1130
+
1131
+ A key whose prefix is neither `db.` nor `conn.` is read as written, and neither signing nor the client's connection check selects it.
1132
+
1133
+ These are now lists of keys, or single keys, too, so code that reads them changes the same way, for example `lockOptionCapabilities.nowait.sql.lockNowait` becomes `lockOptionCapabilities.nowait`, which is the key `'db.lockNowait'`:
1134
+
1135
+ - `mysqlAdapterCapabilities` from `@prisma/orm-target-mysql/adapter`, `mariadbAdapterCapabilities` from `@prisma/orm-target-mariadb/adapter` and `sqliteAdapterCapabilities` from `@prisma/orm-target-sqlite/adapter`, which now also list `conn.interactiveTransactions`.
1136
+ - `lockOptionCapabilities` and `lockStrengthCapabilities` from `@prisma/orm-family-sql/relational-core`.
1137
+
1138
+ ### `extension-stored-contract-needs-the-upgrade-script`
1139
+
1140
+ The extension's emitted `contract.json` and each migration snapshot under `migrations/snapshots/<hash>/` that a release candidate wrote store `capabilities`. This release refuses to read such a `contract.json`, for every database, with `CONTRACT.VALIDATION_FAILED`: "This contract was written by an earlier release of Prisma, in a format this release no longer reads. Prisma includes a tool that brings your stored contracts up to date. How to run it: https://docs.prisma.io/docs/orm/v8/reference/error-reference#CONTRACT.VALIDATION_FAILED" A migration snapshot a release candidate wrote is refused before that, with `MIGRATION.CONTRACT_SNAPSHOT_CONTENT_MISMATCH`, because its storage hash was computed by the old hash rules. The same script fixes both. Applications cannot load an extension whose bundled contract still stores `capabilities`.
1141
+
1142
+ Follow the `contract-hash-inputs` instructions in this guide on the extension package: their script renames the field, writes the keys as a sorted list in every contract and snapshot, and in the type of the list in the `contract.d.ts` beside each, and they then have you run `prisma contract emit`. Publish the rewritten files.
1143
+
1144
+ ## A contract's required capabilities are a list of keys
1145
+
1146
+ ### `required-capabilities-as-list`
1147
+
1148
+ Capabilities are lists of keys everywhere: what a contract requires and what a target, adapter or driver declares it provides.
1149
+
1150
+ | Before | After |
1151
+ | --- | --- |
1152
+ | `contract.requiredCapabilities.db.returning === true` (a development build) | `contract.requiredCapabilities.includes('db.returning')` |
1153
+ | `Object.entries(contract.requiredCapabilities)` over groups and their flags | iterate `contract.requiredCapabilities` directly: each entry is a key such as `db.returning` |
1154
+ | `capabilities: { sql: { returning: true }, postgres: { distinctOn: true } }` (`8.0.0-rc.25`) or `capabilities: { db: { returning: true } }` (a development build) on a target, adapter or driver descriptor, or in a constant the descriptor names, such as `export const myAdapterCapabilities = Object.freeze({ sql: { returning: true } })` | `capabilities: ['db.distinctOn', 'db.returning']` |
1155
+ | `mergeCapabilityMatrices(base, components)` | `unionCapabilityKeys(...lists)` from `@prisma/orm-framework/components` |
1156
+ | `missingCapability(capabilities, { sql: { forUpdate: true } })` (`8.0.0-rc.25`) or `missingCapability(capabilities, { db: { forUpdate: true } })` | `!capabilities.includes('db.forUpdate')` |
1157
+ | `capabilitiesFromKeys(keys)`, `capabilityKeysOf(matrix)` | the list of keys itself |
1158
+ | `isCapabilityKey(key)`, `isCapabilityProvider(prefix)` | nothing: any string is a key; only signing (`db.`) and the client's connection check (`conn.`) select keys by prefix |
1159
+ | `GatedMethod<Capabilities, { postgres: { distinctOn: true } }, Method>` (`8.0.0-rc.25`) or `GatedMethod<Capabilities, { db: { distinctOn: true } }, Method>` | `GatedMethod<Capabilities, 'db.distinctOn', Method>` |
1160
+ | `DatabaseCapabilities`, `ConnectionCapabilities` as grouped interfaces | lists of keys: `readonly DatabaseCapabilityKey[]`, `readonly ConnectionCapabilityKey[]` |
1161
+ | `postgresRequiredCapabilities([...])`, `PostgresRequiredCapabilities` | the list itself, typed `RequiredCapabilities` |
1162
+
1163
+ A key from `8.0.0-rc.25` is renamed as `extension-code-reads-required-capabilities` says: `sql.` and `postgres.` become `db.`, and `sql.interactiveTransactions` becomes `conn.interactiveTransactions`.
1164
+
1165
+ In each file the detection matches, make the change its row describes. A target, adapter or driver that still declares the grouped form is refused with `CONTRACT.PACK_CONTRIBUTION_INVALID` when a contract is emitted or built and when a client is created, naming the component.
1166
+
1167
+ Extensions still declare no capabilities of their own.
1168
+
1169
+ The extension's own stored contracts and migration snapshots are rewritten by the `contract-hash-inputs` script of this release, as its instructions say; this change has no step of its own for them.
1170
+
1171
+ ## A PostgreSQL contract lists the capabilities it requires
1172
+
1173
+ These changes apply to an extension for PostgreSQL. Do them in the order below.
1174
+
1175
+ ### `extension-contract-lists-required-capabilities`
1176
+
1177
+ A capability is a fact that a database version or a connection provides, and that a contract requires. Each capability's key names who provides it: `db.` for the database, such as `db.returning`, and `conn.` for the connection, such as `conn.interactiveTransactions`. A contract's capabilities used to come from the adapter. Now the contract lists every capability it requires, and nothing is added to it. `@prisma/orm-postgres/contract-builder` and `@prisma/orm-postgres/config` export what each supported PostgreSQL version provides, `postgres15` to `postgres18`, and what the driver's connection provides, `postgresDriver`. Each is a list of capability keys such as `db.returning`.
1178
+
1179
+ An extension's shipped contract (its contract space) runs on every database its users have. So require what the oldest version the extension supports provides, usually `postgres15`. `prisma db migrate`, `prisma db update` and `prisma db init` check every contract space's contract against the database before they change it, and refuse a database that lacks what a contract requires. Today all four versions provide the same capabilities, so no supported database is refused. A contract that requires a newer version's capabilities than it needs would refuse users on older databases once a release adds a version with new features.
1180
+
1181
+ #### 1. Write the list
1182
+
1183
+ A contract written in TypeScript lists them in `defineContract`, from `@prisma/orm-postgres/contract-builder`. Before:
1184
+
1185
+ ```ts
1186
+ export const contract = defineContract({ codecLookup, dataTypeLookup }, () => ({
1187
+ // ...
1188
+ }));
1189
+ ```
1190
+
1191
+ After:
1192
+
1193
+ ```ts
1194
+ import { defineContract, postgres15, postgresDriver } from '@prisma/orm-postgres/contract-builder';
1195
+
1196
+ export const contract = defineContract(
1197
+ { requiredCapabilities: [...postgres15, ...postgresDriver], codecLookup, dataTypeLookup },
1198
+ () => ({
1199
+ // ...
1200
+ }),
1201
+ );
1202
+ ```
1203
+
1204
+ Without the list, the contract requires the newest PostgreSQL version's list and the driver's. Under the PostgreSQL `defineConfig`, the commands that load the contract source, such as `prisma contract emit`, warn with `CONTRACT.REQUIRED_CAPABILITIES_NOT_LISTED`. Under the core `defineConfig` with `typescriptContract`, as extension configs usually are, nothing warns, so nothing tells you the default was used. That default is a stopgap for contracts written before the list existed, and Prisma 8.0 requires the list. It is the wrong list for an extension, which should require the oldest version it supports, so write the list.
1205
+
1206
+ An empty list throws:
1207
+
1208
+ > State the capabilities your contract requires in requiredCapabilities in defineContract. The list is empty.
1209
+
1210
+ A capability set, such as `{ db: { returning: true } }`, is refused as not a list:
1211
+
1212
+ > requiredCapabilities in defineContract is not a list. State the capabilities your contract requires as a list of capability keys.
1213
+
1214
+ Any string is accepted as a key, but only a `db.` key is checked against the database and only a `conn.` key against the connection, so a key in the form a release candidate's `contract.json` used, such as `sql.returning`, is required by nothing that checks it. Write it with its provider's prefix, `db.returning`. An entry that is not a string is refused, for example:
1215
+
1216
+ > requiredCapabilities in defineContract lists 42, which is not a capability key. A capability key is a string, such as `db.returning`.
1217
+
1218
+ The config and `prisma7Schema` refuse the same cases, naming where they take the list. These refusals have the code `CONTRACT.ARGUMENT_INVALID`.
1219
+
1220
+ A `db.` key that no PostgreSQL version provides, such as a mistyped one, is written to the contract as it is. `prisma db sign`, `prisma db verify` and the migration commands then refuse every database for it, with `CONTRACT.DATABASE_CAPABILITIES_NOT_PROVIDED` (`MIGRATION.DATABASE_CAPABILITIES_NOT_PROVIDED` from the migration commands):
1221
+
1222
+ > Your contract requires unrecognized database capabilities (db.notAThing). They are not provided by any known PostgreSQL version. Remove them from your contract's required capabilities.
1223
+
1224
+ A contract written in the Prisma schema language, whose config builds the source with `prismaContract` from `@prisma/orm-family-sql/contract-psl/provider`, passes the source its required capabilities. The target, adapter and driver in the config no longer add any, and a config built with the core `defineConfig` gets no default. So after the next `prisma contract emit`, a source given no `requiredCapabilities` writes a contract that lists no capabilities, with no warning. The client then refuses the features that need a capability: `transaction()` is a type error and throws `ORM.CAPABILITY_MISSING`, and row locks, `distinctOn`, skip-on-conflict writes, prepared reads with includes, and writes that read back their rows through `db.returning`, such as a `create()` whose key the database generates, are refused with the same code. Includes still work, with one query per relation. A schema with a scalar list (`String[]`) or `@@check` does not emit at all. Pass it the same list of keys, from `@prisma/orm-postgres/config`. Before:
1225
+
1226
+ ```ts
1227
+ contract: {
1228
+ ...prismaContract('src/contract.prisma', {
1229
+ target: postgres,
1230
+ createNamespace: postgresCreateNamespace,
1231
+ }),
1232
+ },
1233
+ ```
1234
+
1235
+ After:
1236
+
1237
+ ```ts
1238
+ import {
1239
+ postgres15,
1240
+ postgresDriver,
1241
+ } from '@prisma/orm-postgres/config';
1242
+
1243
+ contract: {
1244
+ ...prismaContract('src/contract.prisma', {
1245
+ requiredCapabilities: [...postgres15, ...postgresDriver],
1246
+ target: postgres,
1247
+ createNamespace: postgresCreateNamespace,
1248
+ }),
1249
+ },
1250
+ ```
1251
+
1252
+ The config is not shipped code, so add `@prisma/orm-postgres` to `devDependencies` if the extension does not list it yet, at the same exact version as its other `@prisma/orm-*` packages. `prisma7Contract` from `@prisma/orm-family-sql/contract-prisma7/provider` takes the same `requiredCapabilities` option.
1253
+
1254
+ A config built with the PostgreSQL `defineConfig` from `@prisma/orm-postgres/config`, such as a test application's, lists them in its contract entry. Before:
1255
+
1256
+ ```ts
1257
+ contract: './prisma/contract.prisma',
1258
+ ```
1259
+
1260
+ After:
1261
+
1262
+ ```ts
1263
+ contract: {
1264
+ path: './prisma/contract.prisma',
1265
+ requiredCapabilities: [...postgres15, ...postgresDriver],
1266
+ },
1267
+ ```
1268
+
1269
+ Without it, the same default and the same warning apply.
1270
+
1271
+ A `.ts` contract path in that entry does not change, and the config refuses `requiredCapabilities` beside it. A Prisma 7 schema read with `prisma7Schema` takes the list in a second argument: `prisma7Schema('prisma/schema.prisma')` becomes `prisma7Schema('prisma/schema.prisma', { requiredCapabilities: [...postgres15, ...postgresDriver] })`.
1272
+
1273
+ #### 2. Leave out what the extension does not use, if you need to
1274
+
1275
+ The list is exactly what the contract requires. To leave a capability out, filter it out or write the keys yourself: `[...postgres15.filter((capability) => capability !== 'db.insertOnConflictTarget'), ...postgresDriver]`. A list without `postgresDriver` does not require `conn.interactiveTransactions`, so `transaction()` is unavailable to it.
1276
+
1277
+ #### 3. Emit the contract
1278
+
1279
+ The extension's stored `contract.json` and its migration snapshots store what the contract requires as `capabilities`, with `sql.` and `postgres.` keys, and each `contract.d.ts` beside them types that list. This release refuses to read such a `contract.json`, with `CONTRACT.VALIDATION_FAILED`:
1280
+
1281
+ > This contract was written by an earlier release of Prisma, in a format this release no longer reads. Prisma includes a tool that brings your stored contracts up to date. How to run it: https://docs.prisma.io/docs/orm/v8/reference/error-reference#CONTRACT.VALIDATION_FAILED
1282
+
1283
+ A migration snapshot a release candidate wrote is refused before that, with `MIGRATION.CONTRACT_SNAPSHOT_CONTENT_MISMATCH`, because its storage hash was computed by the old hash rules. The `contract-hash-inputs` script of this release rewrites both: it renames the field, gives each key its new prefix, and drops the flags in `extension-capability-flags-removed`. Its own instructions describe how to run it on the extension package. Then run `prisma contract emit` and commit the regenerated `contract.json` and `contract.d.ts`. They store exactly the keys the list names, under `requiredCapabilities`, and gain `conn.interactiveTransactions` when the list spreads `postgresDriver`. Applications cannot load an extension whose bundled contract still has `capabilities`, so publish the rewritten files.
1284
+
1285
+ #### 4. Sign each test database again
1286
+
1287
+ Run `prisma db sign --db <connection string>` against each database the extension's tests or examples keep signed. Signing now checks that the database provides every capability the contract requires of it, and refuses to sign when it does not. A database signed by an earlier release was signed without that check; signing again makes it.
1288
+
1289
+ Signing and the migration commands now refuse a server older than PostgreSQL 15, for example:
1290
+
1291
+ > This release of Prisma requires PostgreSQL 15 or later. This database runs PostgreSQL 14.10. Upgrade the database to PostgreSQL 15 or later.
1292
+
1293
+ Verification reports the code `CONTRACT.DATABASE_CAPABILITIES_NOT_PROVIDED`, and the migration commands `MIGRATION.DATABASE_CAPABILITIES_NOT_PROVIDED`. Run the extension's tests against PostgreSQL 15 or later.
1294
+
1295
+ ### `extension-descriptor-declares-no-capabilities`
1296
+
1297
+ Each capability is now declared by the component that knows the fact: the target declares what each database version provides, and the driver what the connection provides. PostgreSQL's adapter declares none, and neither does an extension.
1298
+
1299
+ The extension descriptor and pack ref types no longer accept a `capabilities` field, so an extension that still declares one fails to type-check where it builds its pack metadata or descriptors. `prisma contract emit`, the TypeScript `defineContract` and the control stack take capabilities only from the target, the adapter and the contract's own list, and emit no longer copies an extension's flags into the application's contract or into the extension's entry under `extensions`.
1300
+
1301
+ Remove the `capabilities` field from the extension's pack metadata, and so from its control and runtime descriptors. Before:
1302
+
1303
+ ```ts
1304
+ const pgvectorPackMetaBase = {
1305
+ kind: 'extension',
1306
+ id: 'pgvector',
1307
+ familyId: 'sql',
1308
+ targetId: 'postgres',
1309
+ version: '0.0.1',
1310
+ capabilities: {
1311
+ postgres: {
1312
+ 'pgvector.cosine': true,
1313
+ },
1314
+ },
1315
+ authoring: {
1316
+ type: pgvectorAuthoringTypes,
1317
+ },
1318
+ // ...
1319
+ } as const;
1320
+ ```
1321
+
1322
+ After:
1323
+
1324
+ ```ts
1325
+ const pgvectorPackMetaBase = {
1326
+ kind: 'extension',
1327
+ id: 'pgvector',
1328
+ familyId: 'sql',
1329
+ targetId: 'postgres',
1330
+ version: '0.0.1',
1331
+ authoring: {
1332
+ type: pgvectorAuthoringTypes,
1333
+ },
1334
+ // ...
1335
+ } as const;
1336
+ ```
1337
+
1338
+ An operation or data type is not a capability: it goes through the operation registry and the codecs, as before.
1339
+
1340
+ ### `extension-capability-flags-removed`
1341
+
1342
+ These flags are removed from PostgreSQL contracts. Nothing read them, and no `db.` key replaces them:
1343
+
1344
+ - `postgres.orderBy`, `postgres.limit`, `postgres.lateral`, `postgres.jsonAgg` and `postgres.returning`. The `db.lateral`, `db.jsonAgg` and `db.returning` flags, which were `sql.lateral`, `sql.jsonAgg` and `sql.returning`, remain.
1345
+ - `sql.enums`. MySQL and MariaDB contracts keep it, as `db.enums`.
1346
+ - `postgres.pgvector.cosine`, `postgres.postgis.geometry` and `postgres.paradedb/bm25`, which the pgvector, PostGIS and ParadeDB extensions declared.
1347
+
1348
+ The `contract-hash-inputs` script removes them from the extension's stored contract and snapshots. Remove any code, type or test fixture of the extension that reads or writes them.
1349
+
1350
+ ### `extension-client-goes-by-the-contract`
1351
+
1352
+ The SQL runtime used to add the capabilities of the target, adapter, driver and extensions to the contract's. It no longer does: the contract's list is the list, and the query builder and the ORM client offer exactly what it holds.
1353
+
1354
+ `createExecutionContext` from `@prisma/orm-family-sql/runtime` ignores its `driver` option, and Prisma 8.0 removes it. Remove it now. Before:
1355
+
1356
+ ```ts
1357
+ const context = createExecutionContext({ contract, stack, driver });
1358
+ ```
1359
+
1360
+ After:
1361
+
1362
+ ```ts
1363
+ const context = createExecutionContext({ contract, stack });
1364
+ ```
1365
+
1366
+ A contract stores what it requires as `requiredCapabilities`, a sorted list of keys prefixed `db.` for the database and `conn.` for the connection, for example `"requiredCapabilities": ["conn.interactiveTransactions", "db.returning"]`. A contract the extension builds by hand, for example in a test, must list every capability the code under test uses there. Take the keys from a contract emitted with the same list.
1367
+
1368
+ `transaction()` on the PostgreSQL client, a serverless connection or a Supabase role-bound client needs the contract to require `conn.interactiveTransactions`. Without it, the callback is a type error that names the flag, and the call throws `ORM.CAPABILITY_MISSING`:
1369
+
1370
+ > `transaction()` is unavailable: your contract declares no dependency on `conn.interactiveTransactions`. To enable it, add `conn.interactiveTransactions` to your contract's required capabilities.
1371
+
1372
+ Extension code that runs transactions through an application's client should check that `contract.requiredCapabilities.includes('conn.interactiveTransactions')` before it calls `transaction()`, or call `interactiveTransactionsAvailable(contract)` from `@prisma/orm-family-sql/runtime`, as `@prisma/orm-better-auth` does for its `transaction` option.
1373
+
1374
+ A package that adds a SQL target answers what a database lacks of the contract's `db.` keys through `databaseCapabilitiesNotProvided` on its control target descriptor (`SqlControlTargetDescriptor`), which returns a `DatabaseCapabilitiesNotProvided` value from `@prisma/orm-framework/components/control`: the database's name and at least one finding. The SQL family renders it with the framework's text function, and the CLI prints that text. It is optional, and the PostgreSQL target is the model.
1375
+
1376
+ ### `extension-capability-exports-moved`
1377
+
1378
+ Change these, if the extension has them. The old import paths and the ignored last argument of `renderLoweredSql` keep compiling until Prisma 8.0 removes them. `pgVersion` is gone now, and `postgresAdapterCapabilities` is empty, so code that reads one of its flags no longer compiles:
1379
+
1380
+ | Before | After |
1381
+ | --- | --- |
1382
+ | `postgresAdapterCapabilities` from `@prisma/orm-target-postgres/adapter/adapter` | Nothing: it is empty. Remove the import and the code that reads it |
1383
+ | The capabilities that `postgresAdapterCapabilities` listed | `postgres15` to `postgres18` from `@prisma/orm-postgres/contract-builder` or `@prisma/orm-postgres/config`, or the table they are built from, `postgresCapabilitiesByVersion` (one row per version, each a list of keys such as `db.returning`) from `@prisma/orm-target-postgres/target/server-version` |
1384
+ | `renderLoweredSql(ast, contract, codecs, dataTypeLookup, capabilities)` from `@prisma/orm-target-postgres/adapter/sql-renderer` | `renderLoweredSql(ast, contract, codecs, dataTypeLookup)`: drop the last argument, which is ignored. The `platform-paths-an-extension-uses` change then stops publishing it, so an extension that rendered SQL itself copies what it needs |
1385
+ | `POSTGRES_MIN_SERVER_VERSION` from `@prisma/orm-target-postgres/target/server-version` | `POSTGRES_MIN_SERVER_VERSION` from `@prisma/orm-target-postgres/target/server-version-range` |
1386
+ | `pgVersion` (text) on `PostgresDatabaseSchemaNode` and `PostgresDatabaseSchemaNodeInput` from `@prisma/orm-target-postgres/target/types` | `serverVersionNumber`: the server's `server_version_num` as a number, such as `150004` for 15.4, or `undefined` when it could not be read |
1387
+
1388
+ `postgresAdapterCapabilities` is now an empty list. The driver's list, `postgresDriverCapabilities`, `['conn.interactiveTransactions']`, is in `@prisma/orm-target-postgres/driver/capabilities`. `POSTGRES_MIN_SERVER_VERSION` is still `'15'`. It is the oldest entry in the list of supported PostgreSQL versions, which `@prisma/orm-target-postgres/target/server-version-range` exports with `POSTGRES_NEWEST_VERSION` and `PostgresVersion`; that entry point imports nothing. The version table in `@prisma/orm-target-postgres/target/server-version` has one row for each of those versions, and a test checks that its first row is `POSTGRES_MIN_SERVER_VERSION`.
1389
+
1390
+ ## Data types declare their parameter keys
1391
+
1392
+ ### `data-type-param-keys`
1393
+
1394
+ Add `paramKeys` beside every `params` in a data type declaration. List each key of the parameter schema, in the schema's order, as `'required'` when the schema requires it and `'optional'` when the schema lets it be absent. In an arktype schema an optional key is written with a trailing `?`, such as `'srid?'`; another library marks it its own way. Leave out arktype's `'+'` key, which is not a parameter. For a schema of a union, list every key any member lists, as `'required'` only when every member requires it. A declaration without `params` needs no change, unless its parameters name keys or narrow their values (see below).
1395
+
1396
+ When `params` names a schema declared as a constant, such as `geometryParams`, declare its keys once, right after that constant's statement, as a constant named after it with `Params` replaced by `ParamKeys`, written `as const satisfies DataTypeParamKeysOf<typeof geometryParams.infer>`, and write `paramKeys` on the line after `params`. Import `DataTypeParamKeysOf` as a type from `@prisma/orm-framework/components/codec`, in the file's existing import from that module when it has one. For a schema that is not built with arktype, write `DataTypeParamKeysOf<StandardSchemaV1.InferInput<typeof geometryParams>>`.
1397
+
1398
+ ```ts
1399
+ // before
1400
+ export const geometryParams = arktype({ '+': 'reject', 'srid?': 'number.integer >= 1' });
1401
+
1402
+ export const geometry = sqlDataType('acme/geometry', {
1403
+ params: geometryParams,
1404
+ texts: [{ text: 'geometry({srid})', written: true, catalog: true }],
1405
+ read: readGeometry,
1406
+ });
1407
+
1408
+ // after
1409
+ export const geometryParams = arktype({ '+': 'reject', 'srid?': 'number.integer >= 1' });
1410
+
1411
+ const geometryParamKeys = { srid: 'optional' } as const satisfies DataTypeParamKeysOf<typeof geometryParams.infer>;
1412
+
1413
+ export const geometry = sqlDataType('acme/geometry', {
1414
+ params: geometryParams,
1415
+ paramKeys: geometryParamKeys,
1416
+ texts: [{ text: 'geometry({srid})', written: true, catalog: true }],
1417
+ read: readGeometry,
1418
+ });
1419
+ ```
1420
+
1421
+ When `params` is written inline, write the keys inline on the next line: `paramKeys: { srid: 'optional' },`. The compiler checks `paramKeys` against the schema, inline or through `satisfies`: a missing key, an extra key, or `'optional'` for a required key is a type error. A constant without `satisfies` is not checked for an extra key.
1422
+
1423
+ A declaration without `params` must have parameters that name no keys and narrow no values: the broad `DataTypeParams` (or `SqlTypeParams`), `{}` or `Record<never, never>`. The compiler checks this on the parameter type, so a declaration without `params` no longer type-checks when `normalize`, `catalogParams` or `render` is typed to take other parameters, such as `normalize: (params: { readonly length?: number }) => …` or `(params: Readonly<Record<string, number>>) => …`, when `fromReported` returns parameters with named keys, or when the call gives such parameters as a type argument. Nothing checks those parameters before the hooks read them. Add a schema of those parameters as `params`, with its `paramKeys`. A hook whose parameters are not annotated, or are typed as the broad parameters, needs no change. The compiler does not catch a hook that is generic over its parameters, such as `<P extends { readonly length?: number }>(params: P) => …`, or one typed `DataTypeParams & { readonly length?: number }`: such a declaration still compiles without `params`, but its hook reads parameters nothing has checked, so give it a schema too. A file this change's detection matches can also declare a hook that needs no change, or call a function named `render` or `normalize` that is not a hook; leave those alone.
1424
+
1425
+ Remove any cast that made a schema from another copy of arktype fit `params`, such as `as unknown as Type<…>`. The cast is no longer needed, and parameters that schema refuses are now refused with `CONTRACT.TYPE_PARAMS_INVALID`.
1426
+
1427
+ A type-constructor argument gives a parameter of the data type. A key a codec keeps for itself is set by the codec's TypeScript column helper, never by a type constructor, so a type constructor that maps an argument onto a key only the codec's own `paramsSchema` declares is now refused when the stack is assembled. Remove that argument from the type constructor and set the key through the codec's column helper. Here the codec `acme/text@1` keeps `collation` for itself, beside its data type's `length`:
1428
+
1429
+ ```ts
1430
+ // before
1431
+ export const acmeAuthoringTypes = {
1432
+ acme: {
1433
+ Text: {
1434
+ kind: 'typeConstructor',
1435
+ args: [
1436
+ { kind: 'value', dataType: 'pg/int4', name: 'length' },
1437
+ { kind: 'value', dataType: 'pg/text', name: 'collation', optional: true },
1438
+ ],
1439
+ output: {
1440
+ codecId: 'acme/text@1',
1441
+ typeParams: { length: { kind: 'arg', index: 0 }, collation: { kind: 'arg', index: 1 } },
1442
+ },
1443
+ },
1444
+ },
1445
+ } as const satisfies AuthoringTypeNamespace;
1446
+
1447
+ // after
1448
+ export const acmeAuthoringTypes = {
1449
+ acme: {
1450
+ Text: {
1451
+ kind: 'typeConstructor',
1452
+ args: [{ kind: 'value', dataType: 'pg/int4', name: 'length' }],
1453
+ output: {
1454
+ codecId: 'acme/text@1',
1455
+ typeParams: { length: { kind: 'arg', index: 0 } },
1456
+ },
1457
+ },
1458
+ },
1459
+ } as const satisfies AuthoringTypeNamespace;
1460
+
1461
+ export function acmeTextColumn(
1462
+ length: number,
1463
+ collation?: string,
1464
+ ): ColumnTypeDescriptor<'acme/text@1'> & {
1465
+ readonly typeParams: { readonly length: number; readonly collation?: string };
1466
+ } {
1467
+ return {
1468
+ codecId: 'acme/text@1',
1469
+ typeParams: collation === undefined ? { length } : { length, collation },
1470
+ };
1471
+ }
1472
+ ```
1473
+
1474
+ `AuthoringTypeNamespace` is imported from `@prisma/orm-framework/components/authoring`, and `ColumnTypeDescriptor` from `@prisma/orm-framework/components/codec`. A TypeScript contract that wrote `field.column(type.acme.Text(10, 'C'))` writes `field.column(acmeTextColumn(10, 'C'))` instead; a call without the argument, such as `type.acme.Text(10)`, needs no change. PSL has no column helpers, so a PSL schema can no longer set the key. Do not add the key to the data type's `params` and `paramKeys`: the data type's parameters are the ones in its database type name, so the key would have to appear in a written text, and the migration planner would treat a change to it as a change of column type.
1475
+
1476
+ A file this change's detection matches can also contain an unrelated `params` property; change only data type declarations.
1477
+
1478
+ ### `data-type-schema-key-helpers-removed`
1479
+
1480
+ Replace the removed helpers with the data type's own declaration:
1481
+
1482
+ ```ts
1483
+ // before
1484
+ const keys = objectSchemaKeys(type.params) ?? [];
1485
+ const required = requiredSchemaKeys(type.params) ?? [];
1486
+
1487
+ // after
1488
+ const keys = Object.keys(type.paramKeys ?? {});
1489
+ const required = requiredParamKeys(type);
1490
+ ```
1491
+
1492
+ `schemaKeysAllowing(schema, value)` has no replacement: the framework no longer reads a schema's structure, so it cannot say which of a schema's keys accept a value. Remove the code that depended on that answer, or keep that logic in the extension, written against its own schema.
1493
+
1494
+ Replace a direct call of a data type's parameter schema:
1495
+
1496
+ ```ts
1497
+ // before
1498
+ const refused = type.params?.(params) instanceof arktypeType.errors;
1499
+
1500
+ // after
1501
+ const refused = dataTypeParamsProblem(type, params) !== undefined;
1502
+ ```
1503
+
1504
+ `dataTypeParamsProblem` is exported by `@prisma/orm-framework/components/codec`. A file this change's detection matches can also call an unrelated `params(...)` function; leave those calls alone.
1505
+
1506
+ ### `data-type-params-not-arktype`
1507
+
1508
+ A codec with keys of its own built its `paramsSchema` from its data type's schema with `dataType.params.and(ownKeys)`. `dataType.params` is a Standard Schema and has no `and`. Join the data type's exported arktype schema constant with the codec's own keys instead:
1509
+
1510
+ ```ts
1511
+ // before
1512
+ override readonly paramsSchema = acmeText.params.and(type({ 'collation?': 'string' }));
1513
+
1514
+ // after
1515
+ override readonly paramsSchema = acmeTextParams.and(type({ 'collation?': 'string' }));
1516
+ ```
1517
+
1518
+ If the data type is in the same package as the codec, export its schema constant and join that. Only when the data type belongs to another package that does not export its schema, or builds it with another library or another copy of arktype than the codec's, write one arktype object schema that holds both the data type's parameters, with the same bounds, and the codec's own keys. That is the one place a bound is written twice; the contract check still runs the column's data type's own `params` when a column gives type parameters, so a copy that drifts can only refuse more. The codec's own keys stay in its `paramsSchema` only; they never go into the data type's `params` or `paramKeys`.
1519
+
1520
+ Replace other arktype members read from a data type's `params` with the same members of the exported schema constant, or with the Standard Schema interface:
1521
+
1522
+ ```ts
1523
+ // before
1524
+ type Params = typeof acmeText.params.infer;
1525
+ const ok = acmeText.params.allows(params);
1526
+
1527
+ // after
1528
+ type Params = typeof acmeTextParams.infer;
1529
+ const ok = dataTypeParamsProblem(acmeText, params) === undefined;
1530
+ ```
1531
+
1532
+ `DataTypeSpec`, `SqlDataTypeSpec` and `MongoDataTypeSpec` now depend on their parameter type: parameters that name keys or narrow their values need `params` and `paramKeys`, and parameters that do neither take both or neither. An interface that extends one of them with no type argument, or with a type parameter, no longer compiles. Make it a type alias of an intersection:
1533
+
1534
+ ```ts
1535
+ // before
1536
+ interface AcmeDataTypeSpec<P extends SqlTypeParams> extends SqlDataTypeSpec<P> {
1537
+ readonly flavour: string;
1538
+ }
1539
+
1540
+ // after
1541
+ type AcmeDataTypeSpec<P extends SqlTypeParams> = SqlDataTypeSpec<P> & {
1542
+ readonly flavour: string;
1543
+ };
1544
+ ```
1545
+
1546
+ An interface that extends one over concrete parameters, such as `interface AcmeDataTypeSpec extends SqlDataTypeSpec<AcmeParams>`, still compiles; leave it as it is.
1547
+
1548
+ A function generic over the parameters that takes such a spec, removes its own fields by rest destructuring and passes the rest to `dataType`, `sqlDataType` or `mongoDataType` no longer type-checks. The compiler's message mentions `exactOptionalPropertyTypes`, and may name a field of the spec such as `casts`, not the cause. Do not add a cast. Pass the whole spec: the three functions read only their own fields, so the extra fields are ignored.
1549
+
1550
+ ```ts
1551
+ // before
1552
+ export function acmeDataType<P extends SqlTypeParams>(id: string, spec: AcmeDataTypeSpec<P>) {
1553
+ const { flavour, ...rest } = spec;
1554
+ return { ...sqlDataType(id, rest), flavour };
1555
+ }
1556
+
1557
+ // after
1558
+ export function acmeDataType<P extends SqlTypeParams>(id: string, spec: AcmeDataTypeSpec<P>) {
1559
+ return { ...sqlDataType(id, spec), flavour: spec.flavour };
1560
+ }
1561
+ ```
1562
+
1563
+ If one of the function's own fields has the same name as a field of the spec, build the spec to pass with spread instead, as `sqlDataType(id, { ...spec, read })`. This change's detection matches a rest-destructured copy passed to one of the three functions; change it only when the destructured value is a data type spec. `SqlTypeParams` is exported by `@prisma/orm-family-sql/contract/data-type`.
1564
+
1565
+ A file this change's detection matches can also read `.params` of something that is not a data type, such as a route; change only reads of a data type's `params`.
1566
+
1567
+ ## An index type's options validator is a Standard Schema
1568
+
1569
+ ### `index-type-options-standard-schema`
1570
+
1571
+ An extension that registers index types with arktype's `type(...)` has nothing to change, whichever arktype 2 version it uses. Prisma now checks the options through the validator's Standard Schema interface, so a validator built by another copy of arktype than Prisma's is checked correctly, and a validator that answers asynchronously is refused with `CONTRACT.PACK_CONTRIBUTION_INVALID`. The index type's options are typed as the validator's input, which is what an author writes, so a validator with a morph such as `string.numeric.parse` now types its options as the string it parses.
1572
+
1573
+ If the extension's code or tests call a registered entry's validator directly, replace the call. This applies wherever the entry comes from: `indexTypes.entries`, `registry.get(...)`, a variable, or a function parameter typed `IndexTypeEntry`. A file this change's detection matches can also call an unrelated `options(...)` function; leave those calls alone.
1574
+
1575
+ ```ts
1576
+ // before
1577
+ const result = indexTypes.entries[0].options({ key_column: 'id' });
1578
+
1579
+ // after
1580
+ const result = indexTypes.entries[0].options['~standard'].validate({ key_column: 'id' });
1581
+ if (result instanceof Promise) throw new Error('the validator must be synchronous');
1582
+ const problems = result.issues; // undefined when the options are valid
1583
+ ```
1584
+
1585
+ ## A Prisma schema checks each extension's index types
1586
+
1587
+ ### `extension-index-types-checked-for-prisma-schemas`
1588
+
1589
+ A Prisma schema read through `defineConfig` now receives each configured extension's index types, and checks them when it loads, as a TypeScript contract already did. An extension whose `indexTypes` registers a type another extension or the target also registers, or registers a type whose `accessMethod` differs from its literal, now makes every such schema fail to load with `CONTRACT.PACK_CONTRIBUTION_INVALID`, even a schema that does not use the type. Rename the conflicting type, or remove its `accessMethod`.
1590
+
1591
+ ## Resolving a contract argument through the control API
1592
+
1593
+ The CLI now reads every contract argument with one parser, which also accepts a path to a migration directory. Extension code that only runs the CLI sees the error-code changes the app guide describes under `contract-argument-one-parser`. Code that calls the control API's resolvers changes as below.
1594
+
1595
+ ### `control-api-ref-resolution-takes-migration-dir`
1596
+
1597
+ A program that resolves contract arguments through the control API passes the folder a path argument is resolved against, and the space's migrations folder:
1598
+
1599
+ ```ts
1600
+ import { join } from 'node:path';
1601
+ import { resolveContractRef } from '@prisma/orm-toolchain/cli/control-api';
1602
+
1603
+ // before
1604
+ resolveContractRef(input, { ...context });
1605
+ // after
1606
+ resolveContractRef(input, {
1607
+ ...context,
1608
+ migrationDirResolution: { cwd: process.cwd(), spaceMigrationsDir: join(projectDir, 'migrations/app') },
1609
+ });
1610
+ ```
1611
+
1612
+ The same field goes in the options of `resolveContractRefToSnapshot`, `resolveFromForPlan` and `resolveToForPlan`.
1613
+
1614
+ ## Commands read the database's policies as its config
1615
+
1616
+ A database records two policies, its change policy and its data protection policy, for the whole database. On PostgreSQL they are the one row of `prisma.config`, and on SQLite the one row of `prisma_config`; on MySQL, MariaDB and MongoDB they are still under `meta.policies` in the application space's contract signature. Until this release, the framework read them from the application space's signature, and the PostgreSQL adapter presented `prisma.config` as that signature's `meta.policies`. Now a family reads them as the database's config, one record for the whole database, and a signature read carries no policies on PostgreSQL.
1617
+
1618
+ ### `read-the-database-config`
1619
+
1620
+ These changes reach code that implements a family, a target's control adapter or a migration runner outside Prisma, from `@prisma/orm-framework/components/control`, `@prisma/orm-family-sql/family/control-adapter`, `@prisma/orm-family-mongo/family/control-adapter` and the paths that re-export them. Code that only calls a family or a control client is not affected, apart from `ControlClient`, which gains `readDatabaseConfig()`.
1621
+
1622
+ - **`ControlFamilyInstance`** gains `readDatabaseConfig({ driver })`, which returns a `DatabaseConfigRecord`, `{ policies }`, where `policies` is the value the database records, unparsed, or `undefined` when it records none; and `databaseConfigLocation`, a string that names where the database records it, for messages, as `signatureLocation` names where it keeps the contract signatures. A family whose control adapter reads the config, as the built-in SQL and MongoDB families' do, forwards both to the adapter it created from the stack:
1623
+
1624
+ ```ts
1625
+ get databaseConfigLocation(): string {
1626
+ return controlAdapter.databaseConfigLocation;
1627
+ },
1628
+ async readDatabaseConfig({ driver }) {
1629
+ return controlAdapter.readDatabaseConfig(driver);
1630
+ },
1631
+ ```
1632
+
1633
+ - **`SqlControlFamilyInstance`** and **`MongoControlFamilyInstance`** extend `ControlFamilyInstance`, so they gain the same two members. `SqlControlFamilyInstance` also gains `recordDatabasePolicies({ driver, policies })`. Code that implements either type itself, such as a test double, adds them; code that uses the family instances `@prisma/orm-family-sql` and `@prisma/orm-family-mongo` create needs no change.
1634
+
1635
+ - **`SqlControlAdapter`** gains `databaseConfigLocation`, `readDatabaseConfig(driver)` and `recordDatabasePolicies(driver, policies)`. A target that keeps the policies in the application space's signature, as the built-in MySQL adapter does, builds the record from that signature, names it in `databaseConfigLocation`, and sets them there, keeping the rest of its `meta` and leaving its signature as it is:
1636
+
1637
+ ```ts
1638
+ import {
1639
+ APP_SPACE_ID,
1640
+ DATABASE_POLICIES_META_KEY,
1641
+ type DatabaseConfigRecord,
1642
+ } from '@prisma/orm-framework/components/control';
1643
+
1644
+ // In the adapter class, where `SIGNATURE_TABLE` is the name of the target's own signature table:
1645
+ readonly databaseConfigLocation = `the application space's contract signature in ${SIGNATURE_TABLE}`;
1646
+
1647
+ async readDatabaseConfig(driver): Promise<DatabaseConfigRecord> {
1648
+ const signature = await this.readSignature(driver, APP_SPACE_ID);
1649
+ return { policies: signature?.meta[DATABASE_POLICIES_META_KEY] };
1650
+ }
1651
+ ```
1652
+
1653
+ `recordDatabasePolicies` refuses when the database has no application signature. A runner whose run changes only the policies calls it through the family (`SqlControlFamilyInstance.recordDatabasePolicies({ driver, policies })`) and signs nothing, as the built-in runners do.
1654
+
1655
+ - **`MongoControlAdapter`** gains `databaseConfigLocation` and `readDatabaseConfig(driver)`, and the runner's **`ContractSignatureOperations`** gains `databaseConfigLocation` and `readDatabaseConfig()`. Build them the same way, from the application space's signature.
1656
+
1657
+ - A runner's check of the policies under its lock reads `readDatabaseConfig` and compares with `compareDatabasePolicies`. The SQL family's `checkDatabasePoliciesHeld` does this for you.
1658
+
1659
+ ### `policy-helpers-renamed`
1660
+
1661
+ - Rename `compareMarkerDatabasePolicies` to `compareDatabasePolicies`, and the type `MarkerDatabasePoliciesComparison`, which it returns, to `DatabasePoliciesComparison`. `compareDatabasePolicies` now takes the database's config in place of a contract signature: pass what `readDatabaseConfig` returns. Code that holds a signature of a target that keeps the policies there passes `{ policies: signature.meta[DATABASE_POLICIES_META_KEY] }`.
1662
+ - `databasePoliciesOf(config)` takes the same record. Its reason for policies that are not valid no longer names `meta.policies`.
1663
+ - Replace `errorMarkerPoliciesCorrupt({ why, space, markerLocation })` with `errorDatabasePoliciesCorrupt({ why, databaseConfigLocation })`, from `@prisma/orm-framework/errors/execution`. Its code is `CONTRACT.DATABASE_POLICIES_CORRUPT`, not `CONTRACT.SIGNATURE_ROW_CORRUPT`, and its payload is `{ databaseConfigLocation }`. A target that reads the policies from a store of its own reports a read it cannot make with `errorDatabasePoliciesReadFailed({ why, databaseConfigLocation, cause })`, code `CONTRACT.DATABASE_POLICIES_READ_FAILED`. Tests that expected `CONTRACT.SIGNATURE_ROW_CORRUPT` for policies that are not valid expect `CONTRACT.DATABASE_POLICIES_CORRUPT`; `CONTRACT.SIGNATURE_ROW_CORRUPT` still means a signature row that cannot be decoded.
1664
+
1665
+ ## Prisma's own tables are in the `prisma` schema
1666
+
1667
+ ### `name-the-prisma-schema`
1668
+
1669
+ Prisma 8 keeps a few tables of its own in a PostgreSQL database. The release candidates kept them in a schema named `prisma_contract`: `marker` recorded which contract each contract space was last brought to, and from `8.0.0-rc.25` on the application's row could also hold the database's policies, under its `meta` column; a contract space is a set of tables with its own contract and migrations, such as the application's or the one an extension carries. `ledger` records each migration applied, and `contract` holds the contract of each migration. They are now in a schema named `prisma`, and `marker` is replaced by two tables. `prisma.signatures` has one row for each contract space, with the columns `space`, `core_hash`, `profile_hash`, `invariants` and `signed_at` (the release candidates' `updated_at`); `contract_json`, `canonical_version`, `app_tag` and `meta` are gone. `prisma.config` has at most one row, whose `policies` column holds the change policy and the data protection policy; no row means the default policies. `ledger` and `contract` keep their names and columns. Prisma creates them with migrations of its own, which `prisma db init`, `db update`, `db migrate` and `db sign` apply before anything else, and which rename `prisma_contract` to `prisma` on a database a release candidate set up.
1670
+
1671
+ Search the extension's code, scripts and tests for `prisma_contract`, outside `node_modules` and build output, and replace it with `prisma`. `prisma` needs no quotes in SQL. The usual cases:
1672
+
1673
+ - A test helper that resets the database between tests by dropping the schema. If it dropped only `prisma_contract`, `prisma` now survives the reset, and the next test finds the signature rows of the previous one.
1674
+
1675
+ ```ts
1676
+ // Before
1677
+ await driver.query('drop schema if exists prisma_contract cascade');
1678
+
1679
+ // After
1680
+ await driver.query('drop schema if exists prisma cascade');
1681
+ ```
1682
+
1683
+ - A test that reads the contract signature to check which contract a space was brought to reads `prisma.signatures`. It now also has a row for the contract space `_prisma`, the space of Prisma's own tables, so leave it out of a query whose test expects only the application's and the extension's rows:
1684
+
1685
+ ```sql
1686
+ -- Before
1687
+ select space, core_hash from prisma_contract.marker order by space;
1688
+
1689
+ -- After
1690
+ select space, core_hash from prisma.signatures where space <> '_prisma' order by space;
1691
+ ```
1692
+
1693
+ - A test that reads another column of the signature: the policies it read from `meta -> 'policies'` on the application's row are in the `policies` column of `prisma.config`, `updated_at` is now `signed_at`, and nothing replaces `contract_json`, `canonical_version` or `app_tag`.
1694
+
1695
+ - A test that creates Prisma's tables by hand must create them in `prisma`. A test that runs the migration runner directly, without the commands above, now fails with `MIGRATION.PRISMA_TABLES_MISSING` until Prisma's tables exist. Create only Prisma's tables first, with the control client's `bringPrismaSpaceUpToDate()`, or with `applyInstalledContractSpace` from `@prisma/orm-toolchain/migration-tools/spaces` when the test has no control client. Do not use `prisma db init` or `dbInit` for this: they also bring the application's or the extension's own space to its contract, so a test of that space's first migration no longer starts from an empty database.
1696
+
1697
+ ### `prisma-tables-api-breaks`
1698
+
1699
+ These changes reach code that uses the platform packages, or a facade's paths that re-export them, such as `@prisma/orm-postgres/target/contract-free`. Code that only builds and queries with a facade's client is not affected.
1700
+
1701
+ - **`buildControlTableBootstrapQueries` and `buildSignMarkerBootstrapQueries` are removed.** Prisma's own tables are now created by the Prisma space's migration. Code that ran these statements to prepare a database calls `bringPrismaSpaceUpToDate()` on the control client instead, or `applyInstalledContractSpace` from `@prisma/orm-toolchain/migration-tools/spaces` without a client.
1702
+ - **`PostgresControlAdapter.signatureLocation` is typed `string`.** It was the literal type `"prisma_contract.marker"`. Code that compared it with that literal compares with `"prisma.signatures"`, or uses the value it holds.
1703
+ - **`ContractSignatureReadResult` has a new kind, `earlier-release`.** A contract signature read returns it when Prisma's own tables are still in a release candidate's schema. Code that switches over the kinds exhaustively handles it, for example by reporting that the database needs `prisma db migrate`.
1704
+ - **`SqlMigrationRunnerErrorCode` includes `MIGRATION.PRISMA_TABLES_MISSING`.** The runner returns it when asked to apply a space before Prisma's own tables exist. Code that switches over the codes exhaustively handles it.
1705
+ - **`ControlClient` has a new required method, `bringPrismaSpaceUpToDate`.** Code that only calls a control client is not affected. Code that implements `ControlClient` itself, such as a test double or a `createClient` factory passed to `executeMigrateShowPlan`, adds the method; it may return `undefined` when the target carries no Prisma space.
1706
+
1707
+ ## Prisma's own tables on SQLite have new names
1708
+
1709
+ ### `sqlite-prisma-tables-renamed`
1710
+
1711
+ Search extension code and tests for `_prisma_marker` and `_prisma_ledger`. In each match, name `prisma_signatures` where the code reads or writes a space's signature (its columns are `space`, `core_hash`, `profile_hash`, `invariants` and `signed_at`), `prisma_config` where it reads or writes the policies (one row, column `policies`), and `prisma_ledger` where it reads the ledger (without `contract_json_before` and `contract_json_after`). Both tables also hold rows for the space `_prisma`; a query that lists every space should leave them out with `WHERE space <> '_prisma'`.
1712
+
1713
+ ### `sqlite-prisma-tables-api-breaks`
1714
+
1715
+ - Replace `MARKER_TABLE_NAME` with `PRISMA_TABLE_NAMES.signatures`, `LEDGER_TABLE_NAME` with `PRISMA_TABLE_NAMES.ledger`, and `CONTROL_TABLE_NAMES` with `RESERVED_TABLE_NAMES`, which also lists the release candidates' table names. Import them from `@prisma/orm-target-sqlite/target/contract-free`, not `@prisma/orm-target-sqlite/target/control-tables`.
1716
+ - Remove calls to `buildControlTableBootstrapQueries` and `buildSignBootstrapQueries`. Code that ran their statements to create Prisma's tables before running the migration runner or signing a database directly applies the target's `_prisma` contract space instead: call `bringPrismaSpaceUpToDate` on the control client, or, without the control client, `applyInstalledContractSpace` from `@prisma/orm-toolchain/migration-tools/spaces` with the SQLite target descriptor's `contractSpace`. The commands `db init`, `db update`, `db migrate` and `db sign` already do this.
1717
+
1718
+ ## The CLI's route for enum members that keep their names is gone
1719
+
1720
+ No target in this repository reports an enum member that keeps its name as data loss any more: PostgreSQL, SQLite and MongoDB replace its stored value with no question. The CLI code that gave such a member its own route is removed.
1721
+
1722
+ ### `kept-enum-member-route-removed`
1723
+
1724
+ Before, when a target's `dataLoss` named an enum value whose member the destination still has, the question under `db update` offered two runs: rename the member to a temporary member with an unused stored value, then rename it back. For members whose edits set `swapsValues: true`, or that shared a stored value with another kept member, the CLI also left out the target's `keepDataAdvice`.
1725
+
1726
+ Now the question carries the target's `keepDataAdvice`, and the ways to keep the data that the CLI builds from the target's `keepDataEdit`, and nothing else. A target that sets `swapsValues` can stop setting it. A target that still asks about a member that keeps its name should plan the value replacement instead, as the targets here do: the member is the same object on both sides, so there is nothing to ask.
1727
+
1728
+ ### `mongo-runner-checked-policies-renamed`
1729
+
1730
+ 8.0.0-rc.25 gave `MongoMigrationRunnerExecuteOptions` an optional `checkedPolicies`, the database's change policies, which guarded the application space's contract signature write. It is now `policiesInForce`, passed to every contract space's runner: the runner guards the application space's signature with it, and every space's advice offers only routes the policy permits. Rename the option where you pass it to `execute`. Only that option is renamed: the `checkedPolicies` parameter of `updateSignature` (on `ContractSignatureOperations` and `MongoControlAdapter`) and of `signatureSwapFailure` keeps its name, so a target that implements those keeps it. Passing `checkedPolicies` through a variable still compiles, but the runner no longer reads it, so the signature write is not guarded.
1731
+
1732
+ ## Migration calls use the framework's interface
1733
+
1734
+ ### `extension-migration-calls-use-framework-interface`
1735
+
1736
+ The MongoDB, MySQL and SQLite targets no longer publish a union of their own migration calls: `OpFactoryCall` from `@prisma/orm-target-mongo/target` and `/target/control`, `MysqlOpFactoryCall` and `SqliteOpFactoryCall` are gone, so a later 8.x release can add a migration factory. The published entry points use the framework's `OpFactoryCall` interface from `@prisma/orm-framework/components/control`, whose `factoryName` is any string: MongoDB's `planCalls()` result and `PlannerProducedMongoMigration` hold such calls, `renderOps()` and `renderCallsToTypeScript()` take them (`renderOps()` returns MongoDB operations), and SQLite's `RenameColumnCall.companions` and `RenameTableCall.companions` hold them. What to do:
1737
+
1738
+ - Import the framework's `OpFactoryCall` in place of the removed names.
1739
+ - Where code reads a call's own properties, such as a MongoDB `CreateIndexCall`'s `collection`, narrow with `instanceof` the call class the target exports, and give a call of another class a default branch, as the example below shows.
1740
+ - A SQLite rename call's `indexReplacements` still gives each drop and create as its own class.
1741
+ - MongoDB's `planCalls()` no longer takes `statementCalls`.
1742
+ - MongoDB's `renderOps()` lowers a call that is not one of the MongoDB target's, such as an extension's, through its own `toOp()`, and refuses an operation that is not a MongoDB one with `MIGRATION.INVALID_OPERATION_ENTRY`. Give it calls whose operations are MongoDB operations.
1743
+
1744
+ Migration files do not change: they call the migration factories, which are unchanged.
1745
+
1746
+ A call from MongoDB's `planCalls()` is the framework's `OpFactoryCall`. To read the properties of one kind of call, narrow it with the class the target exports:
1747
+
1748
+ ```ts
1749
+ import type { OpFactoryCall } from '@prisma/orm-framework/components/control';
1750
+ import { CreateIndexCall } from '@prisma/orm-target-mongo/target/control';
1751
+
1752
+ function collectionOf(call: OpFactoryCall): string | undefined {
1753
+ if (call instanceof CreateIndexCall) return call.collection;
1754
+ return undefined;
1755
+ }
1756
+ ```
1757
+
1758
+ ## The ORM client holds only the contract's namespaces
1759
+
1760
+ ### `fragment-on-the-client`
1761
+
1762
+ `fragment(fields, body)` moved from the ORM client to the facade client. It needs no database connection, so the facades put it with the static members: `postgres()`, the serverless client and each of its connections, `sqlite()`, the MySQL and MariaDB clients, each Supabase role-bound client and the Supabase root of the service role client, every transaction and nested transaction, and the static entries.
1763
+
1764
+ | Before | After |
1765
+ | --- | --- |
1766
+ | `OrmClientRootMembers<Contract>` (ORM client) | `FragmentMember<Contract>`, the `fragment` member a client and its transactions offer |
1767
+ | `orm({ runtime, context }).fragment(fields, body)` | `fragmentMember<Contract>().fragment(fields, body)` |
1768
+ | `SqliteOrm`, `MysqlOrm`: the namespace's models and `fragment` unless a model is named `fragment` | the namespace's models only |
1769
+ | `db.orm.fragment(...)`, `tx.orm.fragment(...)` | `db.fragment(...)`, `tx.fragment(...)` |
1770
+
1771
+ Import `FragmentMember` and `fragmentMember` from the `orm-client` entry, such as `@prisma/orm-family-sql/orm-client` or `@prisma/orm-postgres/orm-client`.
1772
+
1773
+ A facade or client that offers `orm` offers `fragment` beside it:
1774
+
1775
+ - Add `FragmentMember<TContract>` to the interface of its static members and of the members its transactions share, and `...fragmentMember<TContract>()` to the objects it builds for them.
1776
+ - Where a type picked `fragment` off the ORM client, such as a type for one namespace of the ORM client with `fragment` added, drop `fragment` from it.
1777
+ - In a test or test double that calls `fragment` on the ORM client, call it on the facade client or on `fragmentMember<Contract>()`.
1778
+
1779
+ ### `aggregate-operation-names-after-8-0`
1780
+
1781
+ An extension that contributes an aggregate operation keeps working when a later 8.x release adds a member to collections with the same name. `orm()` refuses an operation only when its name is one a collection has in Prisma 8.0, such as `where`, `with`, `fragment` or `using`. For a name that a member added later to the base collection class has, the reducer is installed and takes the name on the collection, and the new member is not reachable on that client's collections. A member that a user's own collection class declares, at any depth, always keeps its name, and the operation gets no reducer on that class's collections.
1782
+
1783
+ These names are newly refused. An operation named like a member every JavaScript object inherits (`valueOf`, `toString`, `toLocaleString`, `hasOwnProperty`, `isPrototypeOf`, `propertyIsEnumerable`, `__proto__` and the `__define…__`/`__lookup…__` names) used to be skipped without an error, so it never appeared on a collection. An operation named `_row` used to be installed, although a collection's row type is read through `_row`. `orm()` now refuses all of them with `ORM.AGGREGATE_OPERATION_RESERVED`. Rename the operation.
1784
+
1785
+ ## `updateAll` and `updateAndCount` take no explicit type argument
1786
+
1787
+ ### `update-all-explicit-type-argument`
1788
+
1789
+ `updateAll` and `updateAndCount` now take either the object they took before or a callback that returns it, so they have two type parameters: the collection the call is made on, which TypeScript infers from `this`, and the values the callback returns. A call that passed one explicit type argument fails to compile with `TS2558: Expected 2 type arguments, but got 1`.
1790
+
1791
+ In each file the detection matches, first check that the call is made on a Prisma ORM collection, such as `db.orm.public.Post.where(...)` or a variable that holds one, and that it passes one type argument. Leave a method of the same name on another object alone. On such a call, remove the type argument. TypeScript infers both, and the call does what it did before:
1792
+
1793
+ ```ts
1794
+ // before: the type argument named the collection the call is made on
1795
+ const drafts = db.orm.public.Post.where({ draft: true });
1796
+ await drafts.updateAll<typeof drafts>({ draft: false });
1797
+ // after
1798
+ await drafts.updateAll({ draft: false });
1799
+ ```
1800
+
1801
+ Nothing changes at run time.
1802
+
1803
+ ## `fns` comparisons on a model field take the field's input type
1804
+
1805
+ ### `orm-fns-comparison-takes-field-input-type`
1806
+
1807
+ Each field of the model accessor that an ORM callback receives, such as `p` in `collection.where((p, { fns }) => ...)` from `@prisma/orm-postgres/orm-client`, now has the type-only `input` member when the contract has a `FieldInputTypes` entry for the field. The comparisons of `fns` read it, so in extension code that queries a contract with such entries, for example in its tests, a plain value compared with the field must be of the field's input type:
1808
+
1809
+ ```ts
1810
+ collection.where((p, { fns }) => fns.eq(p.status, 'NOT_A_MEMBER'));
1811
+ ```
1812
+
1813
+ This compiled before and no longer compiles. Code that queries a contract without `FieldInputTypes` is not affected.
1814
+
1815
+ A new type error marks a condition that compiled before. On a column that stores the members as text, a value that is not a member matched no row in `fns.eq` and `fns.in`, excluded no row in `fns.ne` and `fns.notIn`, and was compared in text order in `fns.gt`, `fns.gte`, `fns.lt` and `fns.lte`, where it can match rows. Do not edit such a call and do not remove the condition. Report each call that no longer compiles to the user, say which value or narrowing you would propose, say that the condition would then match different rows than before, which before `updateAll` or `deleteAll` changes which rows are written, and ask. This holds for a literal and for a variable of a wider type, such as `string`.
1816
+
1817
+ Nothing changes at run time.
1818
+
1819
+ ## A prepared declaration's parameter can be a list
1820
+
1821
+ ### `prepared-declaration-param-spec-can-be-a-list`
1822
+
1823
+ A prepared statement on PostgreSQL can now take a whole list as one parameter, declared as `{ codecId: 'pg/int8@1', many: { elementNullable: false } }`. So `ParamSpec`, the type of each parameter in a declaration, gains `many?: { readonly elementNullable: boolean }`. It is exported from `@prisma/orm-family-sql/runtime` and from the `family-runtime` entry of each SQL database package, such as `@prisma/orm-postgres/family-runtime`; `PrepareMember` and `prepareQuery` come from the `orm-client` entries. The `ParamSpec` of `@prisma/orm-framework/operations`, which types the arguments and result of an operation, is a different type and does not change. The guide's search finds both, so check which one a file imports before you change it.
1824
+
1825
+ Code that only calls `db.prepare` with its own declaration does not change. Code that is generic over a declaration may no longer type-check: a function that wraps `prepare`, `prepareQuery` or `delegatingRuntime`, a class that implements `PrepareMember` or `DelegatingRuntime`, or a type that maps each parameter of a declaration to the value it takes. Where such code treats every parameter as one value of its codec, give a spec with `many` a list of its codec's values (with `null` elements when `elementNullable` is `true`), or pass the declaration type on to `prepare` unchanged. The type check finds each place.
1826
+
1827
+ ## Sets of values a later 8.x release may grow
1828
+
1829
+ ### `extension-middleware-handles-later-activities`, `extension-switches-over-later-values`
1830
+
1831
+ A middleware's hooks can now receive an activity, an ended result or a value of a kind a later 8.x release adds. `Activity` and `ActivityEndedResult` gain a member whose `kind` is a `FutureCase`, and `ActivityContext.mode` and `.scope`, `TransactionEnded.outcome`, `StatementEnded.outcome` and `.source`, `ClientActivityEnded.outcome` and `.source` and `ActivityFinalizedResult.outcome` accept any string beside their named values. Where a middleware checks every kind or value, with a `switch` or a `never` assignment, give it a branch for the rest, and act there as for a value it does not know: for example, cache nothing or pass the activity on. A middleware that narrows away `'statement'` and `'transaction'` and then reads a client activity's `contentHash` must instead check that the kind is a client kind, whose name always contains a hyphen (such as `orm-call`). `FutureCase` (from `@prisma/orm-framework/utils/types`) only stands for a later kind in the type, and no code can write it; at run time a later kind arrives under its own name, so check for the kinds the middleware knows. Likewise `StatementActivity.returns` accepts any string beside `'rows'` and `'stats'`, and `StatementEnded` gains a member whose `returns` is a `FutureCase`: read `rowCount` after `returns === 'rows'` and `stats` after `returns === 'stats'`, not in an `else` branch.
1832
+
1833
+ Sets of values that a later 8.x release may grow now say so in their types, so a `switch` that handles every value needs a `default` branch. They include a column default (`ColumnDefault`, kinds `'literal'` and `'function'`), a field's type (`ContractFieldType`, kinds `'scalar'`, `'valueObject'` and `'union'`), the partial filter of a document index (`Expr`), the database policies a ref declares (`ChangeStrategy`, `DataLossLevel`, `AccessWideningLevel`), a migration statement (`ResolvedMigrationStatement`, `ResolvedRenameStatement` and `MigrationStatementJson`, told apart by `kind` and `entity`), a migration subject (`MigrationSubject` and `MigrationSubjectJson`), a written value and its form (`WrittenValue`, `WrittenScalar`, `WrittenForm`), an argument type's kind (`ArgTypeKind`), the parts of the PSL document a target builds from a database (`PslDefaultValue`, `PslDefaultFunctionValue.name`, `PslAttributeArgument`, `PslAttributeTarget`), a string literal's quote (`StringLiteralQuote`), the PSL parser's symbols, scope resolutions, token kinds, syntax kinds and diagnostic codes (`PslSymbol`, `ScopeResolution`, `TokenKind`, `SyntaxKind`, `PslDiagnosticCode`), and what `init` passes a target's init contribution (`ContractSourceFormat`, and `ContractEntryInput` with kinds `'starter'` and `'prisma7-schema'`). Each is written `NonExhaustive<…>`, from `@prisma/orm-framework/utils/types`. A union of strings gains `(string & {})`; a union of objects gains a member whose `kind` is a `FutureCase`, a value no release has and no code can write, which stands for one a later release adds, and a migration statement also gains members whose `entity` is a `FutureCase`. Where code checks every value, with a `switch` or a `const unreachable: never = value` assignment, add a `default` branch. To keep the compiler's check that every kind the code knows is handled, assign the value there to `FutureCase` in place of `never`, as in `const later: FutureCase = value.kind`: a kind the code forgets is still a compile error. If your extension hands applications any of these sets, re-export the two helper types from every entry of the extension, as Prisma's own extensions do, since an entry can reach a set through types it does not name: `export type { FutureCase, NonExhaustive } from '@prisma/orm-framework/utils/types'`. Without it, an application file that imports only your extension and exports a value taken from such a set fails declaration emit with TS2742 under pnpm. An extension does not release with Prisma, so after an application upgrades Prisma the extension can be handed a value it does not know: in the `default` branch, refuse with the extension's own ordinary error, naming the unknown value and saying the extension needs a newer release, and never treat it as one of the values it knows. Where code reads a member's own property in an `else` branch, check for the kind it means instead. For example, ``arg.kind === 'positional' ? arg.value : `${arg.name}: ${arg.value}` `` over a `PslAttributeArgument` becomes a check of both kinds, `'positional'` giving `arg.value` and `'named'` giving `` `${arg.name}: ${arg.value}` ``, with any other kind refused, and a `contractEntry(input)` that handles `'prisma7-schema'` and then reads `input.mode` first checks `input.kind === 'starter'`. A table keyed by one of these sets, such as a `Record` from each value to a message, accepts any key once the set is open, so a lookup with a value a later release adds returns `undefined` although its type says otherwise: check that the key is present, for example with `Object.hasOwn(table, key)`, before using what it returns.
1834
+
1835
+ ## More sets of values a later 8.x release may grow
1836
+
1837
+ ### `extension-more-open-sets-of-values`
1838
+
1839
+ More sets of values that a later 8.x release may grow now say so in their types. Each is written `NonExhaustive<…>`, from `@prisma/orm-framework/utils/types`. A union of strings gains `(string & {})`; a union of objects gains a member whose `kind`, or whichever property tells its members apart (`reason`, `status`, `by`, `setting`, `format`), is a `FutureCase`, a value no release has and no code can write, which stands for one a later release adds. The sets:
1840
+
1841
+ - an attribute spec's argument types (`ArgType` and `InspectableArgType`, by `kind`);
1842
+ - the declaration that owns a field in `UnsupportedAttribute.owner` and `UnresolvedTypeReference.owner`;
1843
+ - why a tagged literal has no written value (`ParsedWrittenScalar`'s `reason`);
1844
+ - the syntax of an `unwritable` `ReadRefusal`, and the result of `temporalToText()`;
1845
+ - a PostgreSQL extension node's `location`, and the `objectType` of a PostgreSQL, MySQL or SQLite migration operation's target details;
1846
+ - a branch of an ORM `combine()` include, and the `aliasSource` of a prepared statement's `decodeContext`;
1847
+ - why a tagged literal's text cannot be canonicalized (`TaggedLiteralCanonicalization`'s `reason`; `describeTaggedLiteralFailure()` now takes any string);
1848
+ - why `readWrittenScalar()` read no value (`WrittenScalarResult`'s `reason`, and its `found`), and why a generator function did not resolve (`GeneratorFunctionResolution`'s `reason`);
1849
+ - what a family's `signSpaces()` returns (`SpaceSignOutcome`'s `status`, and `SpaceSignConflict`'s `reason`), the `by` of a `FailedTypeChange` a target's runner reports, and the `setting` of a `DatabasePolicyDifference`;
1850
+ - the `format` of a contract source (`ContractSourceProvider`, as the config loaders return it).
1851
+
1852
+ What to do:
1853
+
1854
+ - Where code checks every value, with a `switch` or a `const unreachable: never = value` assignment, add a `default` branch. To keep the compiler's check that every kind the code knows is handled, assign the value there to `FutureCase` in place of `never`, as in `const later: FutureCase = value.kind`: a kind the code forgets is still a compile error. If your extension hands applications any of these sets, re-export the two helper types from every entry of the extension, as Prisma's own extensions do, since an entry can reach a set through types it does not name: `export type { FutureCase, NonExhaustive } from '@prisma/orm-framework/utils/types'`. Without it, an application file that imports only your extension and exports a value taken from such a set fails declaration emit with TS2742 under pnpm.
1855
+ - An extension does not release with Prisma, so after an application upgrades Prisma the extension can be handed a value it does not know. In the `default` branch, refuse with the extension's own ordinary error, naming the unknown value and saying the extension needs a newer release, and never treat it as one of the values it knows.
1856
+ - For `ContractSourceProvider`'s `format`, branch on `'psl'` and `'typescript'` by name, and treat any other format as one the integration does not read, never as TypeScript.
1857
+ - A `describeUnsupportedAttribute` that reads `owner.node` first checks that `owner.kind` is `'model'`, `'compositeType'` or `'mixin'`, since the new member has no `node`.
1858
+
1859
+ ## Stored files carry a format version
1860
+
1861
+ ### `stored-files-format-version`
1862
+
1863
+ Each file Prisma stores now says which version of its format it is in, so a later release can refuse a file written by a newer release instead of misreading it. An extension bundles stored files: its emitted `src/contract.json`, the `migration.json` of each of its migrations, `migrations/refs/head.json` and its contract snapshots. A descriptor imports them, and this release reads each one's version first. Until `8.0.0`, a `migration.json` or head ref a release candidate wrote without it is still read, converted in memory. A contract or snapshot a release candidate wrote is not. The contract stores what it requires as `capabilities`, which this release refuses, whatever its format version, with `CONTRACT.VALIDATION_FAILED` and the message "This contract was written by an earlier release of Prisma, in a format this release no longer reads. Prisma includes a tool that brings your stored contracts up to date. How to run it: https://docs.prisma.io/docs/orm/v8/reference/error-reference#CONTRACT.VALIDATION_FAILED" Before that check, an application that loads an extension a release candidate built refuses it with `MIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCH`, and a snapshot is refused with `MIGRATION.CONTRACT_SNAPSHOT_CONTENT_MISMATCH`, because their hashes were computed by the old hash rules. The `contract-hash-inputs` step of this release's upgrade instructions, run on the extension package, fixes all of these: it rewrites every hash, the contract and every snapshot. A `migration.json` or head ref from the newest release candidate is otherwise read as that release candidate wrote it, and holds this release's hashes once the `contract-hash-inputs` step has run. A file from an earlier release candidate also needs the other upgrade steps of each release since the one that wrote it; the command that reads the file names the step for content it no longer accepts. From `8.0.0`, an extension built without it fails to load with `CONTRACT.FORMAT_VERSION_MISSING` (for the contract) or `MIGRATION.FORMAT_VERSION_MISSING` (for a `migration.json` or the head ref). The error names the extension and the file, and tells the application's developer to upgrade the extension, or to ask its author to republish it: the application cannot fix a file inside the extension's package.
1864
+
1865
+ ```jsonc
1866
+ // contract.json, before
1867
+ { "schemaVersion": "1", "targetFamily": "sql", ... }
1868
+ // after
1869
+ { "formatVersion": 1, "targetFamily": "sql", ... }
1870
+
1871
+ // refs/head.json, before
1872
+ { "hash": "...", "invariants": [] }
1873
+ // after
1874
+ { "formatVersion": 1, "hash": "...", "invariants": [] }
1875
+
1876
+ // migration.json, before
1877
+ { "from": null, "to": "...", ... }
1878
+ // after
1879
+ { "formatVersion": 1, "from": null, "to": "...", ... }
1880
+ ```
1881
+
1882
+ Commit your work first. Then run the script from the extension package's root:
1883
+
1884
+ ```sh
1885
+ node .agents/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/stored-files-format-version/stored-files-format-version.ts
1886
+ ```
1887
+
1888
+ The path names the copy of the `prisma-8` skill in `.agents/skills/`. Where the project has no `.agents` folder, use the copy in the agent's own skills folder instead: `.claude/skills/`, `.cursor/skills/` or `.windsurf/skills/`.
1889
+
1890
+ Node 24 or later runs the TypeScript script directly. It reads and writes files only. It walks the package, skipping `node_modules`, `dist`, `build` and directories whose name starts with a dot. In every contract (any `*.json` file with `targetFamily`, `storage` and `schemaVersion` at the top level) it replaces `"schemaVersion": "1"` with `"formatVersion": 1`. In every `migration.json` that has an `ops.json` next to it, and every ref file under the package's `migrations/refs/` (or the migrations folder the package configures under another name; the script recognises a migrations folder by the contract snapshot store or the migrations in it, not by its name, and a ref in any other `refs` folder by its `hash` and `invariants`), it adds `"formatVersion": 1` as the first field. It keeps the rest of each file's bytes, prints each file it changed, and says so when nothing needed changing. A field a ref file does not have, which earlier releases ignored and dropped when they wrote the ref again, it drops and lists. It leaves a file unchanged, says what is wrong with it and what to do, and exits 1 when it cannot tell the file is one a release of Prisma wrote: a `contract.json`, `migration.json` or ref file it cannot read or parse; a ref file in a migrations folder it recognises without a `hash` or an `invariants` list; a `migration.json` next to an `ops.json` with a field the format does not have or without one it has; a contract with both `formatVersion` and `schemaVersion`, or a `contract.json` holding a contract with neither; a contract whose `schemaVersion` is not `"1"`. Outside a migrations folder it recognises, it leaves alone, without a report, any file in a `refs` folder without a ref's content (a `hash` that is `empty` or a 64-character storage hash, and an `invariants` list of strings). If a command still refuses a ref file after the script ran, that ref was already invalid, and earlier releases refused it too: restore it from version control, or correct it by hand, since no Prisma command writes the head ref in an extension's own package: its `hash` is the `storage.storageHash` of the contract the extension emits. It also reports a stored file whose `formatVersion` is not `1` and a snapshot's `contract.json` that is not a JSON object. It does not follow symbolic links. It ignores a link to the package folder or a folder above it, and a link to a folder inside the package that the walk enters or to a `.json` file in one, unless the walk would read the target as another kind of file than at the link, such as a ref in `migrations/refs/` that links to a file elsewhere; it reports such a link and exits 1. It reports a link to any other file or folder, outside the package or skipped by the walk, that holds a stored file it would change or report.
1891
+
1892
+ No hash covers the format version: the storage hash, the head ref's hash, snapshot directory names and each `migrationHash` stay as they are. Then run the `contract-hash-inputs` script below, and only then `prisma contract emit`, which writes the new form of `contract.json`. Rebuild the package and publish it as those instructions say.
1893
+
1894
+ Code that catches these errors can test for them with `isFormatVersionError`, from `@prisma/orm-framework/contract/format-version`.
1895
+
1896
+ ### `descriptor-self-consistency-takes-contract-json`
1897
+
1898
+ ```ts
1899
+ // before
1900
+ assertDescriptorSelfConsistency({
1901
+ extensionId: 'my-extension',
1902
+ target: contractJson.target,
1903
+ targetFamily: contractJson.targetFamily,
1904
+ storage: contractJson.storage,
1905
+ headRefHash: headRef.hash,
1906
+ });
1907
+
1908
+ // after
1909
+ assertDescriptorSelfConsistency({
1910
+ extensionId: 'my-extension',
1911
+ contractJson,
1912
+ headRefHash: headRef.hash,
1913
+ });
1914
+ ```
1915
+
1916
+ ### `contract-space-from-json-reads-stored-files`
1917
+
1918
+ Every call passes the extension's id as `spaceId`, the same id as the descriptor's `id`, so an error about a bundled file names the extension. A call that builds the head ref in code passes the file instead:
1919
+
1920
+ ```ts
1921
+ // before
1922
+ contractSpaceFromJson({
1923
+ contractJson,
1924
+ migrations,
1925
+ headRef: { hash: contractJson.storage.storageHash, invariants: [] },
1926
+ });
1927
+
1928
+ // after
1929
+ import headRef from '../../migrations/refs/head.json' with { type: 'json' };
1930
+
1931
+ contractSpaceFromJson({ spaceId: 'my-extension', contractJson, migrations, headRef });
1932
+ ```
1933
+
1934
+ A head ref may not declare `policies`; `contractSpaceFromJson` refuses one that does.
1935
+
1936
+ ### `canonicalize-contract-takes-version-from-serializer`
1937
+
1938
+ Remove the `schemaVersion` option. The version comes from `serializeContract`: pass the target's contract serializer, whose `serializeContract` returns `formatVersion: 1`.
1939
+
1940
+ ```ts
1941
+ // before
1942
+ const canonical = canonicalizeContract(contract, {
1943
+ schemaVersion: '1',
1944
+ serializeContract: (c) => serializer.serializeContract(c),
1945
+ });
1946
+
1947
+ // after
1948
+ const canonical = canonicalizeContract(contract, {
1949
+ serializeContract: (c) => serializer.serializeContract(c),
1950
+ });
1951
+ ```
1952
+
1953
+ A `serializeContract` of your own that returns no `formatVersion` now produces a canonical contract without one, which this release refuses to read.
1954
+
1955
+ ### `contract-serializer-prints-version-1`
1956
+
1957
+ A target that writes its contract in its own shape overrides `printContractV1`, which returns the contract without `formatVersion`; the base class adds it:
1958
+
1959
+ ```ts
1960
+ // before
1961
+ class MyTargetContractSerializer extends SqlContractSerializerBase<MyContract> {
1962
+ override serializeContract(contract: MyContract): JsonObject {
1963
+ return printMyContract(contract);
1964
+ }
1965
+ }
1966
+
1967
+ // after
1968
+ class MyTargetContractSerializer extends SqlContractSerializerBase<MyContract> {
1969
+ protected override printContractV1(contract: MyContract): JsonObject {
1970
+ return printMyContract(contract);
1971
+ }
1972
+ }
1973
+ ```
1974
+
1975
+ A serializer that still overrides `serializeContract` writes a contract without `formatVersion`, which its own `deserializeContract` then refuses.
1976
+
1977
+ ## A contract's hashes cover only what the contract means
1978
+
1979
+ ### `contract-hash-inputs`
1980
+
1981
+ A contract has three hashes: the storage hash (`storage.storageHash`), the profile hash (`profileHash`) and the execution hash (`execution.executionHash`). Until this release each covered its own section inside a stand-in contract with a fixed `schemaVersion` and blank fields. Now each covers only its own section, and no longer the target or the family. So a project that moves to another target with the same storage, such as from MySQL to MariaDB, keeps its storage hashes, and with them its migrations, snapshots and refs; its profile hash changes where the capabilities differ, as they do from MySQL to MariaDB, and each database is signed again with `prisma db sign`. So every hash changes once, and from `8.0.0` the rules that compute them do not change within the major version.
1982
+
1983
+ An extension's package carries these hashes: its emitted `src/contract.json` and `contract.d.ts`, `migrations/refs/head.json`, the `from`, `to` and `migrationHash` of each `migration.json` and any storage hash in its `ops.json`, the snapshots under `migrations/snapshots/<hash>/` and the `migration.ts` that import them. When an application loads the extension, this release recomputes the hash of the bundled contract and compares it with the head ref. An extension published for an earlier release therefore fails to load with `MIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCH`, which names the extension.
1984
+
1985
+ The script works on files with or without `formatVersion`, and leaves their format as it is, so it does not matter whether you have run the upgrade step for the stored-file format version (`stored-files-format-version`). Commit your work, then run the script from the extension package's root:
1986
+
1987
+ ```sh
1988
+ node .agents/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/contract-hash-inputs/contract-hash-inputs.ts
1989
+ ```
1990
+
1991
+ The path names the copy of the `prisma-8` skill in `.agents/skills/`. Where the project has no `.agents` folder, use the copy in the agent's own skills folder instead: `.claude/skills/`, `.cursor/skills/` or `.windsurf/skills/`.
1992
+
1993
+ Node 24 or later runs the TypeScript script directly. It reads and writes files only. It first checks that each stored storage hash, and each snapshot directory's name, is the hash the old rules or the new rules give the contract's content, and that each `migrationHash` matches its migration. If one does not, the file was edited by hand or comes from another release: the script changes no file, names each such file, and exits 1. The one exception is a contract that is not a snapshot and whose storage hash no migration, ref or snapshot names, such as a hand-made test fixture: the script leaves that file alone, prints the hashes its content gives, still upgrades the rest of the package, and exits 1. Otherwise it rewrites every hash listed above, renames each snapshot directory to its new hash, and recomputes each `migrationHash`, keeping every other byte of each file. It also renames each contract's and snapshot's `capabilities` to `requiredCapabilities`, and the type of that list in each `contract.d.ts`: `sql.interactiveTransactions` becomes `conn.interactiveTransactions`, every other `sql.` and `postgres.` key becomes `db.`, and a PostgreSQL contract loses the nine keys the release candidates wrote that nothing reads, such as `postgres.jsonAgg`. A contract a development build wrote, with `requiredCapabilities` grouped by provider (`{ "db": { "returning": true } }`), gets the sorted list too, of the keys it sets to `true`; a contract already in the list form keeps it. This release refuses a contract that still has `capabilities`, and a snapshot cannot be emitted again, so the script is the only way to bring one to this release. It changes no file, names the contract and exits 1 when a contract's capabilities cannot be renamed: two old keys become one key with different values (such as `sql.distinctOn: false` beside `postgres.distinctOn: true`, which both become `db.distinctOn`), the file has both `capabilities` and `requiredCapabilities`, `requiredCapabilities` is neither a list of strings nor an object, or a `sql` or `postgres` namespace of `capabilities`, or a provider of a grouped `requiredCapabilities`, is not an object. Emit the contract again with `prisma contract emit` if Prisma writes it, or fix the file by hand, and run the script again. It does not follow symbolic links. It also changes no file at all, names the cause and exits 1 when a link leads to a file or folder that holds stored files and that the walk does not reach, inside the package where the walk skips or outside the package, or that the walk reaches but reads as another kind of file, such as a ref in `migrations/refs/` that links to a file elsewhere, or when a snapshot directory, or the `contract.json` in one, is itself a link, wherever it points, or a folder above it is a link to a place where the snapshot is not under a `snapshots` folder by the same hash, such as a `snapshots` folder linked to a folder with another name, since the script renames each snapshot directory to its new storage hash and through the link it would keep the old name, or when a link outside a snapshot directory points into one, such as a `contract.json` linked to a snapshot's, since after the rename the link would point at nothing, or when a snapshot whose storage hash changes cannot be rewritten without changing other content: migrations and refs would then name a snapshot directory that keeps its old name. Fix the file as the report says and run the script again. It prints what it changed; a second run changes nothing. If you ran `prisma contract emit` with this release before the script, and the contract source holds a value the earlier release left out, the emitted contract's storage hash differs from the new hash of the contract the earlier release wrote, which is the one your databases are at. The script gives every snapshot, migration and ref that named the old hash that new hash, whether or not a snapshot of the contract is left. It leaves the emitted contract as it is and lists it with both hashes, on every run; "When the emitted contract gets a different storage hash" below says what to do. Two kinds of snapshot are accepted although a stored hash does not match. An earlier release may have written a snapshot's profile or execution hash by other rules, and no version of the file has the right one; `prisma db sign <contract reference>` copies a snapshot's profile hash into the database's contract signature, so the script gives such a snapshot the hashes its content gives, before any database is signed, and lists it. And the upgrade steps that renamed MongoDB indexes and field storage names rewrote snapshots in place and kept their storage hashes, because contract signatures, the ledger and migrations name a snapshot by its hash; such a MongoDB snapshot, whose directory name and stored hash agree, takes the new hash of its content, every file that names it follows, and the script lists it.
1994
+
1995
+ Then build the package and run its tests, and publish a new version. An application must upgrade the extension together with Prisma: an older version of the extension does not load in this release, and this version does not load in an earlier one.
1996
+
1997
+ Add no migration in this version: publish any new migration in a version for the release before, and leave this one with the migrations it already had. An application deploys every pending migration, its own and its extensions', before it upgrades, then upgrades Prisma and the extension in a release of its own, whose deploy runs `prisma db sign --no-advance-ref` (with `--force` where the database's change policy permits only migrations) and then `prisma db migrate` against each database that existed before it. The release assumes every database is at the newest contract of the application and of every extension: `db sign` signs the extension's space at the extension's head, whatever contract the application names, so a database must already be there. A migration first shipped in this version would not be in the database yet: signing would then fail, because the schema does not match, or, for a migration that only drops something or moves data, mark the space as up to date so the migration never runs. The application's guide gives these steps.
1998
+
1999
+ ##### When the emitted contract gets a different storage hash
2000
+
2001
+ The earlier release left out almost every `false`, `[]` and `{}` in the storage section when it wrote `contract.json`. This release keeps every such value except the defaults each family names as the same as leaving the value out, such as an index's `unique: false`. The values the earlier release left out and this release keeps include a PostgreSQL index's options, a type's parameters, a value set member that is an object (such as `{ "round": false }`), the entries an extension pack adds to storage, a MongoDB index's partial filter expression, a MongoDB collation's `backwards: false` and `normalization: false`, a MongoDB collection's storage engine and clustered index options, and a MongoDB validator's `additionalItems: false`. For example, an index with the options `{ fastupdate: false }` was written with the options `{}`, and its migration created the index without `fastupdate = false`. This release keeps those values. If the extension's contract source holds one, the script gives the stored contract, without the value, its new hash, and `prisma contract emit` then writes the value back and a different storage hash. To tell, compare the emitted contract's `storageHash` with the new hash the script printed for it under "Storage hashes (old -> new)", or, if you ran `prisma contract emit` before the script, read the list of such contracts that the script prints; `git diff` on `src/contract.json` also shows the value restored. The same happens to a default generator's parameters, but they are in the execution section, not in storage: `prisma contract emit` writes such a value back and gives the contract a new execution hash, which no database or migration checks, so it needs no migration. After `prisma contract emit`, the file may also list a table's foreign keys and a collection's MongoDB indexes in a new order, which changes no hash; only the `storageHash` comparison tells whether the hash changed.
2002
+
2003
+ The databases were built without the value, so the extension now needs a migration, and this version cannot carry one, for the reason above. In this version, change the source so that `prisma contract emit` writes the storage hash the script printed again, and publish that. Restore the value in a later version, with a migration that applies it to the database for the first time. `prisma migration plan` cannot plan every such change: for a change to an index's options, such as `fastupdate`, it stops with `MIGRATION.PLANNING_FAILED` and advises `migration new`. Then write the migration by hand. Run `prisma migration new --name <name>`, which writes a migration from the contract the `db` ref names to the emitted contract (where there is no `db` ref, add `--from <hash>` with the hash in `migrations/refs/head.json`, which the script rewrote). In its `migration.ts`, import `rawSql` from `@prisma/orm-postgres/migration`, beside `Migration` and `MigrationCLI`, and return one operation that runs the statement, naming the index as the emitted `contract.json` does:
2004
+
2005
+ ```ts
2006
+ import { Migration, MigrationCLI, rawSql } from '@prisma/orm-postgres/migration';
2007
+
2008
+ // in the class that `prisma migration new` wrote:
2009
+ override get operations() {
2010
+ return [
2011
+ rawSql({
2012
+ id: 'index.post_meta_gin_3aa57499.fastupdate',
2013
+ label: 'Set fastupdate = off on index "post_meta_gin_3aa57499"',
2014
+ operationClass: 'widening',
2015
+ target: {
2016
+ id: 'postgres',
2017
+ details: { schema: 'public', objectType: 'index', name: 'post_meta_gin_3aa57499' },
2018
+ },
2019
+ precheck: [],
2020
+ execute: [
2021
+ {
2022
+ description: 'Set fastupdate = off',
2023
+ sql: 'ALTER INDEX "public"."post_meta_gin_3aa57499" SET (fastupdate = off)',
2024
+ },
2025
+ ],
2026
+ postcheck: [],
2027
+ }),
2028
+ ];
2029
+ }
2030
+ ```
2031
+
2032
+ Then run `node <migration directory>/migration.ts`, which writes the migration's `ops.json` and its hash into `migration.json`.
2033
+
2034
+ A family or target built outside Prisma that computes hashes itself changes its calls. `computeStorageHash`, `computeProfileHash`, `computeExecutionHash` and `buildExecutionSection`, from `@prisma/orm-framework/contract/hashing`, no longer take `target` or `targetFamily`; remove both from each call. `computeProfileHash` takes `requiredCapabilities` in place of `capabilities`. `computeStorageHash`, `canonicalizeContract` and `canonicalizeContractToObject` take a required `normalizeStorage`, the family's normal form of `storage`: a SQL target passes `normalizeSqlStorage` from `@prisma/orm-family-sql/contract/normal-form`.
2035
+
2036
+ ```ts
2037
+ // Before
2038
+ computeStorageHash({ target: 'my-db', targetFamily: 'sql', storage });
2039
+ // After
2040
+ computeStorageHash({ storage, normalizeStorage: normalizeSqlStorage });
2041
+ ```
2042
+
2043
+ Such a family or target can then check that its own contracts keep their hashes within the major with `assertContractHashes`, from the same module; its README shows how.