@prisma/orm-mongo 8.0.0-rc.1-dev.46 → 8.0.0-rc.10

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 (80) hide show
  1. package/README.md +1 -5
  2. package/dist/contract-builder.d.mts +1 -0
  3. package/dist/contract-builder.d.mts.map +1 -1
  4. package/dist/utils__suppress-idle-connection-errors.d.mts +1 -0
  5. package/dist/utils__suppress-idle-connection-errors.mjs +2 -0
  6. package/package.json +14 -12
  7. package/skills/prisma-8/SKILL.md +96 -0
  8. package/skills/prisma-8/references/build.md +142 -0
  9. package/skills/prisma-8/references/contract.md +446 -0
  10. package/skills/prisma-8/references/debug.md +144 -0
  11. package/skills/prisma-8/references/feedback.md +251 -0
  12. package/skills/prisma-8/references/migration-model.md +175 -0
  13. package/skills/prisma-8/references/migration-review.md +241 -0
  14. package/skills/prisma-8/references/migrations.md +538 -0
  15. package/skills/prisma-8/references/queries-mongo.md +236 -0
  16. package/skills/prisma-8/references/queries-postgres.md +415 -0
  17. package/skills/prisma-8/references/queries.md +237 -0
  18. package/skills/prisma-8/references/quickstart.md +317 -0
  19. package/skills/prisma-8/references/runtime.md +366 -0
  20. package/skills/prisma-8/references/supabase.md +231 -0
  21. package/skills/prisma-8/references/upgrade-app.md +101 -0
  22. package/skills/prisma-8/references/upgrade-extension.md +105 -0
  23. package/skills/prisma-8/upgrading/app/upgrades/0.10-to-0.11/instructions.md +56 -0
  24. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/instructions.md +381 -0
  25. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-closed-mongo-contracts.ts +202 -0
  26. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-domain-namespaced-contracts.ts +201 -0
  27. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-postgres-public-default.ts +198 -0
  28. package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/strip-migration-labels-hints.ts +340 -0
  29. package/skills/prisma-8/upgrading/app/upgrades/0.12-to-0.13/instructions.md +339 -0
  30. package/skills/prisma-8/upgrading/app/upgrades/0.12-to-0.13/re-emit-mti-variant-link-columns.ts +229 -0
  31. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/instructions.md +543 -0
  32. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/migration-op-factories-to-methods.ts +290 -0
  33. package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/uuid-preset-rename.ts +43 -0
  34. package/skills/prisma-8/upgrading/app/upgrades/0.14-to-0.15/instructions.md +359 -0
  35. package/skills/prisma-8/upgrading/app/upgrades/0.15-to-0.16/instructions.md +173 -0
  36. package/skills/prisma-8/upgrading/app/upgrades/0.16-to-0.17/instructions.md +805 -0
  37. package/skills/prisma-8/upgrading/app/upgrades/0.16-to-0.17/strip-sha256-hash-prefixes.ts +382 -0
  38. package/skills/prisma-8/upgrading/app/upgrades/0.17-to-8.0.0-rc.1/instructions.md +72 -0
  39. package/skills/prisma-8/upgrading/app/upgrades/0.7-to-0.8/instructions.md +8 -0
  40. package/skills/prisma-8/upgrading/app/upgrades/0.8-to-0.9/instructions.md +36 -0
  41. package/skills/prisma-8/upgrading/app/upgrades/0.8-to-0.9/strip-inline-contracts.ts +226 -0
  42. package/skills/prisma-8/upgrading/app/upgrades/0.9-to-0.10/instructions.md +86 -0
  43. package/skills/prisma-8/upgrading/app/upgrades/0.9-to-0.10/stamp-storage-types-kind.ts +360 -0
  44. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md +588 -0
  45. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.2-to-8.0.0-rc.3/instructions.md +5 -0
  46. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.3-to-8.0.0-rc.4/instructions.md +158 -0
  47. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.4-to-8.0.0-rc.5/instructions.md +42 -0
  48. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.5-to-8.0.0-rc.6/instructions.md +157 -0
  49. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.6-to-8.0.0-rc.7/instructions.md +33 -0
  50. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.7-to-8.0.0-rc.8/instructions.md +36 -0
  51. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.8-to-8.0.0-rc.9/instructions.md +63 -0
  52. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.9-to-8.0.0-rc.10/instructions.md +84 -0
  53. package/skills/prisma-8/upgrading/extension/upgrades/0.10-to-0.11/instructions.md +276 -0
  54. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/instructions.md +738 -0
  55. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/migrate-contract-testing-imports.ts +97 -0
  56. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/regenerate-extension-public-baseline.ts +223 -0
  57. package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/strip-migration-labels-hints.ts +340 -0
  58. package/skills/prisma-8/upgrading/extension/upgrades/0.12-to-0.13/instructions.md +266 -0
  59. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/instructions.md +522 -0
  60. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/migration-op-factories-to-methods.ts +290 -0
  61. package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/uuid-preset-rename.ts +43 -0
  62. package/skills/prisma-8/upgrading/extension/upgrades/0.14-to-0.15/instructions.md +803 -0
  63. package/skills/prisma-8/upgrading/extension/upgrades/0.15-to-0.16/instructions.md +219 -0
  64. package/skills/prisma-8/upgrading/extension/upgrades/0.16-to-0.17/instructions.md +731 -0
  65. package/skills/prisma-8/upgrading/extension/upgrades/0.16-to-0.17/strip-sha256-hash-prefixes.ts +382 -0
  66. package/skills/prisma-8/upgrading/extension/upgrades/0.17-to-8.0.0-rc.1/instructions.md +194 -0
  67. package/skills/prisma-8/upgrading/extension/upgrades/0.7-to-0.8/instructions.md +8 -0
  68. package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/instructions.md +57 -0
  69. package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/strip-inline-contracts.ts +226 -0
  70. package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/instructions.md +150 -0
  71. package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/stamp-storage-types-kind.ts +360 -0
  72. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md +746 -0
  73. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.2-to-8.0.0-rc.3/instructions.md +5 -0
  74. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.3-to-8.0.0-rc.4/instructions.md +137 -0
  75. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.4-to-8.0.0-rc.5/instructions.md +129 -0
  76. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.5-to-8.0.0-rc.6/instructions.md +102 -0
  77. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.6-to-8.0.0-rc.7/instructions.md +33 -0
  78. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.7-to-8.0.0-rc.8/instructions.md +35 -0
  79. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.8-to-8.0.0-rc.9/instructions.md +86 -0
  80. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.9-to-8.0.0-rc.10/instructions.md +63 -0
