@prisma/orm-sqlite 8.0.0-rc.2-dev.3 → 8.0.0-rc.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +2 -7
  2. package/dist/config.d.mts +1 -1
  3. package/dist/config.d.mts.map +1 -1
  4. package/dist/config.mjs +3 -8
  5. package/dist/config.mjs.map +1 -1
  6. package/dist/contract-builder.d.mts +205 -15
  7. package/dist/contract-builder.d.mts.map +1 -1
  8. package/dist/contract-builder.mjs +24 -4
  9. package/dist/contract-builder.mjs.map +1 -1
  10. package/dist/contract__validate-once.d.mts +1 -0
  11. package/dist/contract__validate-once.mjs +2 -0
  12. package/dist/control.d.mts +1 -1
  13. package/dist/control.d.mts.map +1 -1
  14. package/dist/control.mjs +1 -1
  15. package/dist/control.mjs.map +1 -1
  16. package/dist/family-contract__data-type-support.d.mts +1 -0
  17. package/dist/family-contract__data-type-support.mjs +2 -0
  18. package/dist/family-contract__data-type.d.mts +1 -0
  19. package/dist/family-contract__data-type.mjs +2 -0
  20. package/dist/family-contract__sql-expression.d.mts +1 -0
  21. package/dist/family-contract__sql-expression.mjs +2 -0
  22. package/dist/family__psl-build.d.mts +1 -0
  23. package/dist/family__psl-build.mjs +2 -0
  24. package/dist/relational-core__collection-methods.d.mts +1 -0
  25. package/dist/relational-core__collection-methods.mjs +2 -0
  26. package/dist/relational-core__functions.d.mts +1 -0
  27. package/dist/relational-core__functions.mjs +2 -0
  28. package/dist/relational-core__index-reference.d.mts +1 -0
  29. package/dist/relational-core__index-reference.mjs +2 -0
  30. package/dist/runtime.d.mts +3 -3
  31. package/dist/runtime.d.mts.map +1 -1
  32. package/dist/runtime.mjs +107 -62
  33. package/dist/runtime.mjs.map +1 -1
  34. package/dist/sqlite-Yizsft25-C2Eb0g8b.d.mts +94 -0
  35. package/dist/sqlite-Yizsft25-C2Eb0g8b.d.mts.map +1 -0
  36. package/dist/sqlite-static-DHwrAnt0-c2gsEamQ.mjs +83 -0
  37. package/dist/sqlite-static-DHwrAnt0-c2gsEamQ.mjs.map +1 -0
  38. package/dist/static.d.mts +25 -2
  39. package/dist/static.d.mts.map +1 -0
  40. package/dist/static.mjs +2 -2
  41. package/dist/target__data-types.d.mts +1 -0
  42. package/dist/target__data-types.mjs +2 -0
  43. package/dist/utils__suppress-idle-connection-errors.d.mts +1 -0
  44. package/dist/utils__suppress-idle-connection-errors.mjs +2 -0
  45. package/dist/utils__text.d.mts +1 -0
  46. package/dist/utils__text.mjs +2 -0
  47. package/package.json +26 -15
  48. package/skills/prisma-8/SKILL.md +96 -0
  49. package/skills/prisma-8/references/build.md +142 -0
  50. package/skills/prisma-8/references/contract.md +544 -0
  51. package/skills/prisma-8/references/debug.md +149 -0
  52. package/skills/prisma-8/references/feedback.md +251 -0
  53. package/skills/prisma-8/references/migration-model.md +179 -0
  54. package/skills/prisma-8/references/migration-review.md +211 -0
  55. package/skills/prisma-8/references/migrations.md +581 -0
  56. package/skills/prisma-8/references/queries-mongo.md +238 -0
  57. package/skills/prisma-8/references/queries-postgres.md +710 -0
  58. package/skills/prisma-8/references/queries.md +253 -0
  59. package/skills/prisma-8/references/quickstart.md +317 -0
  60. package/skills/prisma-8/references/runtime.md +463 -0
  61. package/skills/prisma-8/references/supabase.md +234 -0
  62. package/skills/prisma-8/references/upgrade-app.md +102 -0
  63. package/skills/prisma-8/references/upgrade-extension.md +106 -0
  64. package/skills/prisma-8/upgrading/app/upgrades/0.10-to-0.11/instructions.md +56 -0
  65. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/instructions.md +381 -0
  66. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-closed-mongo-contracts.ts +202 -0
  67. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-domain-namespaced-contracts.ts +201 -0
  68. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-postgres-public-default.ts +198 -0
  69. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/strip-migration-labels-hints.ts +340 -0
  70. package/skills/prisma-8/upgrading/app/upgrades/0.12-to-0.13/instructions.md +339 -0
  71. package/skills/prisma-8/upgrading/app/upgrades/0.12-to-0.13/re-emit-mti-variant-link-columns.ts +229 -0
  72. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/instructions.md +543 -0
  73. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/migration-op-factories-to-methods.ts +290 -0
  74. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/uuid-preset-rename.ts +43 -0
  75. package/skills/prisma-8/upgrading/app/upgrades/0.14-to-0.15/instructions.md +359 -0
  76. package/skills/prisma-8/upgrading/app/upgrades/0.15-to-0.16/instructions.md +173 -0
  77. package/skills/prisma-8/upgrading/app/upgrades/0.16-to-0.17/instructions.md +805 -0
  78. package/skills/prisma-8/upgrading/app/upgrades/0.16-to-0.17/strip-sha256-hash-prefixes.ts +382 -0
  79. package/skills/prisma-8/upgrading/app/upgrades/0.17-to-8.0.0-rc.1/instructions.md +72 -0
  80. package/skills/prisma-8/upgrading/app/upgrades/0.7-to-0.8/instructions.md +8 -0
  81. package/skills/prisma-8/upgrading/app/upgrades/0.8-to-0.9/instructions.md +36 -0
  82. package/skills/prisma-8/upgrading/app/upgrades/0.8-to-0.9/strip-inline-contracts.ts +226 -0
  83. package/skills/prisma-8/upgrading/app/upgrades/0.9-to-0.10/instructions.md +86 -0
  84. package/skills/prisma-8/upgrading/app/upgrades/0.9-to-0.10/stamp-storage-types-kind.ts +360 -0
  85. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md +588 -0
  86. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.10-to-8.0.0-rc.11/instructions.md +34 -0
  87. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +639 -0
  88. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/multifile-psl/add-use-prisma-8-directive.mjs +60 -0
  89. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/psl-verbatim-table-names/add-model-map.mjs +256 -0
  90. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/instructions.md +332 -0
  91. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/scripts/execution-ref-entry-field/rename-execution-ref-keys.ts +193 -0
  92. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.13-to-8.0.0-rc.14/instructions.md +489 -0
  93. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/instructions.md +1368 -0
  94. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/scripts/data-type-in-contract/data-type-in-contract.ts +1492 -0
  95. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md +108 -0
  96. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.16-to-8.0.0-rc.17/instructions.md +755 -0
  97. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/instructions.md +973 -0
  98. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/scripts/sql-expression-literals-psl/rewrite-sql-strings.mjs +271 -0
  99. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +1826 -0
  100. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/client-takes-contract-value/contract-from-json.ts +382 -0
  101. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/data-type-values/data-type-values.ts +1117 -0
  102. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/default-generators-to-on-create/rewrite-default-generators.mjs +86 -0
  103. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/mongo-field-storage-names/mongo-field-storage-names.ts +250 -0
  104. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/remove-nocheck/remove-nocheck.ts +813 -0
  105. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +502 -0
  106. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/scripts/expand-type-aliases/expand-type-aliases.ts +1171 -0
  107. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.2-to-8.0.0-rc.3/instructions.md +5 -0
  108. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.3-to-8.0.0-rc.4/instructions.md +158 -0
  109. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.4-to-8.0.0-rc.5/instructions.md +42 -0
  110. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.5-to-8.0.0-rc.6/instructions.md +157 -0
  111. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.6-to-8.0.0-rc.7/instructions.md +33 -0
  112. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.7-to-8.0.0-rc.8/instructions.md +36 -0
  113. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.8-to-8.0.0-rc.9/instructions.md +63 -0
  114. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.9-to-8.0.0-rc.10/instructions.md +84 -0
  115. package/skills/prisma-8/upgrading/extension/upgrades/0.10-to-0.11/instructions.md +276 -0
  116. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/instructions.md +738 -0
  117. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/migrate-contract-testing-imports.ts +97 -0
  118. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/regenerate-extension-public-baseline.ts +223 -0
  119. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/strip-migration-labels-hints.ts +340 -0
  120. package/skills/prisma-8/upgrading/extension/upgrades/0.12-to-0.13/instructions.md +266 -0
  121. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/instructions.md +522 -0
  122. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/migration-op-factories-to-methods.ts +290 -0
  123. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/uuid-preset-rename.ts +43 -0
  124. package/skills/prisma-8/upgrading/extension/upgrades/0.14-to-0.15/instructions.md +803 -0
  125. package/skills/prisma-8/upgrading/extension/upgrades/0.15-to-0.16/instructions.md +219 -0
  126. package/skills/prisma-8/upgrading/extension/upgrades/0.16-to-0.17/instructions.md +731 -0
  127. package/skills/prisma-8/upgrading/extension/upgrades/0.16-to-0.17/strip-sha256-hash-prefixes.ts +382 -0
  128. package/skills/prisma-8/upgrading/extension/upgrades/0.17-to-8.0.0-rc.1/instructions.md +194 -0
  129. package/skills/prisma-8/upgrading/extension/upgrades/0.7-to-0.8/instructions.md +8 -0
  130. package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/instructions.md +57 -0
  131. package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/strip-inline-contracts.ts +226 -0
  132. package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/instructions.md +150 -0
  133. package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/stamp-storage-types-kind.ts +360 -0
  134. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md +746 -0
  135. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.10-to-8.0.0-rc.11/instructions.md +34 -0
  136. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +857 -0
  137. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/psl-verbatim-table-names/add-model-map.mjs +256 -0
  138. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/instructions.md +504 -0
  139. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/scripts/execution-ref-entry-field/rename-execution-ref-keys.ts +193 -0
  140. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.13-to-8.0.0-rc.14/instructions.md +143 -0
  141. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/instructions.md +2168 -0
  142. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/scripts/data-type-in-contract/data-type-in-contract.ts +1492 -0
  143. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md +223 -0
  144. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.16-to-8.0.0-rc.17/instructions.md +583 -0
  145. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/instructions.md +1008 -0
  146. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +2000 -0
  147. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/client-takes-contract-value/contract-from-json.ts +382 -0
  148. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/remove-nocheck/remove-nocheck.ts +813 -0
  149. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +379 -0
  150. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/scripts/expand-type-aliases/expand-type-aliases.ts +1171 -0
  151. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.2-to-8.0.0-rc.3/instructions.md +5 -0
  152. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.3-to-8.0.0-rc.4/instructions.md +137 -0
  153. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.4-to-8.0.0-rc.5/instructions.md +129 -0
  154. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.5-to-8.0.0-rc.6/instructions.md +102 -0
  155. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.6-to-8.0.0-rc.7/instructions.md +33 -0
  156. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.7-to-8.0.0-rc.8/instructions.md +35 -0
  157. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.8-to-8.0.0-rc.9/instructions.md +86 -0
  158. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.9-to-8.0.0-rc.10/instructions.md +63 -0
  159. package/dist/family-contract__pack-types.d.mts +0 -1
  160. package/dist/family-contract__pack-types.mjs +0 -2
  161. package/dist/sqlite-CjWZostj-Cprd7rkt.d.mts +0 -76
  162. package/dist/sqlite-CjWZostj-Cprd7rkt.d.mts.map +0 -1
  163. package/dist/sqlite-static-CBCbqogG-BtpT_pWA.mjs +0 -44
  164. package/dist/sqlite-static-CBCbqogG-BtpT_pWA.mjs.map +0 -1
  165. package/dist/target__native-type-normalizer.d.mts +0 -1
  166. package/dist/target__native-type-normalizer.mjs +0 -2