package/README.md CHANGED
@@ -15,7 +15,7 @@ The one package a MongoDB application installs. It wires the framework, the Mong
15
15
  └── @prisma/orm-toolchain ORM command family for the `prisma` CLI, emitter, config loader
16
16
  ```
17
17
 
18
- `mongodb` is a peer dependency: the driver is the application's, so a single connection pool and a single BSON implementation serve both Prisma Next and any direct `mongodb` use in the same process.
18
+ `mongodb` is a peer dependency: the driver is the application's, so a single connection pool and a single BSON implementation serve both Prisma 8 and any direct `mongodb` use in the same process.
19
19
 
20
20
  ## Entrypoints
21
21
 
@@ -48,7 +48,3 @@ This package ships no bin. The ORM commands run inside the unified `prisma` CLI,
48
48
  ## Responsibilities
49
49
 
50
50
  Composition only. Every behavior it exposes lives in the platform packages; this package chooses the default combination of them and gives it one name.
51
-
52
- ## Dependencies
53
-
54
- `@prisma/orm-framework`, `@prisma/orm-family-mongo`, `@prisma/orm-target-mongo`, and `@prisma/orm-toolchain` at exact lockstep versions, plus `pathe`. `mongodb` is a peer dependency.
@@ -1,6 +1,7 @@
1
1
  import { ContractDefinition, ContractDefinition as ContractDefinition$1, ContractFactory, ContractFactory as ContractFactory$1, ContractScaffold, ContractScaffold as ContractScaffold$1, EnumMember, EnumTypeHandle, FieldBuilder, FieldReference, ModelBuilder, MongoContractResult, MongoContractResult as MongoContractResult$1, RelationBuilder, ValueObjectBuilder, field, index, member, model, rel, valueObject } from "@prisma/orm-family-mongo/contract-ts/contract-builder";
2
2
  import mongoFamilyPack from "@prisma/orm-family-mongo/family/pack";
3
3
  import mongoTargetPack from "@prisma/orm-target-mongo/target/pack";
4
+ import "@prisma/orm-framework/contract/types";
4
5
  import "@prisma/orm-framework/components/authoring";
5
6
  import { ColumnTypeDescriptor } from "@prisma/orm-framework/components/codec";
6
7
  //#region ../../../3-extensions/mongo/dist/contract-builder.d.mts
@@ -1 +1 @@
1
- {"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../../../../3-extensions/mongo/dist/contract-builder.d.mts"],"mappings":";;;;;;;KAMK,yBAAyB;KACzB,yBAAyB;KACzB,eAAe,WAAW,kBAAkB,sBAAsB,iCAAiC,iBAAiB;KACpH,uBAAuB,KAAK,qBAAqB,iBAAiB;WAC5D;WACA;;KAEN,qBAAqB,KAAK,mBAAmB,iBAAiB;WACxD;WACA;;iBAEM,qBAAqB,mBAAmB,sBAAsB,YAAY,aAAa,sBAAsB;WACnH,QAAQ;WACR,QAAQ;;iBAEF,qBAAqB,mBAAmB,0BAA0B;WACxE,SAAS;WACT,eAAe;WACf,QAAQ;GAChB,UAAU,YAAY,UAAU,SAAS,iBAAiB,QAAQ,sBAAsB,aAAa;WAC7F,QAAQ;WACR,QAAQ;;;;;;;;;;;;UAYT,aAAa,qBAAqB;WACjC,MAAM;WACN,OAAO;;KAEb,gBAAgB,yBAAyB,+CAA+C,WAAW,UAAU,QAAQ,WAAW,2BAA2B,KAAK;KAChK,eAAe,yBAAyB,+CAA+C,WAAW,UAAU,QAAQ,WAAW,mBAAmB,cAAc;KAChK,mBAAmB,yBAAyB,+CAA+C,KAAK,mBAAmB,YAAY;cACtH;;UAEJ,iBAAiB,8BAA8B,wDAAwD,qDAAqD,mBAAmB,0BAA0B;;YAEvM;;WAED,UAAU;;WAEV;;WAEA;;WAEA;aACE;aACA,OAAO;;;WAGT,QAAQ;;WAER,OAAO;;;;;WAKP,SAAS;;EAElB,IAAI,GAAG;;EAEP,OAAO,GAAG;;EAEV,UAAU,GAAG;;;;;;;;KAQV,eAAe;WACT;;;;;;;;KAQN,WAAW,mBAAmB,cAAc;WACtC;KACN,+BAA+B,aAAa,WAAW;WACjD,aAAa;IACpB;;;;;;;;KAQC,cAAc,mBAAmB,uBAAuB,2BAA2B,cAAc,KAAK,uDAAuD,0BAA0B,qBAAqB,WAAW,YAAY,YAAY,qBAAqB,WAAW,YAAY,YAAY,MAAM,MAAM,OAAO,UAAU,SAAS,YAAY,iBAAiB,MAAM,oBAAoB,WAAW,mBAAmB,WAAW,uBAAuB;;;;;;;;;;;;cAY3b,UAAU,2DAA2D"}
1
+ {"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../../../../3-extensions/mongo/dist/contract-builder.d.mts"],"mappings":";;;;;;;;KAOK,yBAAyB;KACzB,yBAAyB;KACzB,eAAe,WAAW,kBAAkB,sBAAsB,iCAAiC,iBAAiB;KACpH,uBAAuB,KAAK,qBAAqB,iBAAiB;WAC5D;WACA;;KAEN,qBAAqB,KAAK,mBAAmB,iBAAiB;WACxD;WACA;;iBAEM,qBAAqB,mBAAmB,sBAAsB,YAAY,aAAa,sBAAsB;WACnH,QAAQ;WACR,QAAQ;;iBAEF,qBAAqB,mBAAmB,0BAA0B;WACxE,SAAS;WACT,eAAe;WACf,QAAQ;GAChB,UAAU,YAAY,UAAU,SAAS,iBAAiB,QAAQ,sBAAsB,aAAa;WAC7F,QAAQ;WACR,QAAQ;;;;;;;;;;;;UAYT,aAAa,qBAAqB;WACjC,MAAM;WACN,OAAO;;KAEb,gBAAgB,yBAAyB,+CAA+C,WAAW,UAAU,QAAQ,WAAW,2BAA2B,KAAK;KAChK,eAAe,yBAAyB,+CAA+C,WAAW,UAAU,QAAQ,WAAW,mBAAmB,cAAc;KAChK,mBAAmB,yBAAyB,+CAA+C,KAAK,mBAAmB,YAAY;cACtH;;UAEJ,iBAAiB,8BAA8B,wDAAwD,qDAAqD,mBAAmB,0BAA0B;;YAEvM;;WAED,UAAU;;WAEV;;WAEA;;WAEA;aACE;aACA,OAAO;;;WAGT,QAAQ;;WAER,OAAO;;;;;WAKP,SAAS;;EAElB,IAAI,GAAG;;EAEP,OAAO,GAAG;;EAEV,UAAU,GAAG;;;;;;;;KAQV,eAAe;WACT;;;;;;;;KAQN,WAAW,mBAAmB,cAAc;WACtC;KACN,+BAA+B,aAAa,WAAW;WACjD,aAAa;IACpB;;;;;;;;KAQC,cAAc,mBAAmB,uBAAuB,2BAA2B,cAAc,KAAK,uDAAuD,0BAA0B,qBAAqB,WAAW,YAAY,YAAY,qBAAqB,WAAW,YAAY,YAAY,MAAM,MAAM,OAAO,UAAU,SAAS,YAAY,iBAAiB,MAAM,oBAAoB,WAAW,mBAAmB,WAAW,uBAAuB;;;;;;;;;;;;cAY3b,UAAU,2DAA2D"}
@@ -0,0 +1 @@
1
+ export * from "@prisma/orm-framework/utils/suppress-idle-connection-errors";
@@ -0,0 +1,2 @@
1
+ export * from "@prisma/orm-framework/utils/suppress-idle-connection-errors";
2
+ export {};
package/package.json CHANGED
@@ -1,24 +1,25 @@
1
1
  {
2
2
  "name": "@prisma/orm-mongo",
3
- "version": "8.0.0-rc.1-dev.46",
3
+ "version": "8.0.0-rc.10",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
- "description": "Prisma Next for MongoDB: the one package a MongoDB application installs",
7
+ "description": "Prisma 8 for MongoDB: the one package a MongoDB application installs",
8
8
  "files": [
9
- "dist"
9
+ "dist",
10
+ "skills"
10
11
  ],
11
12
  "dependencies": {
12
- "@prisma/orm-family-mongo": "8.0.0-rc.1-dev.46",
13
- "@prisma/orm-framework": "8.0.0-rc.1-dev.46",
14
- "@prisma/orm-target-mongo": "8.0.0-rc.1-dev.46",
15
- "@prisma/orm-toolchain": "8.0.0-rc.1-dev.46",
13
+ "@prisma/orm-family-mongo": "8.0.0-rc.10",
14
+ "@prisma/orm-framework": "8.0.0-rc.10",
15
+ "@prisma/orm-target-mongo": "8.0.0-rc.10",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.10",
16
17
  "pathe": "^2.0.3"
17
18
  },
18
19
  "devDependencies": {
19
- "@internal/mongo": "8.0.0-rc.1-dev.46",
20
- "@repo/tsconfig": "8.0.0-rc.1-dev.46",
21
- "@repo/tsdown": "8.0.0-rc.1-dev.46",
20
+ "@internal/mongo": "8.0.0-rc.10",
21
+ "@repo/tsconfig": "8.0.0-rc.10",
22
+ "@repo/tsdown": "8.0.0-rc.10",
22
23
  "tsdown": "0.22.14",
23
24
  "typescript": "5.9.3"
24
25
  },
@@ -112,6 +113,7 @@
112
113
  "./utils/result": "./dist/utils__result.mjs",
113
114
  "./utils/simplify-deep": "./dist/utils__simplify-deep.mjs",
114
115
  "./utils/structured-error": "./dist/utils__structured-error.mjs",
116
+ "./utils/suppress-idle-connection-errors": "./dist/utils__suppress-idle-connection-errors.mjs",
115
117
  "./utils/types": "./dist/utils__types.mjs",
116
118
  "./value": "./dist/value.mjs",
117
119
  "./value/mongodb-types": "./dist/value__mongodb-types.mjs",
@@ -120,12 +122,12 @@
120
122
  },
121
123
  "repository": {
122
124
  "type": "git",
123
- "url": "https://github.com/prisma/prisma.git",
125
+ "url": "https://github.com/prisma/orm.git",
124
126
  "directory": "packages/9-public/@prisma/orm-mongo"
125
127
  },
126
128
  "scripts": {
127
129
  "build": "tsdown",
128
130
  "lint": "biome check . --error-on-warnings",
129
- "clean": "rm -rf dist src-gen"
131
+ "clean": "rm -rf dist src-gen skills"
130
132
  }
131
133
  }
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: prisma-8
3
+ description: >-
4
+ Use when working in a project that depends on @prisma/orm-postgres,
5
+ @prisma/orm-sqlite, or @prisma/orm-mongo (Prisma 8, formerly Prisma Next): editing
6
+ contract.prisma or a contract.ts builder, running `prisma contract emit`,
7
+ planning or applying migrations, editing migration.ts, writing db.orm /
8
+ db.sql / db.query queries, wiring db.ts or middleware, integrating a build
9
+ tool, using the Supabase extension or RLS, or reading a dotted error code
10
+ such as MIGRATION.HASH_MISMATCH. Use when the user asks "what is Prisma
11
+ 8", "where do I start", or compares it to another ORM. Use when the user
12
+ asks to upgrade or bump Prisma 8 in an app or an extension package. Use when
13
+ you see @internal/* or @prisma/orm-* imports, prisma.config.ts with
14
+ definePrismaConfig, or contract.json / contract.d.ts. Do not use for Prisma
15
+ ORM 7 or earlier (schema.prisma + @prisma/client).
16
+ metadata:
17
+ library: '@prisma/orm-mongo'
18
+ library_version: '8.0.0-rc.10'
19
+ version: '2026-09-12'
20
+ ---
21
+
22
+ # Prisma 8 (Prisma 8)
23
+
24
+ > **Edit your data contract. Prisma handles the rest.**
25
+
26
+ Prisma 8 moves fast, and your training data about it is very likely outdated. This skill ships inside the installed Prisma packages, so it describes the exact version this project has — treat it and its reference files as the source of truth, over anything you remember about Prisma.
27
+
28
+ ## Pre-conditions
29
+
30
+ Check these before acting on anything below. Halt on the first one that fails and tell the user what is missing.
31
+
32
+ 1. **The project is on Prisma 8.** `prisma.config.ts` exports `definePrismaConfig({ orm: ... })`, and `package.json` depends on `@prisma/orm-postgres`, `@prisma/orm-sqlite`, or `@prisma/orm-mongo`. A project with `schema.prisma` and `@prisma/client` is Prisma 7 or earlier; this skill does not apply to it, and its instructions will break such a project.
33
+ 2. **The skill matches the installed version.** Compare `metadata.library_version` in this file's frontmatter with the installed `@prisma/orm-*` version in `package.json`. If they differ, run `prisma skills sync` and re-read this file before continuing.
34
+ 3. **The contract artefacts exist.** `contract.json` and `contract.d.ts` sit next to the contract source named by `prisma.config.ts`. If they are missing or older than the source, run `prisma contract emit` first; every query and migration instruction below assumes current artefacts.
35
+
36
+ **Import paths in the references.** The reference files spell façade imports as `@internal/<target>/<subpath>` and `@internal/extension-<name>/<subpath>`. In an application those packages are published as `@prisma/orm-<target>/<subpath>` (`@prisma/orm-postgres/runtime`, `@prisma/orm-mongo/config`, `@prisma/orm-sqlite/runtime`) and `@prisma/orm-extension-<name>/<subpath>` (`@prisma/orm-extension-pgvector/control`). Write the `@prisma/orm-*` name in user code; the two spellings are the same package. Paths already written as `@prisma/orm-*` in the references are exact. The `metadata.library_version` in this file's frontmatter is the version it was published with; if it does not match the project's installed Prisma packages, run `prisma skills sync` and re-read.
37
+
38
+ Prisma 8 is a contract-first data layer. This skill routes every Prisma 8 task to the right reference file — open the reference before writing code; do not answer from this file alone.
39
+
40
+ ## The canonical model (one paragraph)
41
+
42
+ You author a **data contract** (a `contract.prisma` file, or a TypeScript builder). The framework emits machine-readable artifacts (`contract.json`, `contract.d.ts`) and gives you two runtime surfaces on SQL targets: a typed SQL query builder (`db.sql.<ns>.<table>`) and a typed ORM client (`db.orm.<ns>.<Model>`). On MongoDB targets only the ORM lane exists, and its keys are collection storage names (`db.orm.users`) rather than PSL model names — [`references/queries.md`](references/queries.md) § *MongoDB ORM addressing* covers the rule. Migrations are planned from the contract diff; you review them, optionally edit the `migration.ts` for data transforms, and apply.
43
+
44
+ Three steps the user does:
45
+
46
+ 1. **Edit your data contract.** ([`references/contract.md`](references/contract.md))
47
+ 2. **The system plans the migrations for you.** ([`references/migrations.md`](references/migrations.md))
48
+ 3. **If you need data migrations, you edit `migration.ts` and execute it.** ([`references/migrations.md`](references/migrations.md))
49
+
50
+ Everything else — queries, runtime wiring, build integration, debugging, feedback — sits on top of those three.
51
+
52
+ One cross-cutting migration fact: `migration plan` does **not** chain from the newest migration on disk. Its origin is `--from`, else the `db` ref, else an empty database — so a project with no ref keeps planning from scratch. Over existing migrations the CLI refuses that (`MIGRATION.PLAN_ORIGIN_UNKNOWN`) instead of writing a full-create package; choose the exit that matches your intent rather than reflexively passing `--from @empty`. [`references/migration-model.md`](references/migration-model.md) § *The trap* explains which to choose.
53
+
54
+ ## Routing table
55
+
56
+ Open the reference whose triggers match the task. If more than one matches, open each — they are written to compose.
57
+
58
+ | Task | Reference | Triggers |
59
+ | --- | --- | --- |
60
+ | Adopt / set up / first steps | [`references/quickstart.md`](references/quickstart.md) | new project, existing database, "what can I do with Prisma 8", "where do I start", "just ran createprisma", `npx create-prisma`, first steps, first query, `prisma orm init` greenfield setup, `contract infer` + `db sign` brownfield adoption, connect-write-read first arc, day-to-day commands (`contract emit`, `db init`, `db update`, `migration plan`, `db migrate`, `db schema`, `db verify`), flags `--target` / `--authoring` / `--schema-path` / `--probe-db` / `--output` |
61
+ | Edit the data contract | [`references/contract.md`](references/contract.md) | schema, models, fields, attributes, relations, indexes, enums, value objects (composite types), type aliases, namespaces (Postgres schemas), cross-contract foreign keys (cross-space FK), polymorphic types (`@@discriminator` / `@@base`), extension namespaces (`pgvector.Vector(...)`, `postgis.Geometry(...)`), `prisma.config.ts` / `definePrismaConfig` / `ormConfig`, `prisma contract emit`, PSL, `contract.prisma`, `contract.ts`, `contract.json`, `contract.d.ts`, `@internal/postgres/config`, `@internal/postgres/contract-builder`, `@internal/mongo/config`, `extensions:`, pgvector, postgis, paradedb, Temporal / `temporal-polyfill` / `RUNTIME.TEMPORAL_UNAVAILABLE`, `@@control`, control policy (managed / tolerated / external / observed), soft delete, validations, callbacks |
62
+ | Author migrations | [`references/migrations.md`](references/migrations.md) | `db update` vs `migration plan`, `db migrate`, `migration new`, `migration show`, `db update --dry-run`, `db verify`, `db sign`, data migration, `dataTransform`, placeholder sentinels in framework-rendered `migration.ts`, `MIGRATION.HASH_MISMATCH`, `MIGRATION.UNFILLED_PLACEHOLDER`, `MIGRATION.DESTRUCTIVE_CHANGES` / `--confirm <database>`, schema drift |
63
+ | Migration graph, refs, plan origin | [`references/migration-model.md`](references/migration-model.md) | migration graph, refs, `migration ref set` / `list` / `delete`, the `db` ref, `--advance-ref`, `--no-advance-ref`, `migration plan --from`, `from: (baseline)` in plan output, greenfield / from-scratch plan, baseline, first migration before deploy (Composer / CD-managed databases), chaining migrations, retrofitting migrations onto an existing database, `MIGRATION.HASH_NOT_IN_GRAPH`, `MIGRATION.PATH_UNREACHABLE` at plan/chain time |
64
+ | Review migrations on deploy | [`references/migration-review.md`](references/migration-review.md) | "what migrations are going to run", "what runs on deploy / merge", merge conflict, diamond convergence, concurrent migrations, migration status, ref management for CI, staging / production environment refs, `MIGRATION.MARKER_NOT_IN_HISTORY`, `MIGRATION.MISSING_INVARIANTS`, `MIGRATION.AMBIGUOUS_TARGET`, `db migrate --show` |
65
+ | Write queries | [`references/queries.md`](references/queries.md) | query, where, select, project, orderBy, limit, offset, take, skip, include, lookup, first, all, count, aggregate, groupBy, create, update, delete, upsert, returning, transaction, `db.orm`, `db.sql`, `runtime.query(plan)` vs `runtime.execute(plan)`, `db.prepare` / prepared statements, streaming / `for await`, many-to-many `include` and nested `connect`, `and` / `or` / `not` from `@prisma/orm-postgres/orm-client`, `db.query.from(...)` (Mongo pipeline), namespace-aware accessors, `.all()` Thenable, single-use iterators (`RUNTIME.ITERATOR_CONSUMED`), target-declared aggregate types (`count`, integer `sum`, and integer `avg` are `number`; `count` and integer `sum` throw outside ±(2^53 − 1) rather than round, while `avg` is a fraction already and carries no guard; `countBigInt` / `sumBigInt` / `avgDecimal` are the lossless forms, `avgDecimal` on PostgreSQL only), drizzle-style, kysely-style. Naming types (§ *Naming model and result types*): "type of my model", "return type of a query", `ResultType`, `Scalars`, `Shape`, `models` / `Models` namespace in `contract.d.ts`, `Models.public_User`, Prisma 7 `Prisma.User` / `GetPayload` / `UserGetPayload` equivalents. Postgres/SQLite specifics: [`references/queries-postgres.md`](references/queries-postgres.md); Mongo specifics: [`references/queries-mongo.md`](references/queries-mongo.md) |
66
+ | Wire the runtime | [`references/runtime.md`](references/runtime.md) | `db.ts`, `postgres<Contract>(...)` / `sqlite<Contract>(...)` / `mongo<Contract>(...)` façades, middleware composition (lints, budgets, cache via `@prisma/orm-extension-middleware-cache`, custom `afterQuery` middleware, `@prisma/orm-postgres/family-runtime`), `DATABASE_URL`, `.env`, connection pool / `poolOptions`, dev vs prod config, transactions, read replicas, multi-database, script won't exit / hangs, `db.close` / `pool.end`, `await using` / `[Symbol.asyncDispose]` |
67
+ | Build-tool integration | [`references/build.md`](references/build.md) | Vite plugin (`@internal/vite-plugin-contract-emit`, Vite 7/8), `vite.config.ts`, contract emit on save, HMR / dev server, Next.js / Webpack / esbuild / Rollup / Turbopack (named gaps, not fabricated) |
68
+ | Supabase | [`references/supabase.md`](references/supabase.md) | `@internal/extension-supabase`, RLS, row level security, policies (`policy_select` / `policy_update` / `@@rls`, `auth.uid()`), role binding (`asUser(jwt)` / `asAnon()` / `asServiceRole()`), `auth.users`, cross-space FKs to `supabase:auth.AuthUser`, JWT / JWKS (`SUPABASE_JWKS_URL`, `SUPABASE_JWT_SECRET`), `SUPABASE.JWT_INVALID`, `SUPABASE.CONFIG_INVALID`, `RoleBoundDb`, session pooler |
69
+ | Debug an error | [`references/debug.md`](references/debug.md) | any structured error envelope (code, severity, why, fix, nextActions, meta), emit failed, query won't typecheck, query crashed, migration won't apply, `MIGRATION.HASH_MISMATCH`, `MIGRATION.RUNNER_FAILED`, `BUDGET.ROWS_EXCEEDED`, `BUDGET.TIME_EXCEEDED`, `RUNTIME.ABORTED`, `RUNTIME.TEMPORAL_UNAVAILABLE`, `PLAN.HASH_MISMATCH`, `CONTRACT.MARKER_MISSING`, `CONFIG.*` / `CLI.*` / `CONTRACT.*` / `MIGRATION.*` / `ORM.*` / `RUNTIME.*` codes, legacy `PN-*` codes, exit code 4 findings, drift, capability missing, planner conflict, EXPLAIN, query log, script won't exit / close connection |
70
+ | Upgrade Prisma in an app | [`references/upgrade-app.md`](references/upgrade-app.md) | "upgrade Prisma", "upgrade Prisma 8", "bump Prisma 8", "move to Prisma 8 X.Y", `@internal/*` version bump in an application, per-transition upgrade instructions in [`upgrading/app/upgrades/`](upgrading/app/upgrades/), extension-pin pre-flight, `PN-UPGRADE-*` |
71
+ | Upgrade Prisma in an extension | [`references/upgrade-extension.md`](references/upgrade-extension.md) | the same request in a package that *is* a Prisma extension (`@internal/contract` / SPI dependency, `^@.*/extension-` name), `prisma-8-check-pins`, exact-pin rule, per-transition instructions in [`upgrading/extension/upgrades/`](upgrading/extension/upgrades/) |
72
+ | File feedback / ask the team | [`references/feedback.md`](references/feedback.md) | bug report, file an issue, feature request, missing feature, capability gap, "this is broken", surprising behaviour, Q&A / design discussion, ask the Prisma team, Prisma Discord (pris.ly/discord), extension-author questions |
73
+
74
+ ## Routing rules
75
+
76
+ If the task clearly matches a row, open that reference directly without asking.
77
+
78
+ For a vague prompt, ask **one** disambiguating question. Pick from:
79
+
80
+ - *"Are you new to Prisma 8 and asking what you can do with it, or where to start?"* → [`references/quickstart.md`](references/quickstart.md) (first-touch orientation path).
81
+ - *"Do you want to set up a new Prisma 8 project, or wire it into an existing database?"* → [`references/quickstart.md`](references/quickstart.md).
82
+ - *"Do you want to edit your data contract (add a model / field / relation), or work with the database (migrations, queries)?"* → [`references/contract.md`](references/contract.md) vs the others.
83
+ - *"Is this about authoring a migration, or about reviewing what's going to run on deploy?"* → [`references/migrations.md`](references/migrations.md) vs [`references/migration-review.md`](references/migration-review.md). If it's about where a plan starts, refs, or an unexpected from-scratch plan → [`references/migration-model.md`](references/migration-model.md).
84
+ - *"Is this about wiring Prisma 8 into your build tool (Vite / Next.js / …), or about wiring `db.ts` and middleware at runtime?"* → [`references/build.md`](references/build.md) vs [`references/runtime.md`](references/runtime.md).
85
+ - *"What error or symptom are you seeing?"* → [`references/debug.md`](references/debug.md).
86
+ - *"Do you want to report this as a bug to the Prisma 8 team, or is this a feature request?"* → [`references/feedback.md`](references/feedback.md).
87
+ - *"Is the project you want to upgrade an application, or a Prisma extension package?"* → [`references/upgrade-app.md`](references/upgrade-app.md) vs [`references/upgrade-extension.md`](references/upgrade-extension.md).
88
+
89
+ If you still can't tell which reference applies, ask the user what they want to do. Do not guess.
90
+
91
+ ## Checklist
92
+
93
+ - [ ] If the task matches a routing-table row, open that reference before writing code.
94
+ - [ ] If the prompt is vague, ask one disambiguating question.
95
+ - [ ] Do not attempt to answer from this file alone — the references carry the verified tool surface.
96
+ - [ ] If the user describes a missing feature or a misbehaviour they want fixed, open [`references/feedback.md`](references/feedback.md).
@@ -0,0 +1,142 @@
1
+
2
+ # Prisma 8 — Build-System Integration
3
+
4
+ > **Edit your data contract. Prisma handles the rest.**
5
+
6
+ This skill covers Prisma 8's build-tool plugins — the dev-server / build-system integrations that re-emit contract artifacts automatically as the user edits the contract source. Today that's [`@internal/vite-plugin-contract-emit`](https://github.com/prisma/prisma/blob/main/packages/1-framework/3-tooling/vite-plugin-contract-emit/README.md) for Vite 7 and Vite 8. Next.js, Webpack, esbuild, Rollup, and Turbopack plugins are documented under *What Prisma 8 doesn't do yet* with the workaround.
7
+
8
+ **If the project is using Vite and consuming the contract, install the plugin.** There's no good reason not to — manual `prisma contract emit` during dev is friction the plugin eliminates. The agent should proactively offer the plugin whenever it sees a `vite.config.ts` in the project; the user doesn't need to ask.
9
+
10
+ ## When to Use
11
+
12
+ - The project is using Vite (the agent sees a `vite.config.ts` or `@vitejs/*` deps) and the contract is being consumed at runtime — proactively offer the plugin.
13
+ - User asks how to wire Prisma 8 into their Vite project.
14
+ - User asks about Next.js integration, Webpack integration, or any other bundler — the answer is *"not yet, here's the workaround"* and the skill walks them through it.
15
+ - User mentions: *vite plugin, vite-plugin, vite.config.ts, prismaVitePlugin, contract emit on save, HMR, hot reload contract, dev server, vite 7, vite 8*.
16
+ - User mentions Next.js / Webpack / esbuild / Rollup / Turbopack in the context of Prisma 8 integration — the gap-listing path fires.
17
+
18
+ ## When Not to Use
19
+
20
+ - User wants to wire `db.ts` and middleware → `references/runtime.md`.
21
+ - User wants to file a feature request for an unbuilt bundler plugin → `references/feedback.md`.
22
+
23
+ ## Key Concepts
24
+
25
+ - **The plugin's job is `contract emit`, on a schedule the bundler knows about.** It is *not* a runtime concern — at runtime, the application reads `contract.json` / `contract.d.ts` the same way whether the plugin emitted them or a script did. The plugin saves you the manual command during development.
26
+ - **Vite 7 and Vite 8 only.** Peer range `^7.0.0 || ^8.0.0`. Vite 6 is not on the support matrix.
27
+ - **`executeContractEmit` is the canonical publish path.** Custom plugins for other bundlers must also call it — never re-implement the load → emit → publish dance. The atomic-rename invariant (`contract.d.ts` renamed before `contract.json`) and the per-output FIFO queue live in `@internal/cli/control-api`.
28
+ - **No build-time / production emission.** The Vite plugin runs in `vite dev` only. For `vite build` / production, run `prisma contract emit` from a `prebuild` script.
29
+
30
+ ## Workflow — Vite (the supported path)
31
+
32
+ ### 1. Install the plugin
33
+
34
+ ```bash
35
+ pnpm add -D @internal/vite-plugin-contract-emit
36
+ ```
37
+
38
+ (Or `npm install --save-dev`, `yarn add -D`, `bun add -d` — use what the project's package manager is.)
39
+
40
+ ### 2. Wire `vite.config.ts`
41
+
42
+ ```typescript
43
+ // vite.config.ts
44
+ import { defineConfig } from 'vite';
45
+ import { prismaVitePlugin } from '@internal/vite-plugin-contract-emit';
46
+
47
+ export default defineConfig({
48
+ plugins: [prismaVitePlugin('prisma.config.ts')],
49
+ });
50
+ ```
51
+
52
+ The argument is the **path to `prisma.config.ts` relative to Vite root**. Not the path to `schema.psl` or `contract.ts` — the plugin reads the config to discover the contract source.
53
+
54
+ ### 3. Configure (optional)
55
+
56
+ ```typescript
57
+ plugins: [
58
+ prismaVitePlugin('prisma.config.ts', {
59
+ debounceMs: 150, // delay before re-emitting (default 150)
60
+ logLevel: 'info', // 'silent' | 'info' | 'debug' (default 'info')
61
+ }),
62
+ ],
63
+ ```
64
+
65
+ Set `logLevel: 'debug'` only while troubleshooting; default `'info'` in committed config so the dev server isn't noisy.
66
+
67
+ ### 4. Verify the dev loop
68
+
69
+ 1. Start `vite dev`.
70
+ 2. Watch for the success log: `[prisma] emitted contract.d.ts + contract.json`.
71
+ 3. Edit `prisma/schema.psl` (e.g. add a field to a model).
72
+ 4. Within ~150ms (the debounce), watch for a re-emit log line.
73
+ 5. Type-check your application code that uses the new field — should pass without restarting the dev server.
74
+
75
+ If the plugin warns about *config-only watching*, see [Common Pitfalls](#common-pitfalls).
76
+
77
+ ### 5. CI / production builds
78
+
79
+ The plugin does **not** run during `vite build`. For CI and production deploys, run `prisma contract emit` as a prebuild step:
80
+
81
+ ```json
82
+ // package.json
83
+ {
84
+ "scripts": {
85
+ "prebuild": "prisma contract emit",
86
+ "build": "vite build"
87
+ }
88
+ }
89
+ ```
90
+
91
+ `pnpm build` then runs `prebuild` automatically before `build`.
92
+
93
+ ## Workflow — React Router v7 Framework Mode
94
+
95
+ The Vite plugin is compatible with `@react-router/dev/vite`. Both plugins are listed in `vite.config.ts`; there's no ordering constraint between them today, and the Prisma 8 plugin's re-emit fires alongside React Router's own SSR re-load.
96
+
97
+ ```typescript
98
+ import { reactRouter } from '@react-router/dev/vite';
99
+ import { prismaVitePlugin } from '@internal/vite-plugin-contract-emit';
100
+
101
+ export default defineConfig({
102
+ plugins: [
103
+ reactRouter(),
104
+ prismaVitePlugin('prisma.config.ts'),
105
+ ],
106
+ });
107
+ ```
108
+
109
+ See [`examples/react-router-demo`](https://github.com/prisma/prisma/tree/main/examples/react-router-demo) for the canonical configuration plus a smoke test that proves the dev loop.
110
+
111
+ ## Common Pitfalls
112
+
113
+ 1. **Pointing the plugin at `schema.psl` instead of `prisma.config.ts`.** The argument is the config path. The plugin reads the config to find the contract source.
114
+ 2. **Vite 6 or earlier.** Not supported. Upgrade Vite to 7 or 8.
115
+ 3. **The plugin warns: *"watching only the config; loader resolved inputs unavailable."*** The plugin couldn't resolve `contract.source.inputs` from the loader. The fallback watches only `prisma.config.ts` itself, so contract edits won't re-emit. Causes: the config file throws during loading; the contract source path resolves outside the Vite root. Fix the config error first, then check that the contract source path in the config is relative to (or inside) the Vite root.
116
+ 4. **Expecting `vite build` to re-emit.** It doesn't. Add a `prebuild` script.
117
+ 5. **Emit errors during dev**: the plugin surfaces them via Vite's error overlay. Read the overlay; the underlying cause is a contract authoring problem — chain to `references/debug.md` for resolution (PSL syntax, missing namespace, conflicting extensions).
118
+ 6. **Re-installing dependencies without the plugin's peer-range move.** When PN bumps the plugin's peer range, you must re-run `pnpm install` so the lockfile picks up the new range. A stale lockfile keeps the old plugin and produces confusing version mismatch warnings.
119
+
120
+ ## What Prisma 8 doesn't do yet
121
+
122
+ - **Next.js plugin.** No first-party `@internal/next-plugin-*` exists. Workaround: run `prisma contract emit` from a `prebuild` script in `package.json` and run it manually during development when the contract changes. Many Next.js projects also run a dev-time `tsx --watch` against a small script that calls the CLI on contract-source change. If you want a first-party Next.js plugin, file a feature request via the `references/feedback.md` skill.
123
+ - **Webpack, esbuild, Rollup, Turbopack plugins.** None exist yet as first-party. Workaround: the canonical `executeContractEmit` surface lives in `@internal/cli/control-api` — a small per-bundler plugin can call it from the bundler's prebuild hook, but PN doesn't ship one for you. The `vite-plugin-contract-emit` source is the reference implementation if you want to write one yourself. If you want a first-party plugin for your bundler, file a feature request via the `references/feedback.md` skill.
124
+ - **`vite build` integration.** The plugin runs in `vite dev` only. Workaround: a `prebuild` script that runs `prisma contract emit`. If you want the plugin to also run during `vite build`, file a feature request via the `references/feedback.md` skill.
125
+ - **Vite 6 or earlier.** Not on the support matrix. Workaround: upgrade Vite to 7 or 8. If you have a hard reason to stay on Vite 6, file a feature request via the `references/feedback.md` skill.
126
+
127
+ ## Reference Files
128
+
129
+ - The plugin's own README: <https://github.com/prisma/prisma/blob/main/packages/1-framework/3-tooling/vite-plugin-contract-emit/README.md> — support matrix, full API surface, architecture diagram, the *canonical publish path* warning for custom plugin authors.
130
+ - ADR 008 (Dev Auto-Emit, CI Explicit Emit) — the rationale for splitting dev-time auto-emit from the explicit CI / build step.
131
+ - ADR 032 (Dev Auto-Emit Integration) — the plugin's integration contract with the CLI control API.
132
+
133
+ ## Checklist
134
+
135
+ - [ ] Plugin pointed at `prisma.config.ts` (not the contract source).
136
+ - [ ] Vite version 7 or 8 (`pnpm ls vite`).
137
+ - [ ] `vite dev` log shows the initial emit on server start.
138
+ - [ ] Editing the contract source triggers a re-emit log line.
139
+ - [ ] `prebuild` script (or equivalent) runs `prisma contract emit` for CI / production builds.
140
+ - [ ] No `vite build` expectation that the plugin will run.
141
+ - [ ] For non-Vite bundlers: surfaced the *What PN doesn't do yet* entry and routed the user to `references/feedback.md` if they want first-party support.
142
+ - [ ] Did NOT confabulate a `@internal/next-plugin-contract-emit` package or any other bundler-specific plugin that doesn't exist.