@@ -0,0 +1,502 @@
1
+ ---
2
+ from: "8.0.0-rc.19"
3
+ to: "8.0.0-rc.20"
4
+ changes:
5
+ - id: stored-contracts-expand-type-aliases
6
+ summary: |
7
+ A stored SQL contract whose columns name a type alias in `typeRef` no longer loads. Run `scripts/expand-type-aliases/expand-type-aliases.ts` from the project root, then re-emit the contract, then run `prisma db sign` against every database. The script writes each alias's parameters into the columns typed by it, in every stored contract, migration snapshots and the emitted `contract.json` included, and refreshes every hash and reference that changes.
8
+ detection:
9
+ glob: "**/contract.json"
10
+ matches:
11
+ - '"typeRef"\s*:'
12
+ script: scripts/expand-type-aliases/expand-type-aliases.ts
13
+ - id: psl-alias-attributes
14
+ summary: |
15
+ No action is needed. A `types {}` alias in PSL may now carry `@default`, `@onCreate` and `@onUpdate`, and the targets contribute `temporal.CreatedAt` and `temporal.UpdatedAt`. Aliases are still valid PSL, so a `contract.prisma` that uses them does not change.
16
+ - id: ts-types-key-removed
17
+ summary: |
18
+ The TypeScript contract builder no longer takes a `types` key, and `field.namedType(...)` accepts only an enum. Replace `types: { X: type.Y(...) }` and each `field.namedType(types.X)` with a constant `const X = field.column(type.Y(...))` used as the field, and remove `types` from the object the contract returns. A `types` entry written `{ kind: 'codec-instance', codecId, typeParams }` becomes such a constant too if a field uses it; delete it if no field uses it. No `types` key stays in the contract. Re-emit the contract. The detection matches TypeScript files that call `field.namedType` with an alias or a string, or that return a `types` key from `defineContract`.
19
+ detection:
20
+ glob: "**/*.{ts,mts,cts,tsx}"
21
+ matches:
22
+ - '(?<![\w$])field\.namedType\(\s*(?:types\b|[\x27"`])'
23
+ - '(?<![\s\S])(?=[\s\S]*\bdefineContract\()[\s\S]*(?<![\w$.\x27"])types\s*(?::(?!\s*(?:field\.|\{\s*codecTypes\b))|,|\})'
24
+ - id: supabase-contract-expanded
25
+ summary: |
26
+ The `@prisma/orm-extension-supabase` contract no longer stores its nine type aliases, so the Supabase space's storage hash changes. Run `prisma db sign` against every database after upgrading.
27
+ detection:
28
+ glob: "**/package.json"
29
+ matches:
30
+ - '"@prisma/orm-extension-supabase"'
31
+ - id: engine-pin-moves-to-0-9-0
32
+ summary: |
33
+ The toolchain now requires `@prisma/cli-engine@0.9.0` (up from 0.7.0). A project that depends on `@prisma/cli-engine` itself must move to `0.9.0`.
34
+ detection:
35
+ glob: "**/package.json"
36
+ matches:
37
+ - '"@prisma/cli-engine":\s*"[^"]*(?<![\d.])0\.[0-8](?!\d)'
38
+ - id: piped-output-needs-json
39
+ summary: |
40
+ A piped Prisma ORM command no longer prints JSON. Without `--json`, stdout receives the command's plain data lines, such as one tab-separated line per migration. A script that reads JSON from `prisma contract …`, `prisma db …`, `prisma migration …` or `prisma orm init` must pass `--json`.
41
+ - id: access-changes-rename
42
+ summary: |
43
+ `accessWidening` is renamed `accessChanges`, because it also lists changes that do not widen access. The `db update --dry-run --json` output key and `DbUpdateSuccess.accessWidening` become `accessChanges`, and the `executeDbUpdate` and control client `dbUpdate` option `acceptAccessWidening` becomes `acceptAccessChanges`. There is no alias for the old names.
44
+ detection:
45
+ glob: "**/*.{ts,tsx,mts,cts,js,mjs,cjs,sh,bash,yml,yaml}"
46
+ matches:
47
+ - '(?<![\w$])(?:acceptAccessWidening|accessWidening)(?![\w$])'
48
+ - id: removed-namespace-questions
49
+ summary: |
50
+ On Postgres, when the contract no longer declares a namespace the database's contract declared, `migration plan` and `db update` plan to drop its tables, asking about each model, and then the schema. Before, those tables were left in place without a word. If the namespace was renamed, say so with `--rename <old namespace>:<new namespace>`, which renames the schema and keeps every row. Answer with `--delete <namespace>` to let the tables go, or keep a model by moving it with `--rename <namespace>.<Model>:<other namespace>.<Model>`.
51
+ - id: schema-verification-failed-schema-issues
52
+ summary: |
53
+ The `CONTRACT.SCHEMA_VERIFICATION_FAILED` diagnostic of `db verify --json` and `db sign --json` carries the schema differences in `meta.schemaIssues`, as issue objects, instead of `meta.issues`, as label strings. Code that reads `meta.issues` from that diagnostic reads `meta.schemaIssues` instead.
54
+ detection:
55
+ glob: "**/*.{ts,tsx,mts,cts,js,mjs,cjs}"
56
+ matches:
57
+ - '(?<![\s\S])(?=[\s\S]*(?:\bdb (?:verify|sign)\b|SCHEMA_VERIFICATION_FAILED))[\s\S]*\bmeta(?:\?\.|\.|\?\.\[|\[)(?:issues\b|[''"]issues[''"]\])'
58
+ - id: check-expectation
59
+ summary: |
60
+ A migration check that expects one object to be absent or present can now say so in an optional `expectation` field, and a failed precheck's message then names the object: `That check failed: the database already has index "Item_state_idx".` instead of `That check failed on this database.` Checks written without it keep working and keep the generic sentence.
61
+ detection:
62
+ glob: "**/ops.json"
63
+ matches:
64
+ - '(?:\{\s*"description": "(?:[^"\\]|\\.)*",\s*"sql": "(?:SELECT (?:NOT )?EXISTS \(SELECT 1 AS \\"one\\" FROM \\"(?:information_schema\\"\.\\"columns|pg_extension|pg_constraint|pg_class|pg_policies|pg_type|pg_enum|pg_indexes|pg_namespace)\\"(?: AS \\"\w+\\")?(?: INNER JOIN \\"pg_(?:namespace|type|class)\\" AS \\"\w+\\" ON \\"\w+\\"\.\\"\w+\\" = \\"\w+\\"\.\\"\w+\\")* WHERE (?:[^"\\]|\\"(?:table_schema|table_name|column_name|extname|conname|connamespace|conrelid|nspname|schemaname|tablename|policyname|indexname|typname|typnamespace|enumlabel|enumtypid|relname|relkind|oid|type|name|c|n|t|e|i|p)\\")*?\) AS \\"result\\"|SELECT \(to_regclass\(\$\d+\)\) IS (?:NOT )?NULL AS \\"result\\"|SELECT COUNT\(\*\) (?:= 0|> 0) AS \\"result\\" FROM (?:\\"sqlite_master\\"|pragma_table_info\([^)"]*\)|pragma_index_list\([^)"]*\)) WHERE (?:[^"\\]|\\"(?:table_schema|table_name|column_name|extname|conname|connamespace|conrelid|nspname|schemaname|tablename|policyname|indexname|typname|typnamespace|enumlabel|enumtypid|relname|relkind|oid|type|name|c|n|t|e|i|p)\\")*?)"(?:,\s*"params": \[[^\]]*\])?\s*\}|"source": \{\s*"kind": "list(?:Indexes|Collections)"(?:,\s*"collection": "(?:[^"\\]|\\.)*")?\s*\},\s*"filter": \{\s*"kind": "field",(?:[^{}]|\{[^{}]*\})*\},\s*"expect": "(?:exists|notExists)"\s*\})'
65
+ - id: check-expectation-raw-sql
66
+ summary: |
67
+ A precheck or postcheck you write by hand in a `rawSql` operation of a `migration.ts` can carry `expectation`, `{ expects: 'absent' | 'present', object }`, so a failure of it names the object. Add it where the check asks whether one object exists, then run `node migration.ts` for a migration no database has applied yet.
68
+ detection:
69
+ glob: "**/migration.ts"
70
+ matches:
71
+ - '\brawSql\(\{[\s\S]*?\b(?:precheck|postcheck):\s*\[(?:\s*\{(?:[^{}]|\{[^{}]*\})*\},)*?\s*\{[^{}]*\}'
72
+ - id: mongo-quoted-enum-members
73
+ summary: |
74
+ A MongoDB PSL `enum` member is now read in the syntax of its codec's data type, as on SQL, and a quoted member is text. A quoted member on a type that does not take text is refused with `PSL_VALUE_TYPE_INCOMPATIBLE` at the member: write a Double's `"NaN"`, `"Infinity"` and `"-Infinity"` and an Int64's or Decimal128's number unquoted (`Unknown = NaN`, `Big = 9007199254740993`, `Half = 0.5`), a Date member as `` date`2024-01-01T00:00:00Z` `` and a Binary member as `` binary`aGVsbG8=` ``. A Decimal128 `"-0"` cannot be written in PSL any more, because `-0` is an int32 zero: write `0`, or declare the enum in TypeScript. The detection matches an enum on one of those codecs with a quoted member.
75
+ detection:
76
+ glob: "**/*.prisma"
77
+ matches:
78
+ - 'enum\s+\w+\s*\{(?=[^}]*@@type\(\s*"mongo/(?:double|int64|int64Number|decimal128|date|binary)@1"\s*\))[^}]*\n\s*\w+\s*=\s*"'
79
+ - id: mongo-integer-enum-members-with-a-fraction
80
+ summary: |
81
+ A MongoDB PSL number with a fraction, such as `1.0`, is now a Decimal128 value, and no integer type casts from Decimal128, so an Int32 or Int64 member written with a fraction is refused with `PSL_VALUE_TYPE_INCOMPATIBLE` (`Expected a number that mongo/int32 can hold; got mongo/decimal128`). Write the whole number, `One = 1`. The detection matches an Int32 or Int64 enum with a member written with a fraction.
82
+ detection:
83
+ glob: "**/*.prisma"
84
+ matches:
85
+ - 'enum\s+\w+\s*\{(?=[^}]*@@type\(\s*"mongo/(?:int32|int64|int64Number)@1"\s*\))[^}]*\n\s*\w+\s*=\s*-?\d+\.\d'
86
+ - id: discriminator-optional-or-list
87
+ summary: |
88
+ A `@@discriminator` field must be required and hold one value, in SQL and MongoDB schemas alike. An optional field is refused with `Discriminator field "<field>" on model "<Model>" must be required, but it is optional. Remove the "?"`, and a list with `... must hold one value, but it is a list. Remove the "[]"`, both `PSL_INVALID_ATTRIBUTE_ARGUMENT`. Make the field required and single: a document or row without the value has no variant. The detection matches a model whose `@@discriminator` names a field declared with `?` or `[]`.
89
+ detection:
90
+ glob: "**/*.prisma"
91
+ matches:
92
+ - 'model\s+\w+\s*\{(?=[^}]*@@discriminator\(\s*(\w+)\s*\))[^}]*\n\s*\1\s+[\w.]+(?:\?|\[\])'
93
+ - id: discriminator-base-value-not-a-member
94
+ summary: |
95
+ When an enum types a `@@discriminator` field, each `@@base` value must be one of the enum's members, as the field stores them. A value that is not is refused at the value with `PSL_INVALID_ATTRIBUTE_ARGUMENT`: `Model "<Variant>" declares @@base value "<value>", which is not a member of enum "<Enum>", the type of discriminator field "<Model>.<field>". Write one of: ...`. Write a member's stored value, or add the value to the enum. The detection matches a schema that declares both a `@@discriminator` and an `enum`; check each `@@base` value of a discriminator typed by an enum.
96
+ detection:
97
+ glob: "**/*.prisma"
98
+ matches:
99
+ - '(?<![\s\S])(?=[\s\S]*@@discriminator\()(?=[\s\S]*(?:^|\n)\s*enum\s+\w+\s*\{)[\s\S]*@@base\('
100
+ - id: psl-value-refused-code
101
+ summary: |
102
+ An enum member or `@@base` value that the receiving data type or codec refuses now reports `PSL_VALUE_REFUSED`, in SQL and MongoDB schemas. SQL reported `PSL_INVALID_DEFAULT_LITERAL` for these, and MongoDB reported `PSL_EXTENSION_INVALID_VALUE` (`was rejected by codec`) for a member. A member written in a form its type does not take reports `PSL_VALUE_TYPE_INCOMPATIBLE`, and text an entry or a cast cannot read reports `PSL_INVALID_LITERAL`. Update code or tests that match these codes or messages. A MongoDB discriminator that is not text now says `must be text, such as String`, as SQL does, in place of `must be of type String`, and a type alias of `String` is accepted as a discriminator. The detection matches code that names the old member code or messages.
103
+ detection:
104
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
105
+ matches:
106
+ - 'was rejected by codec \\?"mongo/'
107
+ - 'must be of type String'
108
+ - '(?=[\s\S]*@@base\()[\s\S]*PSL_INVALID_DEFAULT_LITERAL'
109
+ - id: decimal128-spelling
110
+ summary: |
111
+ `mongo/decimal128` stores its values as MongoDB writes them: without leading zeros, keeping negative zero, and only a value a Decimal128 holds exactly. A `contract.json` that stores a Decimal128 value with leading zeros, such as `"007.5"`, is refused when it is loaded with `RUNTIME.DECODE_FAILED`, which names the value to store; emit the contract again. A TypeScript enum member such as `member('Half', '007.5')` is stored as `7.5`, so its contract gets a new hash on the next emit. A value with more than 34 significant digits, counting zeros after the decimal point, such as `1.000000000000000000000000000000000000`, is refused in PSL, TypeScript and `contract.json` instead of being rounded; write a value with at most 34 significant digits. The detection matches a Decimal128 value with leading zeros or more than 34 digits.
112
+ detection:
113
+ glob: "**/*.{json,ts,mts,cts,tsx,prisma}"
114
+ matches:
115
+ - 'mongo/decimal128@1[\s\S]*?(?:[=,(:]\s*["\x27`]?-?0\d|[=,(:]\s*["\x27`]?-?\d[\d.]{35,})'
116
+ - id: sql-builder-insert-required-columns
117
+ summary: |
118
+ A SQL builder insert, `db.sql.<namespace>.<table>.insert(rows)`, must now include every column that is not nullable and has no default. Leaving one out is a type error that names the column, and so is a value typed `T | undefined` for such a column. Add a real value, narrowed to `T`.
119
+ detection:
120
+ glob: "**/*.{ts,tsx,mts,cts}"
121
+ matches:
122
+ - '\.insert\('
123
+ - id: orm-create-on-update-only-field
124
+ summary: |
125
+ In ORM `create` and `upsert`, a field that is not nullable, has no default and generates a value only on update is now required. That is a field with `@onUpdate(...)` and no `@onCreate(...)`, a temporal preset with only its update phase such as `temporal.timestamptz(onUpdate: now)` or `field.temporal.timestamptz(undefined, undefined, 'now')`, or a TypeScript field with `.onUpdate(...)` and no `.onCreate(...)`. Pass a value for it on create, or make it generate on create too.
126
+ detection:
127
+ glob: "**/*.{prisma,ts}"
128
+ matches:
129
+ - '@onUpdate\('
130
+ - 'onUpdate:\s*now'
131
+ - '\.onUpdate\('
132
+ - '\.temporal\.\w+\([^)]*,\s*[''"]now[''"]'
133
+ - id: supabase-for-role-replaces-with-role-methods
134
+ summary: |
135
+ `SupabaseRuntime` no longer has `queryWithRole`, `executeWithRole`, `preparedQueryWithRole` or `preparedExecuteWithRole`, and `SupabaseRuntimeImpl` no longer has `roleActivitySource`. Call `runtime.forRole(binding)` once and use its members: `runtime.queryWithRole(plan, binding, options)` becomes `runtime.forRole(binding).query(plan, options)`, `executeWithRole` becomes `forRole(binding).execute`, and a prepared statement runs on the role with `statement.query(runtime.forRole(binding), params)` or `statement.execute(runtime.forRole(binding), params)`. The detection matches files that call one of the removed methods.
136
+ detection:
137
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
138
+ matches:
139
+ - '\.(?:queryWithRole|executeWithRole|preparedQueryWithRole|preparedExecuteWithRole|roleActivitySource)\('
140
+ - id: supabase-role-types-gain-members
141
+ summary: |
142
+ Three public Supabase types require new members, so a test double or hand-built object typed with them stops compiling. `RoleBoundDb` and `ServiceRoleDb` gain `enums` and `nativeEnums`. `SupabaseTransactionContext` is now `PostgresTransactionContext`, so it gains `enums` and `nativeEnums` too. `SupabaseRuntime` requires `forRole(binding)`, which returns a `SupabaseRoleScope` (`query`, `execute`, the prepared-statement operations and `connection`), in place of the four removed `*WithRole` methods. Add the members to each double: take `enums` and `nativeEnums` from `postgresStatic({ contract })` of `@prisma/orm-postgres/static`, or from a role-bound client. The detection matches files that name one of these types.
143
+ detection:
144
+ glob: "**/*.{ts,mts,cts,tsx}"
145
+ matches:
146
+ - '(?<![\w$])(?:RoleBoundDb|ServiceRoleDb|SupabaseTransactionContext|SupabaseRuntime)(?![\w$])'
147
+ - id: supabase-pg-takes-a-pool
148
+ summary: |
149
+ The `pg` option of `supabase()` takes a `pg.Pool` only. A `pg.Client` is a type error and fails at `supabase()` with `SUPABASE.CONFIG_INVALID`. Replace `pg: new Client(...)` with `pg: new Pool(...)` built from the same settings, or pass `url`. The detection matches every `supabase()` call that passes `pg`; leave a call that already passes a `pg.Pool` as it is.
150
+ detection:
151
+ glob: "**/*.{ts,mts,cts,tsx,js,mjs,cjs}"
152
+ matches:
153
+ - '(?<![\w$.])supabase(?:<[^>]*>)?\(\s*\{(?:[^{}]|\{[^{}]*\})*?(?<![\w$.])pg\s*[:,}]'
154
+ - id: supabase-close-waits-for-work
155
+ summary: |
156
+ `db.close()` on a Supabase client now refuses new work at once on every role-bound client and on `.supabase`, with `DRIVER.NOT_CONNECTED` "Runtime is closed", and waits for work already running, open role transactions included, before it ends the pool. With a pool you passed as `pg`, a query after `close()` used to throw at the call; its promise now rejects instead. Await every role transaction before `close()`, or `close()` waits for it.
157
+ - id: contract-artifacts-restamp
158
+ summary: |
159
+ An extension that writes its own package version into the contracts it emits, such as the Supabase extension, now writes 8.0.0-rc.20. Run `contract emit` once after upgrading so the emitted `contract.json` and `contract.d.ts` match the installed extension.
160
+ detection:
161
+ glob: "**/contract.json"
162
+ contains:
163
+ - '"version": "8.0.0-rc.19"'
164
+ ---
165
+
166
+ # 8.0.0-rc.19 → 8.0.0-rc.20 — User upgrade instructions
167
+
168
+ ## Order of the steps
169
+
170
+ Two changes in this release change storage hashes: the type-alias change (`stored-contracts-expand-type-aliases`) and the re-emitted Supabase contract (`supabase-contract-expanded`). Do the steps in this order, and skip a step that does not apply to the project:
171
+
172
+ 1. Commit your work, so the script's changes can be reviewed and undone with git. Then upgrade the Prisma packages. If the project depends on `@prisma/cli-engine` itself, move it to `0.9.0` (`engine-pin-moves-to-0-9-0`).
173
+ 2. Rewrite the stored contracts, from the project root, with `scripts/expand-type-aliases/expand-type-aliases.ts` (`stored-contracts-expand-type-aliases`). It leaves a project without type aliases unchanged and says so.
174
+ 3. Change the contract source as the entries below say: a TypeScript contract drops its `types` key (`ts-types-key-removed`), and a MongoDB schema rewrites the enum members and discriminators the MongoDB entries name.
175
+ 4. Run `prisma contract emit` (this also covers `contract-artifacts-restamp`).
176
+ 5. Run `prisma db sign` against every database when step 2 changed a storage hash, or when the project uses the Supabase extension.
177
+ 6. For each migration that is not applied yet and that `check-expectation` or `check-expectation-raw-sql` matches, run its `migration.ts` again. This is optional.
178
+ 7. Change the application code and scripts: add `--json` where a script parses a command's output (`piped-output-needs-json`), rename `accessWidening` (`access-changes-rename`), read `meta.schemaIssues` (`schema-verification-failed-schema-issues`), complete SQL builder inserts and ORM creates (`sql-builder-insert-required-columns`, `orm-create-on-update-only-field`), and move Supabase code to `forRole` (`supabase-for-role-replaces-with-role-methods` and the entries after it).
179
+
180
+ The script path is relative to the directory that holds this guide, which the commands below call `<guide>`.
181
+
182
+ ## Type aliases are written into each column
183
+
184
+ A type alias is now authoring shorthand only. In PSL, `types { Slug = VarChar(64) }` still works, but the contract no longer stores `Slug` in `storage.types` with a `typeRef` on each column that uses it. Each column stores the alias's codec and parameters itself. In TypeScript, an alias is a constant field builder.
185
+
186
+ Do the steps in this order: run the script that rewrites the stored contracts (`stored-contracts-expand-type-aliases`), change the TypeScript contract source if you have one (`ts-types-key-removed`), re-emit the contract, and then sign every database.
187
+
188
+ ### `stored-contracts-expand-type-aliases`
189
+
190
+ Migration snapshots, the emitted `contract.json` and any other stored contract written by an earlier release may have a column with a `typeRef`. This release refuses such a contract and says to re-emit it or run this script. A historical snapshot cannot be re-emitted from today's source, so run the script. Commit your work first so the script's changes can be reviewed and undone with git. Run it from the project root:
191
+
192
+ ```sh
193
+ node <guide>/scripts/expand-type-aliases/expand-type-aliases.ts
194
+ ```
195
+
196
+ `<guide>` is the directory that holds this guide. Node 24 or later runs the TypeScript script directly; it needs no `tsx`. The script reads and writes files only and needs no database. It rewrites every SQL contract under the root, skipping `node_modules`, `.git`, `dist` and `build`. That includes a test fixture of an old contract: if you keep one on purpose, restore it with git afterwards.
197
+
198
+ In each contract it replaces every column's `typeRef` with the parameters of the `storage.types` entry it names, and removes each entry a column named. In a contract of your app's own contract space it also removes every entry that no column names. Your app's contract never needs such an entry: it is an alias that the source declares but no field uses, which a re-emit drops as well, or, in a TypeScript source, a `codec-instance` entry that no field uses, which `ts-types-key-removed` tells you to delete. Only an extension's contract space registers a database type. So in a contract of an extension's contract space, such as the copy of pgvector's space in `migrations/snapshots/`, the script keeps an entry that no column names, such as `vector`, and lists it. It makes the same change in the `contract.d.ts` next to the contract. The script tells the spaces apart by the migrations directory: a snapshot that a migration or ref under `migrations/app/` names is your app's, and one that a migration or ref under any other `migrations/<space>/` names is an extension's. A snapshot that no migration or ref names may be either, so the script keeps its unused entries and lists them. The emitted `contract.json` is your app's.
199
+
200
+ The storage hash changes, so the script renames each changed snapshot directory to its new hash. It rewrites every `migration.json`, ref, `migration.ts` and `contract.d.ts` that names an old hash, and gives each changed migration a new `migrationHash`. When it finishes, it prints how many files it rewrote, how many snapshot directories it renamed, each storage hash it replaced (`<old> -> <new>`), each `storage.types` entry it removed, per contract, and each entry it kept. A project with no `typeRef` is left unchanged, and the script says so. The script replaces the hashes in the import paths of `migration.ts` where they are, so if your project sorts imports with a linter, run its fix command afterwards.
201
+
202
+ It changes no file and exits 1 in these cases, and names the file:
203
+
204
+ - a `contract.json`, `migration.json`, `ops.json` or ref is not valid JSON;
205
+ - a contract's stored storage hash, or the name of its snapshot directory, does not match its content;
206
+ - a column names an alias that `storage.types` does not declare, stores both `typeRef` and `typeParams`, or has a codec or data type other than its alias's;
207
+ - a migration goes between two snapshots that become the same snapshot once their aliases are written into their columns, and has no data operation;
208
+ - a renamed snapshot directory already exists with different content.
209
+
210
+ For the first three cases, restore that file from version control, or re-emit it, and run the script again. Two snapshots become the same one when the only change between them was an alias: a migration that replaced `slug VarChar(64)` with `types { Slug = VarChar(64) }` and `slug Slug`, or that renamed an alias. After the upgrade such a migration goes from a snapshot to itself, which only a migration with a data operation may do. The script names each such migration that has no data operation. Delete its directory and run the script again. When that migration is your latest, nothing else names its target snapshot, so the script names that snapshot directory too; delete it as well. The script then writes the hash of the merged snapshot into every `migration.json`, ref and `migration.ts` that names either old hash, and gives each changed migration a new `migrationHash`. A migration with a data operation keeps its operations and goes from the merged snapshot to itself. If it stops partway, for example on a full disk, it says so; run it again to finish.
211
+
212
+ If you upgrade from a release before 8.0.0-rc.19 and also run `remove-nocheck.ts` from the 8.0.0-rc.18 to 8.0.0-rc.19 guide, the two scripts may run in either order: each checks the hash of the content it reads.
213
+
214
+ Then re-emit the contract with `prisma contract emit`. A contract written in PSL gives the contract the script wrote, so the latest snapshot, the head ref and the emitted contract keep one storage hash. A contract written in TypeScript needs `ts-types-key-removed` first.
215
+
216
+ Each database's marker still holds the old storage hash, so `prisma db verify` and `prisma db migrate` refuse it until you sign it. The database itself does not change. After the re-emit, run `prisma db sign` against every database (development, staging, production):
217
+
218
+ ```sh
219
+ prisma db sign --db "$DATABASE_URL"
220
+ ```
221
+
222
+ The script has already written the new hash into each ref, so when `db sign` advances a ref, such as `migrations/app/refs/db.json`, it prints the new hash twice: `Advanced ref "db" → <new hash> (was <new hash>)`. This is expected, and the database is signed.
223
+
224
+ The script also gives each rewritten migration a new hash, and the database's migration history keeps the old ones. After the upgrade, `prisma migration status` therefore no longer marks the migrations applied before it as applied, although it still reports the database as up to date. `prisma db migrate` runs none of them again, and `prisma db verify` passes.
225
+
226
+ ### `psl-alias-attributes`
227
+
228
+ There is nothing to change. PSL gains two things:
229
+
230
+ ```prisma
231
+ types {
232
+ Slug = VarChar(64)
233
+ UpdatedAt = TimestampString(3) @onCreate(now()) @onUpdate(now())
234
+ }
235
+
236
+ model Post {
237
+ id String @id @onCreate(uuid())
238
+ slug Slug
239
+ createdAt temporal.CreatedAt
240
+ updatedAt UpdatedAt @default(now())
241
+ }
242
+ ```
243
+
244
+ - An alias may carry `@default`, `@onCreate` and `@onUpdate`. Each field typed by it gets them. A field may add an attribute its alias does not set, but writing one the alias already sets is the error `PSL_DUPLICATE_ATTRIBUTE`. `@id` and `@unique` belong on the field, not the alias.
245
+ - Postgres, SQLite and MongoDB contribute `temporal.CreatedAt` and `temporal.UpdatedAt`, written bare as a field type. Each stores exactly what `temporal.createdAt()` and `temporal.updatedAt()` store. Postgres also has `temporal.CreatedAtString`, `temporal.UpdatedAtString`, `temporal.CreatedAtJsDate` and `temporal.UpdatedAtJsDate`.
246
+
247
+ ### `ts-types-key-removed`
248
+
249
+ Write an alias as a constant field builder and use it as the field:
250
+
251
+ ```ts
252
+ // Before
253
+ ({ field, model, type }) => {
254
+ const types = { Embedding1536: type.pgvector.Vector(1536) } as const;
255
+ const Post = model('Post', {
256
+ fields: {
257
+ embedding: field.namedType(types.Embedding1536).optional(),
258
+ },
259
+ });
260
+ return { types, models: { Post } };
261
+ }
262
+
263
+ // After
264
+ ({ field, model, type }) => {
265
+ const Embedding1536 = field.column(type.pgvector.Vector(1536));
266
+ const Post = model('Post', {
267
+ fields: {
268
+ embedding: Embedding1536.optional(),
269
+ },
270
+ });
271
+ return { models: { Post } };
272
+ }
273
+ ```
274
+
275
+ A field builder is immutable, so one constant serves every model. `type.*` now has a helper for every PSL type constructor of the stack, such as `type.VarChar(64)` and `type.TimestampString(3)`, and for the contributed aliases, such as `field.column(type.temporal.UpdatedAt())`. A string such as `field.namedType('Slug')` named an alias the same way; replace it with the alias's constant.
276
+
277
+ `field.namedType(...)` still takes an enum handle, such as `field.namedType(Priority)`; leave those calls alone.
278
+
279
+ A `types` key left in the definition fails with `CONTRACT.TYPES_KEY_REMOVED`. An entry may also be written `{ kind: 'codec-instance', codecId: ..., typeParams: ... }`. If a field uses it, through `field.namedType(types.X)` or `field.namedType('X')`, replace it with a constant `field.column(type.Y(...))` of the same type and parameters, as above. If no field uses it, delete it. Your app's contract space never needs a registered database type: only an extension's contract space registers one, under `databaseTypes`. The script removed such an entry from your stored contracts and listed it in its summary, so the re-emit gives the storage hash the script wrote.
280
+
281
+ Two calls that set the same thing on one builder now fail instead of the second one winning. `.default()` on a builder that already has a default throws `CONTRACT.DEFAULT_INVALID` with reason `default-set-twice`, and `.onCreate()` or `.onUpdate()` on a builder that already sets that phase throws, as before.
282
+
283
+ Re-emit the contract. If you ran `stored-contracts-expand-type-aliases`, the column gets the same type and parameters it had, so there is nothing more to sign or migrate.
284
+
285
+ ### `supabase-contract-expanded`
286
+
287
+ The `@prisma/orm-extension-supabase` contract is re-emitted from its PSL, which keeps its nine aliases. The contract no longer stores them in `storage.types`, and each column stores its own type. The Supabase space's storage hash changes from `292489649ae6d6928de98a32b544bd9caf6b7d49718c10fe2720b83545a4b5a2` to `110ad99e1e466691bdb0a4349a17365561e76ad017f58beb272f4496b05b8e9e`.
288
+
289
+ A contract that composes the Supabase space references it by id, so this change does not touch your own `contract.json` and `contract.d.ts`. Only the extension version stamped in them moves, which `contract-artifacts-restamp` covers. A database that was signed against the previous Supabase contract no longer matches the new hash, so run `prisma db sign` against it after upgrading. The Supabase database itself does not change.
290
+
291
+ ## The CLI engine is 0.9.0, and piped output needs `--json`
292
+
293
+ ### `engine-pin-moves-to-0-9-0`
294
+
295
+ For every `package.json` matched by `detection`, change the `@prisma/cli-engine` version (`0.7.0`, `^0.7.0` or any other 0.x below 0.9) to `0.9.0` and reinstall. Projects assembled by the `prisma` CLI resolve the engine automatically.
296
+
297
+ ### `piped-output-needs-json`
298
+
299
+ Engine 0.9.0 chooses the output format from flags only. Before, a command whose stdout was not a terminal (a pipe, a file, `$(…)`, a CI log or an agent) printed JSON frames. Now it prints the human card on stderr and the command's data lines on stdout. JSON needs `--json`.
300
+
301
+ Find every place that runs a Prisma ORM command and parses its stdout as JSON: `package.json` scripts and shell scripts that pipe into `jq`, CI steps, and code that spawns `prisma` and calls `JSON.parse` on its output. Add `--json` to each such command. For example, `prisma migration status | jq '.envelope.result'` becomes `prisma migration status --json | jq '.envelope.result'`.
302
+
303
+ A script that only needs a list or a value can read the data lines instead. Fields are separated by a tab and come in the order below. A field whose JSON value is null or absent is an empty field. A backslash, tab, newline or carriage return inside a value is written as `\\`, `\t`, `\n` or `\r`. Paths are relative to the working directory. New fields are only ever added at the end of a line.
304
+
305
+ - `migration list`: space, name, from, to and operation count, one line per migration.
306
+ - `migration status`: space, name, from, to, operation count and status (`applied`, `pending`, or empty when the JSON status is null), one line per migration.
307
+ - `migration log`: applied at, space, name, from, to and operation count, one line per applied migration.
308
+ - `migration graph`: space, name, from and to, one line per migration; with `--dot`, the DOT text.
309
+ - `migration show`: `key<TAB>value` lines, then one `operation` line per operation.
310
+ - `migration check`: space, code and where (the path the failure is about), one line per failure.
311
+ - `migration new` and `migration plan`: the directories written.
312
+ - `migration ref list`: name, hash and comma-separated invariants, one line per ref. `migration ref set`: the hash the ref points at.
313
+ - `db migrate`: space, name, from, to and operations run, one line per applied migration; with `--show`, space, name, from and to per migration that will run.
314
+ - `db sign`: space, status and contract storage hash, one line per space.
315
+ - `orm init`: the paths of the files written.
316
+ - `contract emit`: the paths of `contract.json` and `contract.d.ts`. `contract infer`: the path written. `contract format`: the paths formatted. `contract print`: the PSL.
317
+
318
+ `db init`, `db update`, `db verify`, `db schema` and `migration ref delete` print nothing on stdout; their exit code is the result, and `--json` carries the document. An error in a pipe is now human text on stderr, with the same exit code.
319
+
320
+ ## `accessWidening` is renamed `accessChanges`
321
+
322
+ `db update` asks about each operation that changes who can read or write a model's data. Such an operation does not always widen access, so the list of them is now `accessChanges`, and the option that answers all of them is `acceptAccessChanges`. Rename each use:
323
+
324
+ ```ts
325
+ // Before
326
+ const result = await client.dbUpdate({ contract, mode: 'apply', migrationsDir, acceptAccessWidening: true, answerQuestions });
327
+ if (result.ok) console.log(result.value.accessWidening);
328
+
329
+ // After
330
+ const result = await client.dbUpdate({ contract, mode: 'apply', migrationsDir, acceptAccessChanges: true, answerQuestions });
331
+ if (result.ok) console.log(result.value.accessChanges);
332
+ ```
333
+
334
+ A script that reads `prisma db update --dry-run --json` reads `accessChanges` in place of `accessWidening`. The output is one JSON object per line, and the result is in the last one:
335
+
336
+ ```bash
337
+ prisma db update --dry-run --json | jq -s 'last | .envelope.result.accessChanges'
338
+ ```
339
+
340
+ The question `db update` asks now ends with "who can read and write its data" in place of "who can read and write its rows". A script that matches the question text changes the same way.
341
+
342
+ ## A removed namespace is asked about
343
+
344
+ If your contract removes a `namespace` block on Postgres, the next `migration plan` or `db update` asks about each model that namespace held, as it asks about any model you remove.
345
+
346
+ If you renamed the block, for example from `billing` to `finance`, give the rename and nothing is dropped:
347
+
348
+ ```bash
349
+ prisma db update --rename billing:finance
350
+ ```
351
+
352
+ Otherwise the namespace is removed. A script that runs without a terminal fails with `CLI.CONSENT_REQUIRED`, listing each model. To drop them all and the schema, add `--delete <namespace>`:
353
+
354
+ ```bash
355
+ prisma db update --delete billing
356
+ ```
357
+
358
+ To keep a model's data, move it to a namespace the contract keeps in the same run, for example `--rename billing.Invoice:public.Invoice`, or put the namespace back in the contract.
359
+
360
+ A table in that schema that no contract declared, such as one created by hand, is asked about too, by its storage name: `--delete billing.audit_log`. `--delete billing` does not answer it. Another object no contract declared, such as a view or a function, makes the run fail and changes nothing: a view on one of the tables stops that table's drop, and any other object stops the schema drop. The failure names each object; drop or move it yourself, then run the command again.
361
+
362
+ A namespace that only another contract space declares, and a schema no contract ever declared, such as Supabase's `auth`, are still left alone.
363
+
364
+ ## The schema check's differences are in `meta.schemaIssues`
365
+
366
+ When `db verify` or `db sign` finds that the database schema does not match the contract, its `--json` output has a diagnostic with the code `CONTRACT.SCHEMA_VERIFICATION_FAILED`. Its `meta.issues` was a list of label strings, such as `"missing: public/users/email"`. It is now `meta.schemaIssues`, a list of issue objects, the same key and shape the `MIGRATION.SCHEMA_VERIFY_FAILED` failure of `db init`, `db update` and `db migrate` already uses. `meta.space` and `meta.code` are unchanged, and so is `schema.issues` in the result of a check that passed.
367
+
368
+ Each issue has a `path`, the location of the difference as a list of names, and `expected` and `actual`, the contract's and the database's side, one of which is absent for a missing or an extra object. It has an `explanation` with a `text` when the CLI can say more.
369
+
370
+ In code that reads the diagnostic, read `meta.schemaIssues` where it read `meta.issues`. Where it used the label strings, build them from the issue. A label was the outcome, then the path: `missing` when only `expected` is set, `extra` when only `actual` is set, and `mismatch` when both are:
371
+
372
+ ```typescript
373
+ // before
374
+ const labels: string[] = diagnostic.meta.issues;
375
+ // after
376
+ const labels = diagnostic.meta.schemaIssues.map((issue) => {
377
+ const outcome = issue.actual === undefined ? 'missing' : issue.expected === undefined ? 'extra' : 'mismatch';
378
+ return `${outcome}: ${issue.path.join('/')}`;
379
+ });
380
+ ```
381
+
382
+ The `why` of the diagnostic still lists every difference as text.
383
+
384
+ ## Checks say which object they expect absent or present
385
+
386
+ Before an operation runs, the migration runner runs its prechecks. When one fails, the error's `why` named the check and said only that it failed on this database. A check that expects one object to be absent or present can now carry that as data, in `expectation`, and the `why` then says what the database already has or lacks. On MongoDB, a check carries the object's name in `object`, and its `expect` says whether it should exist.
387
+
388
+ Nothing breaks without it. An `ops.json` that has no `expectation` reads, verifies its hash and runs as before.
389
+
390
+ ### Migrations Prisma writes
391
+
392
+ The PostgreSQL, SQLite and MongoDB operations now write it on every check that asks only whether one object exists. A matched `ops.json`, or a MongoDB `ops.json` written before this change, gains it when you write it again: run its `migration.ts` (`node migration.ts`). Writing it again changes its hash, so do this only for a migration that no database has applied yet. Leave an applied migration as it is.
393
+
394
+ ### Checks you write yourself
395
+
396
+ In your app's migrations, a check you write in a `rawSql` operation can carry it too. Add `expectation` to the precheck or postcheck step, with `expects: 'absent'` or `'present'` and the object as a reader would name it, then run `node migration.ts`:
397
+
398
+ ```typescript
399
+ rawSql({
400
+ // ...
401
+ precheck: [
402
+ {
403
+ description: 'verify extension "vector" is not already enabled',
404
+ sql: "SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')",
405
+ expectation: { expects: 'absent', object: 'extension "vector"' },
406
+ },
407
+ ],
408
+ })
409
+ ```
410
+
411
+ Leave it out of a check about data or about several objects at once, such as a check that a column holds no NULL values.
412
+
413
+ ## MongoDB values are written in the syntax of their data type
414
+
415
+ MongoDB PSL now reads every enum member the way SQL PSL does: by the syntax it is written in, then the casts of the enum codec's data type, then the codec. The MongoDB target has an authoring entry or a cast for every data type except `mongo/bson`:
416
+
417
+ - a quoted string is `mongo/string`, and `true` and `false` are `mongo/bool`;
418
+ - a number is the smallest type that holds it: `mongo/int32`, `mongo/int64`, `mongo/decimal128` when a Decimal128 holds it exactly, `NaN` and the infinities included, and `mongo/double` otherwise;
419
+ - the `date`, `binary` and `json` tags write `mongo/date`, `mongo/binary` and `mongo/json`.
420
+
421
+ A member that was quoted to get a number through the JSON reader is now text, and a member that was written with a fraction on an integer enum is now a Decimal128 value. Rewrite each as the change entries above say:
422
+
423
+ ```prisma
424
+ enum Ratio {
425
+ @@type("mongo/double@1")
426
+ Unknown = NaN
427
+ Half = 0.5
428
+ }
429
+
430
+ enum Level {
431
+ @@type("mongo/int32@1")
432
+ One = 1
433
+ }
434
+ ```
435
+
436
+ Discriminators follow one rule in both families: the field must be required, hold one value, and have one of the stack's text data types, and when an enum types it, each `@@base` value must be one of its members. A field is text by its data type, so on MongoDB a type alias of `String` is now a discriminator.
437
+
438
+ An enum on an Int64, Date, Decimal128, Binary or ObjectId codec, or a Double enum with a `NaN` or infinite member, is still refused when a collection the contract manages uses it, because a collection validator cannot list those members.
439
+
440
+ ## Inserts must include the columns the database requires
441
+
442
+ The SQL builder's `insert` used to accept a row that left out any column. A row without a value for a column that is not nullable and has no default compiled, and then the database rejected it with a not-null error. The row type now requires those columns:
443
+
444
+ ```typescript
445
+ // User.displayName is `String` with no default
446
+ db.sql.public.user.insert([{ email: 'admin@example.com', kind: 'admin' }]);
447
+ // error: Property 'displayName' is missing
448
+
449
+ db.sql.public.user.insert([{ email: 'admin@example.com', kind: 'admin', displayName: 'Admin' }]);
450
+ ```
451
+
452
+ A column is still optional when it is nullable, when it has a default (`@default(...)`, including `now()` and `autoincrement()`), or when the client generates its value on create with `@onCreate(...)` or a preset that generates on create. Rows in one `insert` call are checked one by one, so they may set different optional columns.
453
+
454
+ For each insert that stops compiling, add a real value for each column the error names. Do not cast the row. A required property does not accept `undefined`, so a value typed `T | undefined` for one of these columns is now an error too: check it before the insert. Rows built in a variable and passed as `insert(rows)` get the same check, so give the variable the row type or build each row with every required column.
455
+
456
+ ### ORM create for fields that generate only on update
457
+
458
+ A field generates its value on update only when it has `@onUpdate(...)` without `@onCreate(...)`, or when a temporal preset sets only its update phase: `temporal.timestamptz(onUpdate: now)` and `temporal.timestamp(3, onUpdate: now)` in PSL, `field.temporal.timestamptz(undefined, undefined, 'now')` in TypeScript. Such a field that is not nullable and has no default was optional in ORM `create` input, and the create then failed in the database. It is now required. Pass a value for it on create, or make it generate on create too: add `@onCreate(...)`, or set the preset's create phase (`temporal.timestamptz(onCreate: now, onUpdate: now)`).
459
+
460
+ ## Supabase runs every role operation through one object
461
+
462
+ `SupabaseRuntime.forRole(binding)` returns a `SupabaseRoleScope`, the runtime operations under one role: `query`, `execute`, the prepared-statement operations and `connection`. Run a transaction under the role with `withTransaction(runtime.forRole(binding), fn)`.
463
+
464
+ | Type | New required members |
465
+ | --- | --- |
466
+ | `RoleBoundDb`, `ServiceRoleDb` | `enums`, `nativeEnums` |
467
+ | `SupabaseTransactionContext` | `enums`, `nativeEnums` (it is now `PostgresTransactionContext`) |
468
+ | `SupabaseRuntime` | `forRole(binding)`, in place of the four `*WithRole` methods |
469
+
470
+ ```ts
471
+ // Before
472
+ const rows = await runtime.queryWithRole(plan, { role: 'anon' }).toArray();
473
+ const stats = await runtime.executeWithRole(plan, { role: 'anon' });
474
+ const named = await runtime.preparedQueryWithRole(statement, params, { role: 'anon' }).toArray();
475
+
476
+ // After
477
+ const anon = runtime.forRole({ role: 'anon' });
478
+ const rows = await anon.query(plan).toArray();
479
+ const stats = await anon.execute(plan);
480
+ const named = await statement.query(anon, params).toArray();
481
+ ```
482
+
483
+ The `pg` option takes a `pg.Pool`:
484
+
485
+ ```ts
486
+ // Before
487
+ const db = await supabase({ contract, pg: new Client({ connectionString }), jwtSecret });
488
+
489
+ // After: close() does not end a pool you pass in, so keep it and end it at shutdown
490
+ const pool = new Pool({ connectionString });
491
+ const db = await supabase({ contract, pg: pool, jwtSecret });
492
+ // ...
493
+ await db.close();
494
+ await pool.end();
495
+
496
+ // Or let Supabase create and end the pool
497
+ const db = await supabase({ contract, url: connectionString, jwtSecret });
498
+ ```
499
+
500
+ ## `contract-artifacts-restamp`
501
+
502
+ For every `contract.json` matched by `detection`, run the project's emit command (`prisma contract emit`, or the project's `contract:emit` script) once after upgrading. This entry accounts for the extension's embedded `version` moving to `8.0.0-rc.20`; any other difference in the emitted files comes from an earlier entry in this guide.