@prisma/orm-postgres 8.0.0-rc.24-dev.27 → 8.0.0-rc.24-dev.29

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 (55) hide show
  1. package/README.md +8 -3
  2. package/dist/components-CWcPJJxx-0zxP3brl.mjs +19 -0
  3. package/dist/components-CWcPJJxx-0zxP3brl.mjs.map +1 -0
  4. package/dist/config.mjs +21 -14
  5. package/dist/config.mjs.map +1 -1
  6. package/dist/{contract-from-json-BVDNIlFO-Ds6x_F9v.mjs → contract-from-json-BQdx9dk3-CHLY5fww.mjs} +3 -3
  7. package/dist/{contract-from-json-BVDNIlFO-Ds6x_F9v.mjs.map → contract-from-json-BQdx9dk3-CHLY5fww.mjs.map} +1 -1
  8. package/dist/contract-types.d.mts +4 -0
  9. package/dist/contract-types.mjs +1 -0
  10. package/dist/control.mjs +2 -8
  11. package/dist/control.mjs.map +1 -1
  12. package/dist/init-quick-reference-prisma7.md +80 -0
  13. package/dist/init-quick-reference.md +95 -0
  14. package/dist/init-readme.md +34 -0
  15. package/dist/init.d.mts +7 -0
  16. package/dist/init.d.mts.map +1 -0
  17. package/dist/init.mjs +272 -0
  18. package/dist/init.mjs.map +1 -0
  19. package/dist/internal__static-context.mjs +1 -1
  20. package/dist/internal__transaction-members.d.mts +1 -1
  21. package/dist/internal__transaction-members.mjs +1 -1
  22. package/dist/internal__validate-contract.mjs +1 -1
  23. package/dist/module-base-C02qpQ9x-BEyIGqx7.mjs +6 -0
  24. package/dist/module-base-C02qpQ9x-BEyIGqx7.mjs.map +1 -0
  25. package/dist/{postgres-members-B7ZvxGYc-D_L3NVGm.mjs → postgres-members-CRPX0rhb-C0keDjWe.mjs} +18 -16
  26. package/dist/postgres-members-CRPX0rhb-C0keDjWe.mjs.map +1 -0
  27. package/dist/{postgres-members-F9CVSrrN-BFAuNPbW.d.mts → postgres-members-DQvChDJ--ByodBWAn.d.mts} +3 -2
  28. package/dist/postgres-members-DQvChDJ--ByodBWAn.d.mts.map +1 -0
  29. package/dist/{postgres-static-BjWEDHSs-Y8MES2qy.mjs → postgres-static-BsLAA6GS-BBKjNHT8.mjs} +3 -3
  30. package/dist/{postgres-static-BjWEDHSs-Y8MES2qy.mjs.map → postgres-static-BsLAA6GS-BBKjNHT8.mjs.map} +1 -1
  31. package/dist/runtime.d.mts +1 -1
  32. package/dist/runtime.mjs +3 -3
  33. package/dist/runtime.mjs.map +1 -1
  34. package/dist/serverless.d.mts +1 -1
  35. package/dist/serverless.mjs +3 -3
  36. package/dist/serverless.mjs.map +1 -1
  37. package/dist/static.mjs +2 -2
  38. package/package.json +12 -10
  39. package/skills/prisma-8/SKILL.md +10 -10
  40. package/skills/prisma-8/references/build.md +12 -16
  41. package/skills/prisma-8/references/contract.md +35 -33
  42. package/skills/prisma-8/references/debug.md +5 -3
  43. package/skills/prisma-8/references/feedback.md +8 -8
  44. package/skills/prisma-8/references/migration-model.md +4 -0
  45. package/skills/prisma-8/references/migration-review.md +6 -5
  46. package/skills/prisma-8/references/migrations.md +73 -26
  47. package/skills/prisma-8/references/queries-mongo.md +3 -3
  48. package/skills/prisma-8/references/queries-postgres.md +25 -9
  49. package/skills/prisma-8/references/queries.md +9 -8
  50. package/skills/prisma-8/references/quickstart.md +19 -19
  51. package/skills/prisma-8/references/runtime.md +23 -23
  52. package/skills/prisma-8/references/supabase.md +7 -7
  53. package/skills/prisma-8/references/upgrade-app.md +1 -1
  54. package/dist/postgres-members-B7ZvxGYc-D_L3NVGm.mjs.map +0 -1
  55. package/dist/postgres-members-F9CVSrrN-BFAuNPbW.d.mts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-postgres",
3
- "version": "8.0.0-rc.24-dev.27",
3
+ "version": "8.0.0-rc.24-dev.29",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -10,26 +10,26 @@
10
10
  "skills"
11
11
  ],
12
12
  "dependencies": {
13
- "@prisma/orm-family-sql": "8.0.0-rc.24-dev.27",
14
- "@prisma/orm-framework": "8.0.0-rc.24-dev.27",
15
- "@prisma/orm-target-postgres": "8.0.0-rc.24-dev.27",
16
- "@prisma/orm-toolchain": "8.0.0-rc.24-dev.27",
13
+ "@prisma/orm-family-sql": "8.0.0-rc.24-dev.29",
14
+ "@prisma/orm-framework": "8.0.0-rc.24-dev.29",
15
+ "@prisma/orm-target-postgres": "8.0.0-rc.24-dev.29",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.24-dev.29",
17
17
  "@types/node": "26.1.2",
18
- "@types/pg": "8.20.4",
19
18
  "arktype": "^2.2.2",
20
19
  "pathe": "^2.0.3",
21
- "pg": "8.22.0",
22
20
  "temporal-spec": "1.0.1",
23
21
  "tinyglobby": "^0.2.17"
24
22
  },
25
23
  "devDependencies": {
26
- "@internal/postgres": "8.0.0-rc.24-dev.27",
27
- "@repo/tsconfig": "8.0.0-rc.24-dev.27",
28
- "@repo/tsdown": "8.0.0-rc.24-dev.27",
24
+ "@internal/postgres": "8.0.0-rc.24-dev.29",
25
+ "@repo/tsconfig": "8.0.0-rc.24-dev.29",
26
+ "@repo/tsdown": "8.0.0-rc.24-dev.29",
29
27
  "tsdown": "0.22.14",
30
28
  "typescript": "5.9.3"
31
29
  },
32
30
  "peerDependencies": {
31
+ "@types/pg": "^8.20.0",
32
+ "pg": "^8.22.0",
33
33
  "temporal-polyfill": "^1.0.4",
34
34
  "typescript": ">=5.9"
35
35
  },
@@ -75,6 +75,7 @@
75
75
  "./contract/validate-once": "./dist/contract__validate-once.mjs",
76
76
  "./contract/validate-storage": "./dist/contract__validate-storage.mjs",
77
77
  "./contract-builder": "./dist/contract-builder.mjs",
78
+ "./contract-types": "./dist/contract-types.mjs",
78
79
  "./control": "./dist/control.mjs",
79
80
  "./driver": "./dist/driver.mjs",
80
81
  "./driver/control": "./dist/driver__control.mjs",
@@ -114,6 +115,7 @@
114
115
  "./family-contract/value-set-derivation-hook": "./dist/family-contract__value-set-derivation-hook.mjs",
115
116
  "./family-runtime": "./dist/family-runtime.mjs",
116
117
  "./family-runtime/internal/prepared-query": "./dist/family-runtime__internal__prepared-query.mjs",
118
+ "./init": "./dist/init.mjs",
117
119
  "./internal/options": "./dist/internal__options.mjs",
118
120
  "./internal/static-context": "./dist/internal__static-context.mjs",
119
121
  "./internal/transaction-members": "./dist/internal__transaction-members.mjs",
@@ -10,12 +10,12 @@ description: >-
10
10
  such as MIGRATION.HASH_MISMATCH. Use when the user asks "what is Prisma
11
11
  8", "where do I start", or compares it to another ORM. Use when the user
12
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
13
+ you see @prisma/orm-* imports, prisma.config.ts with
14
14
  definePrismaConfig, or contract.json / contract.d.ts. Do not use for Prisma
15
15
  ORM 7 or earlier (schema.prisma + @prisma/client).
16
16
  metadata:
17
17
  library: '@prisma/orm-postgres'
18
- library_version: '8.0.0-rc.24-dev.27'
18
+ library_version: '8.0.0-rc.24-dev.29'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -33,7 +33,7 @@ Check these before acting on anything below. Halt on the first one that fails an
33
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
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
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.
36
+ **Import paths in the references.** The reference files name the published packages an application installs: `@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`). Some older per-transition instructions under `upgrading/` name a package by the Prisma repository's workspace name, which is not published; find the `@prisma/orm-*` entry that carries the same module before writing it into user code. 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
37
 
38
38
  ## Never reset or drop a database
39
39
 
@@ -49,7 +49,7 @@ Three steps the user does:
49
49
 
50
50
  1. **Edit your data contract.** ([`references/contract.md`](references/contract.md))
51
51
  2. **The system plans the migrations for you.** ([`references/migrations.md`](references/migrations.md))
52
- 3. **If you need data migrations, you edit `migration.ts` and execute it.** ([`references/migrations.md`](references/migrations.md))
52
+ 3. **If you need a data migration, you write a `dataTransform` in `migration.ts` and execute it.** Inserts, updates and deletes never go in a `rawSql` step. ([`references/migrations.md`](references/migrations.md))
53
53
 
54
54
  Everything else — queries, runtime wiring, build integration, debugging, feedback — sits on top of those three.
55
55
 
@@ -62,17 +62,17 @@ Open the reference whose triggers match the task. If more than one matches, open
62
62
  | Task | Reference | Triggers |
63
63
  | --- | --- | --- |
64
64
  | 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` |
65
- | 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 |
66
- | Author migrations | [`references/migrations.md`](references/migrations.md) | "no migration path", "migration path not found", "no authored path", `MIGRATION.MARKER_MISMATCH`, `MIGRATION.CHANGE_POLICY_FORBIDS`, `MIGRATION.POLICY_MISMATCH`, change policy, data protection policy, `--permit-policy-change`, "reset the database", "drop the database", `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`, data-loss questions (`--delete`, `--rename`, `--allow`, `CLI.CONSENT_REQUIRED`), schema drift |
65
+ | 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`, `@prisma/orm-postgres/config`, `@prisma/orm-postgres/contract-builder`, `@prisma/orm-mongo/config`, `extensions:`, pgvector, postgis, paradedb, Temporal / `temporal-polyfill` / `RUNTIME.TEMPORAL_UNAVAILABLE`, `@@control`, control policy (managed / tolerated / external / observed), soft delete, validations, callbacks |
66
+ | Author migrations | [`references/migrations.md`](references/migrations.md) | "no migration path", "migration path not found", "no authored path", `MIGRATION.MARKER_MISMATCH`, `MIGRATION.CHANGE_POLICY_FORBIDS`, `MIGRATION.DATA_PROTECTION_FORBIDS`, `MIGRATION.POLICY_MISMATCH`, change policy, data protection policy, `--permit-policy-change`, "reset the database", "drop the database", `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`, data-loss questions (`--delete`, `--rename`, `--allow`, `CLI.CONSENT_REQUIRED`), schema drift |
67
67
  | 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 |
68
68
  | 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`, `db migrate --show` |
69
69
  | 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), custom collection class (`extends Collection`), `with` and query fragments (`QueryFragment`, `Filtered`, `Ordered`), shared query fragments and scopes (`db.orm.fragment(fields, body)` for a filter on every model with given fields, `CodecField`, `db.orm.public.Post.fragment(...)` for a shared `select` / `include`, `orderByField` for an order or sort parameter from a request), 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) |
70
70
  | Wire the runtime | [`references/runtime.md`](references/runtime.md) | `db.ts`, `contractFromJson<Contract>(...)`, `postgres({ contract })` / `sqlite({ contract })` / `mongo({ contract })` façades, middleware composition (lints, budgets, cache via `@prisma/orm-extension-middleware-cache`, custom `activityEnded` 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]` |
71
- | 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) |
72
- | 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 |
71
+ | Build-tool integration | [`references/build.md`](references/build.md) | Vite plugin (`@prisma/orm-<target>/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) |
72
+ | Supabase | [`references/supabase.md`](references/supabase.md) | `@prisma/orm-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 |
73
73
  | 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.SCHEMA_VERIFY_FAILED`, `MIGRATION.PRECHECK_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 |
74
- | 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-*` |
75
- | 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/) |
74
+ | 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", `@prisma/orm-*` version bump in an application, per-transition upgrade instructions in [`upgrading/app/upgrades/`](upgrading/app/upgrades/), extension-pin pre-flight, `PN-UPGRADE-*` |
75
+ | Upgrade Prisma in an extension | [`references/upgrade-extension.md`](references/upgrade-extension.md) | the same request in a package that *is* a Prisma extension (`@prisma/orm-framework` / SPI dependency, `^@.*/extension-` name), `prisma-8-check-pins`, exact-pin rule, per-transition instructions in [`upgrading/extension/upgrades/`](upgrading/extension/upgrades/) |
76
76
  | 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 |
77
77
 
78
78
  ## Routing rules
@@ -3,9 +3,9 @@
3
3
 
4
4
  > **Edit your data contract. Prisma handles the rest.**
5
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.
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 the Vite plugin for Vite 7 and Vite 8, `prismaVitePlugin`, which the database package exports from its `vite-plugin-contract-emit` entry (`@prisma/orm-postgres/vite-plugin-contract-emit`, `@prisma/orm-sqlite/vite-plugin-contract-emit`, `@prisma/orm-mongo/vite-plugin-contract-emit`, and the same for MySQL and MariaDB). Next.js, Webpack, esbuild, Rollup, and Turbopack plugins are documented under *What Prisma 8 doesn't do yet* with the workaround.
7
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.
8
+ **If the project is using Vite and consuming the contract, use 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
9
 
10
10
  ## When to Use
11
11
 
@@ -24,25 +24,21 @@ This skill covers Prisma 8's build-tool plugins — the dev-server / build-syste
24
24
 
25
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
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`.
27
+ - **Emission goes through the CLI's own publish path.** The Vite plugin and `prisma contract emit` both call `executeContractEmit`, which renames `contract.d.ts` before `contract.json` and queues writes per output. Never re-implement emission by writing the artefacts yourself; run `prisma contract emit` instead. No database package re-exports `executeContractEmit` (see *What Prisma 8 doesn't do yet*).
28
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
29
 
30
30
  ## Workflow — Vite (the supported path)
31
31
 
32
- ### 1. Install the plugin
32
+ ### 1. Have the plugin
33
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.)
34
+ The plugin ships inside the database package the project already depends on (`@prisma/orm-postgres`, `@prisma/orm-sqlite`, `@prisma/orm-mysql`, `@prisma/orm-mariadb` or `@prisma/orm-mongo`), so there is nothing to install besides Vite itself.
39
35
 
40
36
  ### 2. Wire `vite.config.ts`
41
37
 
42
38
  ```typescript
43
39
  // vite.config.ts
44
40
  import { defineConfig } from 'vite';
45
- import { prismaVitePlugin } from '@internal/vite-plugin-contract-emit';
41
+ import { prismaVitePlugin } from '@prisma/orm-postgres/vite-plugin-contract-emit';
46
42
 
47
43
  export default defineConfig({
48
44
  plugins: [prismaVitePlugin('prisma.config.ts')],
@@ -96,7 +92,7 @@ The Vite plugin is compatible with `@react-router/dev/vite`. Both plugins are li
96
92
 
97
93
  ```typescript
98
94
  import { reactRouter } from '@react-router/dev/vite';
99
- import { prismaVitePlugin } from '@internal/vite-plugin-contract-emit';
95
+ import { prismaVitePlugin } from '@prisma/orm-postgres/vite-plugin-contract-emit';
100
96
 
101
97
  export default defineConfig({
102
98
  plugins: [
@@ -115,12 +111,12 @@ See [`examples/react-router-demo`](https://github.com/prisma/prisma/tree/main/ex
115
111
  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
112
  4. **Expecting `vite build` to re-emit.** It doesn't. Add a `prebuild` script.
117
113
  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.
114
+ 6. **Re-installing dependencies without the plugin's peer-range move.** When a Prisma 8 release changes 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
115
 
120
116
  ## What Prisma 8 doesn't do yet
121
117
 
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.
118
+ - **Next.js plugin.** No first-party Next.js 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.
119
+ - **Webpack, esbuild, Rollup, Turbopack plugins.** None exist yet as first-party. `executeContractEmit`, the function the Vite plugin calls, is exported only by the platform package `@prisma/orm-toolchain` (`cli/control-api`), and no database package re-exports it; an application should not depend on a platform package (it depends on its database package and extension packs only), so do not build a plugin on it. Workaround: run `prisma contract emit` from the bundler's prebuild step (or a `prebuild` script in `package.json`), and rerun it when the contract changes during development. If you want a first-party plugin for your bundler, or a public entry for contract emission, file a feature request via the `references/feedback.md` skill.
124
120
  - **`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
121
  - **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
122
 
@@ -138,5 +134,5 @@ See [`examples/react-router-demo`](https://github.com/prisma/prisma/tree/main/ex
138
134
  - [ ] Editing the contract source triggers a re-emit log line.
139
135
  - [ ] `prebuild` script (or equivalent) runs `prisma contract emit` for CI / production builds.
140
136
  - [ ] 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.
137
+ - [ ] For non-Vite bundlers: surfaced the *What Prisma 8 doesn't do yet* entry and routed the user to `references/feedback.md` if they want first-party support.
138
+ - [ ] Did NOT confabulate a Next.js plugin package or any other bundler-specific plugin that doesn't exist.
@@ -7,7 +7,7 @@ The data contract is the single source of truth for your data layer. You edit a
7
7
 
8
8
  1. **You edit your data contract.**
9
9
  2. **The system plans the migrations for you.** (`references/migrations.md`)
10
- 3. **If you need data migrations, you edit `migration.ts` and execute it.** (`references/migrations.md`)
10
+ 3. **If you need a data migration, you write a `dataTransform` in `migration.ts` and execute it.** Inserts, updates and deletes never go in a `rawSql` step. (`references/migrations.md`)
11
11
 
12
12
  Behind step 1 the agent runs `prisma contract emit` after every contract edit (or installs the Vite plugin so the bundler runs it on save — see `references/build.md`). Emit reads the contract source through the provider the façade picks based on the file extension of `contract:` in `prisma.config.ts`, then writes two artefacts colocated with the source:
13
13
 
@@ -24,10 +24,10 @@ Both files are **emitted artefacts**. Edit the source; never the JSON or `.d.ts`
24
24
  - User wants to set `@@control` on a model or configure `defaultControlPolicy`.
25
25
  - User wants to use a custom type from an extension (`pgvector.Vector(length: 1536)`, `postgis.Geometry(...)`).
26
26
  - User needs a column of a database type no Prisma column type covers (`tsvector`, `ltree`, `circle`, a domain): a raw column, ``Raw(sql`...`)``.
27
- - User wants to install or configure an extension via `extensions: [...]` in `prisma.config.ts`, including `@internal/extension-supabase`.
27
+ - User wants to install or configure an extension via `extensions: [...]` in `prisma.config.ts`, including `@prisma/orm-extension-supabase`.
28
28
  - User is migrating between authoring sources (PSL ↔ TypeScript builder).
29
29
  - User received `CONFIG.CONTRACT_MISSING`, `CONTRACT.VALIDATION_FAILED`, or `CONFIG.MISSING_EXTENSION_PACKS` from `contract emit`.
30
- - User mentions: *schema, fields, models, attributes, prisma schema, PSL, contract.prisma, contract.ts, contract.json, contract.d.ts, contract emit, façade imports, `@internal/postgres/config`, `@internal/postgres/contract-builder`, extensions, pgvector, postgis, paradedb, supabase, namespaces, cross-space FK, `@@control`, enums, check constraints, `@@check`, value objects, validations, callbacks, soft delete, paranoid, scopes*. (The last cluster routes to *What Prisma 8 doesn't do yet* below.)
30
+ - User mentions: *schema, fields, models, attributes, prisma schema, PSL, contract.prisma, contract.ts, contract.json, contract.d.ts, contract emit, façade imports, `@prisma/orm-postgres/config`, `@prisma/orm-postgres/contract-builder`, extensions, pgvector, postgis, paradedb, supabase, namespaces, cross-space FK, `@@control`, enums, check constraints, `@@check`, value objects, validations, callbacks, soft delete, paranoid, scopes*. (The last cluster routes to *What Prisma 8 doesn't do yet* below.)
31
31
 
32
32
  ## When Not to Use
33
33
 
@@ -41,18 +41,18 @@ Both files are **emitted artefacts**. Edit the source; never the JSON or `.d.ts`
41
41
 
42
42
  ## Key Concepts
43
43
 
44
- - **The `@internal/<target>` façade is the only surface user-authored code imports from.** For a Postgres app: `@internal/postgres/config`, `@internal/postgres/contract-builder`, `@internal/postgres/control`, `@internal/postgres/runtime`, `@internal/postgres/static`. Mongo has the same layout (`@internal/mongo/config`, `@internal/mongo/contract-builder`, `@internal/mongo/runtime`, `@internal/mongo/static`). Each extension publishes its own façade — `@internal/extension-pgvector/control`, `@internal/extension-postgis/control`, `@internal/extension-paradedb/control`. **Never reach into `@internal/cli/*`, `@internal/family-*`, `@internal/target-*`, `@internal/adapter-*`, `@internal/driver-*`, or `@internal/sql-contract-*` from user code.** The façade bakes the family / target / adapter / driver wiring in. See *Common Pitfalls* #4.
44
+ - **The `@prisma/orm-<target>` façade is the only surface user-authored code imports from.** For a Postgres app: `@prisma/orm-postgres/config`, `@prisma/orm-postgres/contract-builder`, `@prisma/orm-postgres/control`, `@prisma/orm-postgres/runtime`, `@prisma/orm-postgres/static`. Mongo has the same layout (`@prisma/orm-mongo/config`, `@prisma/orm-mongo/contract-builder`, `@prisma/orm-mongo/runtime`, `@prisma/orm-mongo/static`). Each extension publishes its own façade — `@prisma/orm-extension-pgvector/control`, `@prisma/orm-extension-postgis/control`, `@prisma/orm-extension-paradedb/control`. **Never import the platform packages (`@prisma/orm-framework`, `@prisma/orm-family-*`, `@prisma/orm-target-*`, `@prisma/orm-toolchain`) from user code.** The façade bakes the family / target / adapter / driver wiring in. See *Common Pitfalls* #4.
45
45
  - **Contract source.** A file the framework reads and lowers to the canonical Contract IR. Two flavours, both first-class:
46
46
  - **`contract.prisma` (PSL)** — schema-flavoured DSL. Canonical for typical apps and brownfield Prisma users. Wired by `contract: './<path>/contract.prisma'` — the target config (`ormConfig`, below) detects the `.prisma` extension and routes through the PSL provider. The first line of every `.prisma` file is `// use prisma-8`; `orm init` and `contract infer` write it, and the language server only serves diagnostics, completion, and formatting on files that carry it (it still recognises the header earlier releases wrote and rewrites it on Format).
47
- - **`contract.ts` (TypeScript builder)** — programmatic authoring with `defineContract({...}, ({ field, model, rel, type }) => ({...}))` from `@internal/postgres/contract-builder` (or `@internal/mongo/contract-builder`). Wired by `contract: './<path>/contract.ts'` — the façade detects the `.ts` extension and routes through the TS provider. Use when you need programmatic composition (per-tenant variants, generated fields) or constructs PSL doesn't yet express (e.g. registering a parameterised extension type — see pgvector's contract).
48
- - **An existing Prisma schema, during adoption.** A project that still runs an earlier Prisma can point `contract:` at its current `schema.prisma` instead of writing a Prisma 8 contract: `contract: prisma6Schema('prisma/schema.prisma')` from `@internal/mongo/config` reads a Prisma 6 MongoDB schema, and `prisma7Schema` from `@internal/postgres/config` reads a Prisma 7 Postgres schema. The earlier Prisma keeps owning the database; after each change there, run `contract emit` and `db sign`. A construct Prisma 8 cannot express fails `contract emit` with a `PSL.PRISMA6_MONGO_*` or `PSL.PRISMA7_*` diagnostic. See the façade READMEs for the details.
49
- - **`prisma.config.ts`.** Wires the contract source, the database connection, the migrations directory, and any installed extensions. The file is an *envelope*: the unified CLI's `definePrismaConfig({...})` from `@prisma/cli-engine` wraps an `orm:` section built by the target's `defineConfig` — conventionally imported as `ormConfig` from `@internal/postgres/config` (or `@internal/mongo/config`). There is no flat form; a bare `defineConfig({ contract, ... })` default export fails with `CONFIG.VERSION_MARKER_MISSING`. Pass `formatter: { indent, newline }` to `ormConfig` to set how `prisma contract format` and the language server lay out PSL files: `indent` is a whole number of spaces, 1 or more (default 2), or `'tab'`. `newline` is `'LF'` or `'CRLF'`; without it, `contract format` uses the operating system's line ending and the language server uses LF.
47
+ - **`contract.ts` (TypeScript builder)** — programmatic authoring with `defineContract({...}, ({ field, model, rel, type }) => ({...}))` from `@prisma/orm-postgres/contract-builder` (or `@prisma/orm-mongo/contract-builder`, `@prisma/orm-sqlite/contract-builder`, `@prisma/orm-mysql/contract-builder`, `@prisma/orm-mariadb/contract-builder`). Wired by `contract: './<path>/contract.ts'` — the façade detects the `.ts` extension and routes through the TS provider. Use when you need programmatic composition (per-tenant variants, generated fields) or constructs PSL doesn't yet express (e.g. registering a parameterised extension type — see pgvector's contract).
48
+ - **An existing Prisma schema, during adoption.** A project that still runs an earlier Prisma can point `contract:` at its current `schema.prisma` instead of writing a Prisma 8 contract: `contract: prisma6Schema('prisma/schema.prisma')` from `@prisma/orm-mongo/config` reads a Prisma 6 MongoDB schema, and `prisma7Schema` from `@prisma/orm-postgres/config` reads a Prisma 7 Postgres schema. The earlier Prisma keeps owning the database; after each change there, run `contract emit` and `db sign`. A construct Prisma 8 cannot express fails `contract emit` with a `PSL.PRISMA6_MONGO_*` or `PSL.PRISMA7_*` diagnostic. See the façade READMEs for the details.
49
+ - **`prisma.config.ts`.** Wires the contract source, the database connection, the migrations directory, and any installed extensions. The file is an *envelope*: the unified CLI's `definePrismaConfig({...})` from `@prisma/cli-engine` wraps an `orm:` section built by the target's `defineConfig` — conventionally imported as `ormConfig` from `@prisma/orm-postgres/config` (or `@prisma/orm-mongo/config`). There is no flat form; a bare `defineConfig({ contract, ... })` default export fails with `CONFIG.VERSION_MARKER_MISSING`. Pass `formatter: { indent, newline }` to `ormConfig` to set how `prisma contract format` and the language server lay out PSL files: `indent` is a whole number of spaces, 1 or more (default 2), or `'tab'`. `newline` is `'LF'` or `'CRLF'`; without it, `contract format` uses the operating system's line ending and the language server uses LF.
50
50
 
51
51
  ```typescript
52
52
  // prisma.config.ts — what `prisma orm init` scaffolds
53
53
  import 'dotenv/config';
54
54
  import { definePrismaConfig } from '@prisma/cli-engine';
55
- import { defineConfig as ormConfig } from '@internal/postgres/config';
55
+ import { defineConfig as ormConfig } from '@prisma/orm-postgres/config';
56
56
 
57
57
  export default definePrismaConfig({
58
58
  orm: ormConfig({
@@ -65,8 +65,8 @@ Both files are **emitted artefacts**. Edit the source; never the JSON or `.d.ts`
65
65
  The fields `ormConfig` accepts: `contract` (path string — `.prisma` or `.ts`), `output` (optional override for where `contract.json` lands), `db` (`{ connection?: string }`), `extensions` (array of control descriptors), `migrations` (`{ dir?: string }`), `formatter` (`{ indent?: number | 'tab'; newline?: 'LF' | 'CRLF' }`). Without `output`, the path for `contract.json` is derived from `contract` (e.g. `./src/prisma/contract.prisma` → `./src/prisma/contract.json`). Keep `import 'dotenv/config'` when the config reads `process.env`.
66
66
  - **Emit pipeline.** `prisma contract emit --config <path>?` reads `prisma.config.ts`, calls the provider the façade picked, validates the resulting Contract, then atomically writes `contract.json` + `contract.d.ts` colocated with the source.
67
67
  - **Extension namespaces.** Extensions contribute namespaced constructors (`pgvector.Vector(length: 1536)`, `postgis.Geometry(...)`) and type aliases. Install them by adding the descriptor to **two** places — both fields are named `extensions`, but the two surfaces consume two different descriptor types and shapes:
68
- - **In the config (façade and core):** `extensions: [pgvector]` — array of *control* descriptors imported from `@internal/extension-<name>/control`.
69
- - **In the TS builder's `defineContract` (only when authoring `contract.ts`):** `extensions: { pgvector }` — record of *pack* descriptors imported from `@internal/extension-<name>/pack`.
68
+ - **In the config (façade and core):** `extensions: [pgvector]` — array of *control* descriptors imported from `@prisma/orm-extension-<name>/control`.
69
+ - **In the TS builder's `defineContract` (only when authoring `contract.ts`):** `extensions: { pgvector }` — record of *pack* descriptors imported from `@prisma/orm-extension-<name>/pack`.
70
70
  - **Contract space.** Every package that emits a contract owns its own *contract space* — a `prisma.config.ts` at package root, a contract source, the colocated emitted artefacts, and a `migrations/` directory. **There are two intentional on-disk layouts**, picked by whether the contract space is the consuming application or a contract-space package (an extension, an internal aggregate-root package, etc.):
71
71
  - **Application layout** (what you use when building an *app*). `prisma.config.ts` at repo root; `src/prisma/contract.{prisma,ts}`; `src/prisma/contract.{json,d.ts}` colocated; `src/prisma/db.ts` colocated; migrations under `migrations/app/<timestamp>_<slug>/`. The `app/` segment is the consuming application's space-id; extension space-ids land in sibling `migrations/<extension-space-id>/` directories that the extension packages manage. This is what `examples/prisma-8-demo` uses and what `prisma orm init` scaffolds by default (`src/prisma/contract.prisma` with `db.ts` beside it).
72
72
  - **Contract-space-package layout** (what you use when *publishing* a contract-space package — extensions, internal monorepo packages). `prisma.config.ts` at package root; `src/contract.{prisma,ts}` directly (no `prisma/` subdir); `src/contract.{json,d.ts}` colocated; `migrations/<timestamp>_<slug>/` directly under `migrations/` (no `<space-id>` segment — the package *is* a single space). Documented in `.cursor/rules/contract-space-package-layout.mdc` and ADR 212.
@@ -82,7 +82,7 @@ Both files are **emitted artefacts**. Edit the source; never the JSON or `.d.ts`
82
82
  | `CONFIG.CONTRACT_MISSING` | `contract` not set in `prisma.config.ts`. | Add `contract: './src/prisma/contract.prisma'` (app layout) or `'./src/contract.prisma'` (contract-space-package layout) — likewise for `.ts` sources — to the `ormConfig({...})` section. |
83
83
  | `CONFIG.VERSION_MARKER_MISSING` | The default export was not produced by `definePrismaConfig` / `ormConfig` (a flat `defineConfig({...})`, a plain object, or a Prisma 7 config). | Rewrite to the envelope form in *Key Concepts* above. |
84
84
  | `CONTRACT.VALIDATION_FAILED` | Source loaded but the Contract IR failed structural validation. | Read `meta.errors` for the offending model/field, fix the source, re-emit. |
85
- | `CONFIG.MISSING_EXTENSION_PACKS` | The contract uses a namespaced constructor (e.g. `pgvector.Vector(...)`) but `extensions` in the config does not list a matching descriptor. `meta.missingExtensionPacks` names them. | Install the package, import its control descriptor (`import pgvector from '@internal/extension-pgvector/control'`), add it to `extensions: [...]` in `ormConfig({...})`. |
85
+ | `CONFIG.MISSING_EXTENSION_PACKS` | The contract uses a namespaced constructor (e.g. `pgvector.Vector(...)`) but `extensions` in the config does not list a matching descriptor. `meta.missingExtensionPacks` names them. | Install the package, import its control descriptor (`import pgvector from '@prisma/orm-extension-pgvector/control'`), add it to `extensions: [...]` in `ormConfig({...})`. |
86
86
 
87
87
  ## Workflow — Read the contract source of truth
88
88
 
@@ -118,11 +118,11 @@ model Post {
118
118
 
119
119
  Then run `pnpm prisma contract emit` (or rely on the Vite plugin — see `references/build.md`). Specify cascade behaviour explicitly with `onDelete` / `onUpdate`; the default is `Restrict`.
120
120
 
121
- **Integer, decimal, float, text, boolean, binary and JSON types.** On PostgreSQL, `Int`, `BigInt`, `Float`, `Decimal`, `String`, `Boolean`, `Bytes` and `Json` are convenience types: bare, each is the usual type (`Int` an `int4`, `BigInt` an `int8` read as a `bigint`, `Decimal` a `numeric` read as decimal text, `String` a `text`, `Json` a `json`). An optional `storage` chooses another database type, and `BigInt` also takes `as`: `Int(storage: int2)`, `BigInt(as: number)` (an `int8` read as a `number` in the safe-integer range), `BigInt(storage: numeric)` (an integer of any size, read as a `bigint`), `Float(storage: float4)`, `Decimal(precision: 10, scale: 2)`, `String(storage: varchar, length: 12)`, `String(storage: char, length: 3)`, `Json(storage: jsonb)`. `String(length: 12)` is refused: `length` applies only to `varchar` and `char`. The contract stores the explicit type each call chooses, named after the database type (`Int2`, `Int4`, `Int8BigInt`, `Int8Number`, `NumericString`, `NumericBigInt`, `Float4`, `Float8`, `Text`, `Varchar`, `Char`, `Bool`, `Bytea`, `Jsonb`; a `json` column is `PlainJson`), and writing that type directly is the same. A `json` column cannot be filtered by equality, and PostgreSQL refuses an index or a unique constraint on it; write `Json(storage: jsonb)` for a JSON field that needs any of these. `SmallInt`, `BigIntNumber`, `Numeric`, `UnboundedInt`, `Real` and `VarChar` are deprecated names of `Int2`, `Int8Number`, `NumericString`, `NumericBigInt`, `Float4` and `Varchar`, and warn `PSL_DEPRECATED_SCALAR_NAME`. In a TypeScript contract: `type.BigInt({ as: 'number' })`, `type.String({ storage: 'varchar', length: 64 })`, `type.Json({ storage: 'jsonb' })`.
121
+ **Integer, decimal, float, text, boolean, binary and JSON types.** On PostgreSQL, `Int`, `BigInt`, `Float`, `Decimal`, `String`, `Boolean`, `Bytes` and `Json` are convenience types: bare, each is the usual type (`Int` an `int4`, `BigInt` an `int8` read as a `bigint`, `Decimal` a `numeric` read as decimal text, `String` a `text`, `Json` a `json`). An optional `storage` chooses another database type, and `BigInt` also takes `as`: `Int(storage: int2)`, `BigInt(as: number)` (an `int8` read as a `number` in the safe-integer range), `BigInt(storage: numeric)` (an integer of any size, read as a `bigint`), `Float(storage: float4)`, `Decimal(precision: 10, scale: 2)`, `String(storage: varchar, length: 12)`, `String(storage: char, length: 3)`, `Json(storage: jsonb)`. `String(length: 12)` is refused: `length` applies only to `varchar` and `char`. The contract stores the explicit type each call chooses, named after the database type (`Int2`, `Int4`, `Int8BigInt`, `Int8Number`, `NumericString`, `NumericBigInt`, `Float4`, `Float8`, `Text`, `Varchar`, `Char`, `Bool`, `Bytea`, `Jsonb`; a `json` column is `PlainJson`), and writing that type directly is the same. A `json` column cannot be filtered by equality, and PostgreSQL refuses an index or a unique constraint on it; write `Json(storage: jsonb)` for a JSON field that needs any of these. `SmallInt`, `BigIntNumber`, `Numeric`, `UnboundedInt`, `Real` and `VarChar` are deprecated names of `Int2`, `Int8Number`, `NumericString`, `NumericBigInt`, `Float4` and `Varchar`, and warn `PSL_DEPRECATED_SCALAR_NAME`. In a TypeScript contract: `type.BigInt({ as: 'number' })`, `type.String({ storage: 'varchar', length: 64 })`, `type.Json({ storage: 'jsonb' })`. On SQLite, `Int`, `BigInt`, `Float`, `Decimal`, `String`, `Boolean`, `Bytes` and `Json` are convenience types too, each with one `storage`, the SQLite column type: the contract stores `IntegerNumber` (`Int`, and `BigInt(as: number)`), `IntegerBigInt` (`BigInt`), `Real`, `DecimalString` (`Decimal`), `Text`, `IntegerBoolean` (`Boolean`), `Blob` or `PlainJson`, and writing that type directly is the same. Its column helpers are named after these types: `integerNumberColumn`, `integerBigIntColumn`, `realColumn`, `decimalStringColumn`, `textColumn`, `integerBooleanColumn`, `blobColumn`, `plainJsonColumn`. A SQLite `Boolean` is an `integer` column holding 0 or 1; `@default(true)` is written `DEFAULT 1`, and reading any other stored value raises `RUNTIME.DECODE_FAILED` naming the column. An `Int` (`IntegerNumber`) write refuses a number that is not an integer in the safe-integer range, such as `1.5`. A SQLite `Decimal` is decimal text such as `"12.50"` in a `text` column: a write refuses other text, and since text compares by its characters it takes equality filters only, with no ordering and no aggregates. `BigIntNumber` is a deprecated name of `IntegerNumber` and warns `PSL_DEPRECATED_SCALAR_NAME`; write `BigInt(as: number)`. On MySQL and MariaDB, the eight names are convenience types too: the contract stores `Int4` (`Int`, an `int`), `Int8BigInt` (`BigInt`) or `Int8Number` (`BigInt(as: number)`), both a `bigint`, `Float8` (`Float`, a `double`), `NumericString` (`Decimal`, a `decimal(65,30)`; an unwritten `precision` is 65 and an unwritten `scale` 30, so `Decimal(precision: 40)` is `decimal(40,30)`, unlike PostgreSQL: write both), `Varchar` (`String`, a `varchar(191)` unless `length` is written) or `Text` (`String(storage: text)`), `Bool` (`Boolean`, a `tinyint(1)` holding 0 or 1), `Longblob` (`Bytes`) or `PlainJson` (`Json`, a `json` column, which MariaDB stores as `longtext` with a `json_valid` check). A MySQL `Decimal` reads as the server prints it, padded to the column's scale (`"1.50"` in a `decimal(10,2)`), and has no `avg`. A `Json` field has no equality filter or ordering. A `Bytes`, `Json` or `String(storage: text)` field cannot be an `@id`, and on MySQL not `@unique` either: `db migrate` fails, because MySQL needs a prefix length Prisma does not write. Defaults: `@default(true)`, ``@default(longblob`00ff`)``, ``@default(json`{"a": 1}`)``.
122
122
 
123
- **Date and time types.** On PostgreSQL, write a field with a convenience type named for what it means: `DateTime` (a moment in time, a `timestamptz(3)` read as a JavaScript `Date`), `Date` (a calendar date, read as a string such as `"2024-02-29"`), `Time` (a time of day, read as a string) or `Duration` (an ISO 8601 duration string such as `"P1M"`). None needs `Temporal`. Optional arguments choose another explicit type: `as`, the value the application reads (`jsDate`, `temporal` or `string` for `DateTime`; `string` or `temporal` for `Date` and `Time`; `string` or `parts` for `Duration`), `storage`, the database type that stores it (`timestamptz` or `timestamp` for `DateTime`; `time` or, with `as: string`, `timetz` for `Time`), and `precision`: `DateTime(as: temporal)`, `DateTime(storage: timestamp)`, `Time(precision: 0)`. The contract stores only the explicit type, and `contract print` writes it; the full table is [Scalar types](https://github.com/prisma/orm/blob/main/docs/reference/scalar-types.md). SQLite has the same four types with the same defaults, all stored as text: `DateTime` reads a `Date`, `DateTime(as: temporal)` a `Temporal.Instant` and `DateTime(as: string)` the stored text `"2024-01-01T00:00:00.000Z"`; `Date` and `Time` read `"2024-02-29"` and `"09:30:00.000"`, or `Temporal.PlainDate` and `Temporal.PlainTime` with `as: temporal`; `Duration` reads an ISO 8601 duration. SQLite has no `storage` choices and no `precision`: an instant and a time hold milliseconds. MySQL has the same four types with the same defaults: `DateTime` is a `datetime(3)` read as a `Date`, `storage: timestamp` picks a `timestamp` column (1970 to 2038), and `as: temporal` and `as: string` default to `precision: 6`; `Date` and `Time` read `"2024-02-29"` and `"09:30:00"`; `Duration` is ISO 8601 text in a `varchar(191)`. Every MySQL instant is UTC, and a value written with more fraction digits than its column holds is cut to the column's precision, not rounded, but a value with digits below a microsecond (a `Temporal` value ending in `.123456789`) is refused, so round it to microseconds first; a column with no written precision holds whole seconds. `Time(3)` is refused, because the first argument is `as`; write `Time(precision: 3)`. In a TypeScript contract the helpers take one object: `type.DateTime({ as: 'string', precision: 6 })`, `type.Time({ storage: 'timetz' })`.
123
+ **Date and time types.** On PostgreSQL, write a field with a convenience type named for what it means: `DateTime` (a moment in time, a `timestamptz(3)` read as a JavaScript `Date`), `Date` (a calendar date, read as a string such as `"2024-02-29"`), `Time` (a time of day, read as a string) or `Duration` (an ISO 8601 duration string such as `"P1M"`). None needs `Temporal`. Optional arguments choose another explicit type: `as`, the value the application reads (`jsDate`, `temporal` or `string` for `DateTime`; `string` or `temporal` for `Date` and `Time`; `string` or `parts` for `Duration`), `storage`, the database type that stores it (`timestamptz` or `timestamp` for `DateTime`; `time` or, with `as: string`, `timetz` for `Time`), and `precision`: `DateTime(as: temporal)`, `DateTime(storage: timestamp)`, `Time(precision: 0)`. The contract stores only the explicit type, and `contract print` writes it; the full table is [Scalar types](https://github.com/prisma/orm/blob/main/docs/reference/scalar-types.md). SQLite has the same four types with the same defaults, all stored as text: `DateTime` reads a `Date`, `DateTime(as: temporal)` a `Temporal.Instant` and `DateTime(as: string)` the stored text `"2024-01-01T00:00:00.000Z"`; `Date` and `Time` read `"2024-02-29"` and `"09:30:00.000"`, or `Temporal.PlainDate` and `Temporal.PlainTime` with `as: temporal`; `Duration` reads an ISO 8601 duration. SQLite has no `storage` choices and no `precision`: an instant and a time hold milliseconds. MySQL and MariaDB have the same four types with the same defaults: `DateTime` is a `datetime(3)` read as a `Date`, `storage: timestamp` picks a `timestamp` column (1970 to 2038), and `as: temporal` and `as: string` default to `precision: 6`; `Date` and `Time` read `"2024-02-29"` and `"09:30:00"`; `Duration` is ISO 8601 text in a `varchar(191)`. Every MySQL and MariaDB instant is UTC, and a value written with more fraction digits than its column holds is cut to the column's precision, not rounded, but a value with digits below a microsecond (a `Temporal` value ending in `.123456789`) is refused, so round it to microseconds first; a column with no written precision holds whole seconds. `Time(3)` is refused, because the first argument is `as`; write `Time(precision: 3)`. In a TypeScript contract the helpers take one object: `type.DateTime({ as: 'string', precision: 6 })`, `type.Time({ storage: 'timetz' })`.
124
124
 
125
- **Temporal columns.** On PostgreSQL, `DateTemporal`, `TimestampTemporal(p)`, `TimestampInstant(p)`, `TimestamptzTemporal(p)` and `TimeTemporal(p)`, on SQLite `DatetimeTemporal`, `DateTemporal` and `TimeTemporal`, on MySQL `DatetimeTemporal(p)`, `TimestampTemporal(p)`, `DateTemporal` and `TimeTemporal(p)`, on MongoDB `DateInstant`, `DateTemporal` and `TimeTemporal` (and a convenience type with `as: temporal` on any of them) read and write `Temporal` values (`Temporal.PlainDate`, `PlainDateTime`, `Instant` for both instant types, `PlainTime`), never JavaScript `Date`. They need a global `Temporal` at query time: Node.js 26.8.2 and later ship `globalThis.Temporal`; 26.8.1 and earlier — including every 22 and 24 release — do not, and the first read or write of such a column throws `RUNTIME.TEMPORAL_UNAVAILABLE`. On those runtimes either `import 'temporal-polyfill/full/global'` before the first query (add `temporal-polyfill` as a dependency) or author the column as `DateString` / `TimestampString(p)` / `TimestamptzString(p)` / `TimeString(p)`, which carry ISO 8601 text, the same on every server (`2024-01-01T00:00:00Z` for a `timestamptz`, the instant in UTC), and need no `Temporal`, or as `TimestamptzJsDate(p)` / `TimestampJsDate(p)`, which read a JavaScript `Date`. `IntervalParts(p)` reads `{ months, days, micros }` and `IntervalString(p)` an ISO 8601 duration such as `P1Y2M`. `prisma contract emit`, `prisma db init` and the other commands need no global `Temporal`: the Postgres, SQLite, MySQL and MongoDB targets load `temporal-polyfill` as a fallback `Temporal` for the control plane, and set no global. `temporal-polyfill` is a required peer dependency of `@prisma/orm-postgres`, `@prisma/orm-sqlite`, `@prisma/orm-mysql` and `@prisma/orm-mongo`. npm, pnpm and bun install it automatically. With Yarn, add `temporal-polyfill` (`^1.0.4`) to the project's dependencies, or the commands fail because Node.js cannot find the package. That fallback is held once per process. An application that loads control-plane code in its own process, such as server code under `vite dev` with the Prisma Vite plugin or a script that calls the control client, decodes dates without its own `Temporal`, and then fails in production. An application that uses the Temporal codecs must load its own `Temporal`. A TypeScript contract file that constructs a `Temporal` value must load an implementation too.
125
+ **Temporal columns.** On PostgreSQL, `DateTemporal`, `TimestampTemporal(p)`, `TimestampInstant(p)`, `TimestamptzTemporal(p)` and `TimeTemporal(p)`, on SQLite `DatetimeTemporal`, `DateTemporal` and `TimeTemporal`, on MySQL and MariaDB `DatetimeTemporal(p)`, `TimestampTemporal(p)`, `DateTemporal` and `TimeTemporal(p)`, on MongoDB `DateInstant`, `DateTemporal` and `TimeTemporal` (and a convenience type with `as: temporal` on any of them) read and write `Temporal` values (`Temporal.PlainDate`, `PlainDateTime`, `Instant` for both instant types, `PlainTime`), never JavaScript `Date`. They need a global `Temporal` at query time: Node.js 26.8.2 and later ship `globalThis.Temporal`; 26.8.1 and earlier — including every 22 and 24 release — do not, and the first read or write of such a column throws `RUNTIME.TEMPORAL_UNAVAILABLE`. On those runtimes either `import 'temporal-polyfill/full/global'` before the first query (add `temporal-polyfill` as a dependency) or author the column as `DateString` / `TimestampString(p)` / `TimestamptzString(p)` / `TimeString(p)`, which carry ISO 8601 text, the same on every server (`2024-01-01T00:00:00Z` for a `timestamptz`, the instant in UTC), and need no `Temporal`, or as `TimestamptzJsDate(p)` / `TimestampJsDate(p)`, which read a JavaScript `Date`. `IntervalParts(p)` reads `{ months, days, micros }` and `IntervalString(p)` an ISO 8601 duration such as `P1Y2M`. `prisma contract emit`, `prisma db init` and the other commands need no global `Temporal`: the Postgres, SQLite, MySQL, MariaDB and MongoDB targets load `temporal-polyfill` as a fallback `Temporal` for the control plane, and set no global. `temporal-polyfill` is a required peer dependency of `@prisma/orm-postgres`, `@prisma/orm-sqlite`, `@prisma/orm-mysql`, `@prisma/orm-mariadb` and `@prisma/orm-mongo`. npm, pnpm and bun install it automatically. With Yarn, add `temporal-polyfill` (`^1.0.4`) to the project's dependencies, or the commands fail because Node.js cannot find the package. That fallback is held once per process. An application that loads control-plane code in its own process, such as server code under `vite dev` with the Prisma Vite plugin or a script that calls the control client, decodes dates without its own `Temporal`, and then fails in production. An application that uses the Temporal codecs must load its own `Temporal`. A TypeScript contract file that constructs a `Temporal` value must load an implementation too.
126
126
 
127
127
  `@@index` also accepts `expression:` (instead of a fields list), `where:` (partial-index predicate), `unique:`, `type:`/`options:` (target-registered access method), and `name:` xor `map:`. Raw SQL in `expression:` and `where:` is a `sql` literal; a quoted string is refused with `PSL_VALUE_TYPE_INCOMPATIBLE`, whose message gives the rewrite:
128
128
 
@@ -171,12 +171,12 @@ Note: scalar lists (e.g. `String[]`) are gated on the target's `sql.scalarList`
171
171
 
172
172
  ## Workflow — Edit a model / field / relation (TS builder)
173
173
 
174
- The concept: same model, different authoring surface. The façade re-exports `defineContract`, `field`, `model`, `rel`, plus the `family`/`target` packs as default exports of `@internal/postgres/family` and `@internal/postgres/target`. Use the callback overload (`defineContract({...}, ({ field, model, rel, type, gen }) => ({...}))`) to get the type constructors, type aliases and generator calls (`field.column(type.String())`, `field.column(type.Uuid()).id().onCreate(gen.uuid(7))`, `field.column(type.temporal.CreatedAt())`, `type.sql.Varchar(35)`).
174
+ The concept: same model, different authoring surface. The façade re-exports `defineContract`, `field`, `model`, `rel`, plus the `family`/`target` packs as default exports of `@prisma/orm-postgres/family` and `@prisma/orm-postgres/target`. Use the callback overload (`defineContract({...}, ({ field, model, rel, type, gen }) => ({...}))`) to get the type constructors, type aliases and generator calls (`field.column(type.String())`, `field.column(type.Uuid()).id().onCreate(gen.uuid(7))`, `field.column(type.temporal.CreatedAt())`, `type.sql.Varchar(35)`).
175
175
 
176
176
  ```typescript
177
- import sqlFamily from '@internal/postgres/family';
178
- import { defineContract } from '@internal/postgres/contract-builder';
179
- import postgresPack from '@internal/postgres/target';
177
+ import sqlFamily from '@prisma/orm-postgres/family';
178
+ import { defineContract } from '@prisma/orm-postgres/contract-builder';
179
+ import postgresPack from '@prisma/orm-postgres/target';
180
180
 
181
181
  export const contract = defineContract(
182
182
  {
@@ -197,9 +197,9 @@ export const contract = defineContract(
197
197
  );
198
198
  ```
199
199
 
200
- Then `pnpm prisma contract emit`. On Postgres, `@prisma/orm-postgres/contract-builder` exports `field`, `type` and `gen`, the same helpers the callback receives, without the ones an extension adds (such as pgvector's `type.pgvector.Vector`); for those, use the callback's helpers. MongoDB's `@prisma/orm-mongo/contract-builder` exports them too, with the same limit. On other targets `type` and `gen` are only available inside the callback overload.
200
+ Then `pnpm prisma contract emit`. Every facade's `contract-builder` entry exports `field` and `gen`. The Postgres, SQLite and MongoDB entries also export `type`. These are the helpers the callback receives, without the ones an extension adds (such as pgvector's `type.pgvector.Vector`); for those, use the callback's helpers. On MySQL and MariaDB, `type` is only available inside the callback overload.
201
201
 
202
- For Mongo, swap every `@internal/postgres/*` import for `@internal/mongo/*`. The Mongo builder also exposes `index` and `valueObject`.
202
+ For Mongo, swap every `@prisma/orm-postgres/*` import for `@prisma/orm-mongo/*`. The Mongo builder also exposes `index` and `valueObject`.
203
203
 
204
204
  Mongo scalar types, as PSL name / TS builder / application type: `String` / `field.scalar(type.String())` / `string`; `Int` / `field.scalar(type.Int())` / `number` (a BSON int); `BigInt` / `field.scalar(type.BigInt())` / `bigint` (a BSON long); `BigInt(as: number)` / `field.scalar(type.BigInt({ as: 'number' }))` / `number` in the safe-integer range (a BSON long); `Float` / `field.scalar(type.Float())` / `number`; `Decimal` / `field.scalar(type.Decimal())` / decimal text as a `string`; `Boolean` / `field.scalar(type.Boolean())` / `boolean`; `DateTime` / `field.scalar(type.DateTime())` / `Date` (an instant, a BSON date); `Date` / `field.scalar(type.Date())` / `string` such as `"2024-02-29"` (a calendar date, a BSON date at midnight UTC); `Time` / `field.scalar(type.Time())` / `string` such as `"09:30:00.000"`; `Duration` / `field.scalar(type.Duration())` / an ISO 8601 duration `string`; `ObjectId` / `field.scalar(type.ObjectId())` / `string`; `Bytes` / `field.scalar(type.Bytes())` / `Uint8Array`; `Json` / `field.scalar(type.Json())` / `JsonValue`; `Bson` / `field.scalar(type.Bson())` / `BsonValue`. `Int`, `BigInt`, `Float`, `Decimal`, `Boolean`, `Bytes`, `String` and `Json` are convenience types: the contract stores the explicit type each chooses, named after the BSON type (`Int32`, `Int64BigInt`, `Int64Number`, `Double`, `Decimal128`, `Bool`, `Binary`, `BsonString`, `PlainJson`), and writing that type directly is the same. `Int64` is a deprecated name of `Int64BigInt` and warns `PSL_DEPRECATED_SCALAR_NAME`; `type.Int64()` no longer exists, so write `type.BigInt()`. `Json` holds a JSON value only, validated as the JSON-representable BSON types (`storage: bson`, its one storage, is not the `Bson` type); `Bson` holds any BSON value, unconstrained by the validator. `DateTime`, `Date` and `Time` take `as: temporal` for `Temporal.Instant`, `Temporal.PlainDate` and `Temporal.PlainTime`, and `DateTime` takes `as: string` for the instant's ISO text. Before Prisma 8's convenience types, MongoDB's `Date` was the instant; write `DateTime` for an instant. The full table, with codec ids and storage types, is [Scalar types](https://github.com/prisma/orm/blob/main/docs/reference/scalar-types.md).
205
205
 
@@ -214,8 +214,8 @@ The concept: an extension contributes a namespace (`pgvector.*`) plus two descri
214
214
  ```typescript
215
215
  import 'dotenv/config';
216
216
  import { definePrismaConfig } from '@prisma/cli-engine';
217
- import pgvector from '@internal/extension-pgvector/control';
218
- import { defineConfig as ormConfig } from '@internal/postgres/config';
217
+ import pgvector from '@prisma/orm-extension-pgvector/control';
218
+ import { defineConfig as ormConfig } from '@prisma/orm-postgres/config';
219
219
 
220
220
  export default definePrismaConfig({
221
221
  orm: ormConfig({
@@ -294,6 +294,8 @@ model Feature {
294
294
  }
295
295
  ```
296
296
 
297
+ An STI variant's relations put their foreign keys on the base table. Its `@@unique`, `@unique` and `@@index` without `where:` are refused, because on the shared table they would also cover the other variants' rows; scope the index to the variant instead, as in ``@@index([severity], unique: true, where: sql`type = 'bug'`)``. Without `where:`, only a plain `@@index` that backs one of the variant's own relations is accepted: the index its foreign key creates anyway, or the one its `index:` argument names. A unique is always refused, so a one-to-one relation from a single-table variant is not supported yet. A variant `@@index` with `where:` becomes a partial index on the base table; before, it was dropped from the contract. A variant relation is refused when another model of the table maps one of its columns without the same relation, or when its column has a `@default`, which every row of the table gets: give the variant's field its own column with `@map`, or remove the default. `@@check` on an STI variant is refused; declare it on the base.
298
+
297
299
  A variant's base can be in another namespace: write `@@base(ns.Model, "value")`. Such a variant must set `@@map(...)`, because a variant that shares its base's table has to be in the base's namespace.
298
300
 
299
301
  Verify the polymorphism syntax against the interpreter tests if in doubt: `packages/2-sql-family/2-authoring/contract-psl/test/interpreter.polymorphism.test.ts`.
@@ -454,7 +456,7 @@ namespace public {
454
456
  }
455
457
  ```
456
458
 
457
- `supabase:auth.AuthUser` means: model `AuthUser` in namespace `auth` of contract space `supabase`. The target space is provided by a registered extension pack (here `@internal/extension-supabase/pack`).
459
+ `supabase:auth.AuthUser` means: model `AuthUser` in namespace `auth` of contract space `supabase`. The target space is provided by a registered extension pack (here `@prisma/orm-extension-supabase/pack`).
458
460
 
459
461
  Canonical worked example: `examples/supabase/src/contract.prisma`.
460
462
 
@@ -473,7 +475,7 @@ model AuditLog {
473
475
 
474
476
  A contract-level default can be set via `defaultControlPolicy` on `prismaContract(path, { defaultControlPolicy })`. See `references/migrations.md` for how control policies affect DDL planning.
475
477
 
476
- ## Workflow — `@internal/extension-supabase`
478
+ ## Workflow — `@prisma/orm-extension-supabase`
477
479
 
478
480
  The concept: the Supabase extension provides the `supabase` contract space (the `auth` / `storage` schemas as `external` tables, plus the platform roles) and its own role-first runtime factory. Its descriptor is the `pack` export, and it goes into the same `extensions` array as any other extension. See `examples/supabase` for the full working pattern.
479
481
 
@@ -481,8 +483,8 @@ The concept: the Supabase extension provides the `supabase` contract space (the
481
483
 
482
484
  ```typescript
483
485
  import { definePrismaConfig } from '@prisma/cli-engine';
484
- import supabasePack from '@internal/extension-supabase/pack';
485
- import { defineConfig as ormConfig } from '@internal/postgres/config';
486
+ import supabasePack from '@prisma/orm-extension-supabase/pack';
487
+ import { defineConfig as ormConfig } from '@prisma/orm-postgres/config';
486
488
 
487
489
  export default definePrismaConfig({
488
490
  orm: ormConfig({
@@ -493,9 +495,9 @@ export default definePrismaConfig({
493
495
  });
494
496
  ```
495
497
 
496
- `db.ts` does **not** use the stock `postgres()` factory — a Supabase app builds its client with the `supabase()` factory from `@internal/extension-supabase/runtime` (role-first: `asUser(jwt)` / `asAnon()` / `asServiceRole()`, JWT validation, RLS). That runtime — and RLS policy authoring (`policy_select` / `@@rls`) — is covered by **`references/supabase.md`**; load it for anything past the config wiring.
498
+ `db.ts` does **not** use the stock `postgres()` factory — a Supabase app builds its client with the `supabase()` factory from `@prisma/orm-extension-supabase/runtime` (role-first: `asUser(jwt)` / `asAnon()` / `asServiceRole()`, JWT validation, RLS). That runtime — and RLS policy authoring (`policy_select` / `@@rls`) — is covered by **`references/supabase.md`**; load it for anything past the config wiring.
497
499
 
498
- Export subpaths: `@internal/extension-supabase/pack`, `@internal/extension-supabase/runtime`, `@internal/extension-supabase/contract`. Canonical worked example: `examples/supabase`.
500
+ Export subpaths: `@prisma/orm-extension-supabase/pack`, `@prisma/orm-extension-supabase/runtime`, `@prisma/orm-extension-supabase/contract`. Canonical worked example: `examples/supabase`.
499
501
 
500
502
  ## Workflow — Brownfield introspection
501
503
 
@@ -512,9 +514,9 @@ Infer captures indexes at full fidelity — expression, partial (`where:`), uniq
512
514
 
513
515
  1. **Forgetting to re-emit after an edit.** `contract.json` and `contract.d.ts` go stale; downstream typecheck and `migration plan` see the old shape. Re-emit, or install the Vite plugin (`references/build.md`).
514
516
  2. **Editing the emitted artefacts.** `contract.json` and `contract.d.ts` are emitted; edits there round-trip away on the next emit. Edit the source.
515
- 3. **Wrong factory/import path for the TS builder.** `defineContract`, `field`, `model`, `rel` come from `@internal/postgres/contract-builder` (or `@internal/mongo/contract-builder`). On Postgres the facade also exports `type` and `gen` (`field.column(type.TimestamptzTemporal())`, `.onCreate(gen.uuid())`) without an extension's helpers; elsewhere, outside the callback overload, the available field constructors are `field.column(...)` and `field.namedType(...)`.
516
- 4. **Reaching into internal packages from user code.** User-authored files (`prisma.config.ts`, `contract.ts`, `db.ts`, control clients) import only from `@internal/<target>/<subpath>` and `@internal/extension-<name>/<subpath>`. Imports from `@internal/cli/*`, `@internal/family-*`, `@internal/target-*`, `@internal/adapter-*`, `@internal/driver-*`, or `@internal/sql-contract-*` are framework-internal — the façade composes them for you. If a façade subpath you need is missing for your target, see *What Prisma 8 doesn't do yet* and route to `references/feedback.md`. The canonical worked examples are `examples/multi-extension-monorepo/app/prisma.config.ts` and `examples/prisma-8-postgis-demo/prisma.config.ts`.
517
- 5. **Confusing the config `extensions` with the TS builder's `extensions`.** Same packs, two surfaces, one field name but two shapes: `ormConfig({ extensions: [pgvector] })` (array of *control* descriptors from `@internal/extension-<name>/control`) versus `defineContract({ extensions: { pgvector } })` (record of *pack* descriptors from `@internal/extension-<name>/pack`).
517
+ 3. **Wrong factory/import path for the TS builder.** `defineContract`, `field`, `model`, `rel` come from `@prisma/orm-postgres/contract-builder` (or the `contract-builder` entry of the SQLite, MySQL, MariaDB or Mongo facade). Every facade's `contract-builder` exports `gen` (`.onCreate(gen.uuid())`). The Postgres, SQLite and Mongo facades also export `type` (`field.column(type.TimestamptzTemporal())` on Postgres); on MySQL and MariaDB, outside the callback overload, the available field constructors are `field.column(...)` and `field.namedType(...)`.
518
+ 4. **Reaching into internal packages from user code.** User-authored files (`prisma.config.ts`, `contract.ts`, `db.ts`, control clients) import only from `@prisma/orm-<target>/<subpath>` and `@prisma/orm-extension-<name>/<subpath>`. Imports from the platform packages (`@prisma/orm-framework`, `@prisma/orm-family-*`, `@prisma/orm-target-*`, `@prisma/orm-toolchain`) are framework wiring — the façade composes them for you, and an application that depends on a façade does not install them directly. If a façade subpath you need is missing for your target, see *What Prisma 8 doesn't do yet* and route to `references/feedback.md`. The canonical worked examples are `examples/multi-extension-monorepo/app/prisma.config.ts` and `examples/prisma-8-postgis-demo/prisma.config.ts`.
519
+ 5. **Confusing the config `extensions` with the TS builder's `extensions`.** Same packs, two surfaces, one field name but two shapes: `ormConfig({ extensions: [pgvector] })` (array of *control* descriptors from `@prisma/orm-extension-<name>/control`) versus `defineContract({ extensions: { pgvector } })` (record of *pack* descriptors from `@prisma/orm-extension-<name>/pack`).
518
520
  6. **Writing a flat `prisma.config.ts`.** `export default defineConfig({ contract, extensions })` from the target config alone is the pre-rc.4 shape and fails with `CONFIG.VERSION_MARKER_MISSING`. Wrap it: `definePrismaConfig({ orm: ormConfig({...}) })`.
519
521
  7. **Renaming a model or field and expecting the planner to detect it.** The contract does not record renames, so the planner sees a destructive drop+add. State the rename on the command line with `--rename old:new` on `migration plan` or `db update` (see `references/migrations.md`); the planner then renames instead of dropping. Do not invent a rename attribute in the contract source.
520
522
  8. **Quoting a type-constructor argument.** A type constructor's argument is a value, read as an attribute argument is. Write a length, precision or scale as a plain whole number: `Varchar(255)`, `NumericString(10, 2)`, `String(storage: varchar, length: 255)`. `Varchar("255")` is refused with `Expected a number; write 255`, and on Postgres `Varchar(255.0)` is refused too, because a number with a fraction is not a 32-bit integer.
@@ -541,9 +543,9 @@ Infer captures indexes at full fidelity — expression, partial (`where:`), uniq
541
543
  ## Checklist
542
544
 
543
545
  - [ ] Read `prisma.config.ts` and identified the contract source (path string ending in `.prisma` or `.ts`) and the installed `extensions: [...]`.
544
- - [ ] All user-authored imports resolve to `@internal/<target>/<subpath>` (e.g. `@internal/postgres/config`) or `@internal/extension-<name>/<subpath>`. No imports from `@internal/cli/*`, `@internal/family-*`, `@internal/target-*`, `@internal/adapter-*`, `@internal/driver-*`, or `@internal/sql-contract-*` in user files.
546
+ - [ ] Every Prisma ORM import in a user-authored file resolves to `@prisma/orm-<target>/<subpath>` (e.g. `@prisma/orm-postgres/config`) or to `@prisma/orm-extension-<name>` or one of its subpaths, apart from `definePrismaConfig` in `prisma.config.ts`, which comes from `@prisma/cli-engine`. No imports from `@prisma/orm-framework`, `@prisma/orm-family-*`, `@prisma/orm-target-*` or `@prisma/orm-toolchain` in user files.
545
547
  - [ ] Edited the contract source (`contract.prisma` or `contract.ts`), not an emitted artefact.
546
- - [ ] For new extension namespaces: added the package, imported its control descriptor (`@internal/extension-<name>/control`), added it to `extensions: [...]` in `ormConfig({...})` (and the matching pack descriptor to `defineContract({extensions: {...}})` if using the TS builder).
548
+ - [ ] For new extension namespaces: added the package, imported its control descriptor (`@prisma/orm-extension-<name>/control`, or `/pack` for a package with no `/control` entry, such as Supabase), added it to `extensions: [...]` in `ormConfig({...})` (and the matching pack descriptor to `defineContract({extensions: {...}})` if using the TS builder).
547
549
  - [ ] `prisma.config.ts` is the envelope form — `definePrismaConfig({ orm: ormConfig({...}) })` — not a flat `defineConfig({...})`.
548
550
  - [ ] For renames: passed `--rename old:new` to `migration plan` or `db update` (or hand-edited `migration.ts` where statements do not cover the rename).
549
551
  - [ ] Ran `pnpm prisma contract emit` after the edit (or let the Vite plugin re-emit on save).
@@ -89,7 +89,7 @@ The single source of truth: read the envelope, find the row by `code`, follow th
89
89
  | `MIGRATION.UNFILLED_PLACEHOLDER` | `node <package dir>/migration.ts` (self-emit) or `db migrate` | Edit `migration.ts`, replace the `placeholder("<slot>")` named by `meta.slot` with a real query closure, self-emit. See `references/migrations.md`. |
90
90
  | `MIGRATION.FILE_MISSING` | Reading a migration package | Restore from version control or scaffold a fresh package with `migration plan` / `migration new`. |
91
91
  | `MIGRATION.INVALID_DEFAULT_EXPORT` | Loading `migration.ts` | Use `export default class extends Migration<Start, End> { ... }` (or a factory returning `{ operations, targetId, destination }`). See `references/migrations.md`. |
92
- | `MIGRATION.DATA_TRANSFORM_CONTRACT_MISMATCH` | Building a data-transform query plan | Pass the same `endContract` reference to both `this.dataTransform(endContract, …)` and the query-builder context. |
92
+ | `MIGRATION.DATA_TRANSFORM_CONTRACT_MISMATCH` | Building a data-transform query plan | Pass the `contract` that `postgres({ contract: contractFromJson<End>(endContract) })` returns to `this.dataTransform(contract, …)`, and build the queries with that client's `sql`. |
93
93
  | `MIGRATION.HASH_MISMATCH` | Any read of a migration package (`plan`, `list`, `db migrate`) | `ops.json` / `migration.json` were edited without self-emitting. Run `node <package dir>/migration.ts` to re-emit. |
94
94
  | `CONTRACT.MARKER_MISSING` | `db verify` (`error` diagnostic, exit 4), runtime startup (warning) | DB has no marker yet. Run `prisma db init --db <url>` (baseline empty DB), `db update --db <url>` (apply contract directly), or `db sign --db <url>` if the schema already matches the contract. |
95
95
  | `CONTRACT.MARKER_MISMATCH` | `db verify` (exit 4), runtime startup (warning) | Marker disagrees with contract hash (`meta.expected` / `meta.actual`). Either migrate forward (`db migrate` / `db update`), or — if the DB is correct after a manual fix-up — `db sign`. See `references/migrations.md`. |
@@ -105,8 +105,9 @@ The single source of truth: read the envelope, find the row by `code`, follow th
105
105
  | `await db.close()` or the end of an `await using` scope never settles in a test | A test that installed fake timers (`vi.useFakeTimers()`, Jest's modern fake timers) before the Prisma runtime module was imported | `close()` waits one turn of the event loop through a `setTimeout(0)` that the runtime module takes when it loads. Install fake timers after the imports, or advance the fake clock (`await vi.runAllTimersAsync()`) before awaiting the close. |
106
106
  | `MIGRATION.MARKER_MISMATCH` | `db migrate`, `db migrate --show`, a Composer deploy | The database's marker is not in the migration graph, usually because a migration it applied was planned again or deleted. `why` names the last graph contract it applied and the missing migrations. `nextActions` gives the one recovery the database's change policy permits. Follow `references/migrations.md` § *A database whose marker is not in the migration graph*. Never reset or drop the database. |
107
107
  | `MIGRATION.CHANGE_POLICY_FORBIDS` | `db update`, `db sign`, `db migrate` | The database's change policy does not include what the command does. When `db update` or `db sign` is refused, author a migration with `migration plan` and apply it with `db migrate`. See `references/migrations.md` § *Policies*. |
108
+ | `MIGRATION.DATA_PROTECTION_FORBIDS` | `db update`, `db migrate`, `migration plan --to <ref>`, a Composer deploy | The database's data protection policy (or, for `migration plan`, the ref's) forbids an operation that loses data or changes who can read or write rows. `meta.operations` lists them. The operation cannot run on that database. State a `--rename` if it was only a rename, plan a type change with `migration plan --convert`, or keep the model or field. `--delete` and `--allow` do not help, and never loosen the policy to make a deploy pass. See `references/migrations.md` § *Policies*. |
108
109
  | `MIGRATION.POLICY_MISMATCH` | `db migrate --to <ref>`, `db update --to <ref>`, a Composer deploy | The ref declares a policy that differs from the database's. Fix the ref, or have the database's owner apply the change. Never loosen a policy to make a deploy pass. See `references/migrations.md` § *Policies*. |
109
- | `MIGRATION.PATH_UNREACHABLE` | `db migrate`, a Composer deploy | The marker is in the graph but no migration reaches the target from it. Run `migration plan --from <marker> --to <target>`, then `db migrate`; `migration list` audits the graph. |
110
+ | `MIGRATION.PATH_UNREACHABLE` | `db migrate`, a Composer deploy | The marker is in the graph but no migration reaches the target from it. Run the two commands the error prints: a `migration plan --from <marker> --name <slug>`, with `--to <target>` unless the target is the emitted contract (a contract change emitted but not planned), then the `db migrate` that was run, with its flags. When the space has no migrations yet, neither command has `--to`, and the `db migrate` is printed without the run's other flags. When an extension space has no path, the error says to install a version of the extension whose migrations start where the database is. `migration list` audits the graph. |
110
111
  | `MIGRATION.PLAN_ORIGIN_UNKNOWN` / `MIGRATION.HASH_NOT_IN_GRAPH` / `MIGRATION.SNAPSHOT_MISSING` | `migration plan`, `migration new` | Origin resolution — `references/migration-model.md` § *The trap* and `references/migrations.md` § *Dev → ship transition*. |
111
112
  | `MIGRATION.MISSING_INVARIANTS` | `migration status` `warn` diagnostic (exit 0) | The live marker reached the destination hash structurally but doesn't carry all invariants the target ref requires. Run `db migrate --to <name> --db $URL` to take a path that covers the missing invariants. See `references/migration-review.md`. |
112
113
  | `MIGRATION.MARKER_NOT_IN_HISTORY` / `CONTRACT.UNREADABLE` | `migration status` `warn` diagnostics (exit 0) | Read `severity` *and* `code`. Up-to-date / pending / no-marker states are not codes — read `spaces[].currentContract` and `migrations[].status` in the `--json` document. `references/migration-review.md` covers the marker-out-of-history flow. |
@@ -114,7 +115,8 @@ The single source of truth: read the envelope, find the row by `code`, follow th
114
115
  | `LINT.SELECT_STAR` / `LINT.NO_LIMIT` / `LINT.DELETE_WITHOUT_WHERE` / `LINT.UPDATE_WITHOUT_WHERE` / `LINT.READ_ONLY_MUTATION` | Runtime, when the `lints` middleware is active | Fix the query (add a `WHERE` / `LIMIT` / explicit columns), or relax the lint config. See `references/runtime.md`. |
115
116
  | `PLAN.HASH_MISMATCH` | Runtime, executing a precompiled plan | The contract the plan was built against does not match the runtime contract. Re-emit, rebuild, redeploy. |
116
117
  | `RUNTIME.TEMPORAL_UNAVAILABLE` | Runtime, first read or write touching a Temporal-backed column (`DateTemporal`, `TimestampTemporal(p)`, `TimestampInstant(p)`, `TimestamptzTemporal(p)`, `TimeTemporal(p)`, and `DateTime`, `Date` or `Time` with `as: temporal`) | No global `Temporal`. Node.js 26.8.2 and later ship `globalThis.Temporal`; 26.8.1 and earlier — including every 22 and 24 — do not. Either `import 'temporal-polyfill/full/global'` before the first query, or write the field as a convenience type at its default (`DateTime`, `Date`, `Time`), which reads a JavaScript `Date` or a string. |
117
- | `ORM.RELATION_MUTATION_UNSUPPORTED` | ORM nested `create` / `connect` on an N:M relation whose junction has required payload columns | Write the junction table directly or use the SQL builder (`meta.junction`). |
118
+ | `ORM.OPERATION_UNSUPPORTED` | ORM operation used where it is not supported; `meta.reason` says why | With `reason: 'junction-required-columns'` (nested `create` / `connect` on an N:M relation whose junction has required payload columns): write the junction table directly or use the SQL builder (`meta.junction`). Other reasons: `docs/reference/error-reference.md#ORM.OPERATION_UNSUPPORTED`. |
119
+ | `ORM.OPERATION_UNSUPPORTED` with `reason: 'required-foreign-key'` | ORM nested `disconnect()` on a relation whose foreign key is required (`meta.model`, `meta.fields`) | If `meta.model` is the model being updated, the record holds the key (a many-to-one relation, such as `Post.author`): `connect` it to another row or delete the record. Otherwise the related rows hold it (one-to-many, or one-to-one from the side without the key): connect them to another record or delete them. Or make the key optional. |
118
120
  | `RUNTIME.ABORTED` (`details.phase` = `encode\|decode\|stream\|beforeEncode\|onRow`) | Runtime, when an `AbortSignal` fires mid-execute | Cancellation, not a bug; surface to the caller. |
119
121
  | `SqlQueryError` (no dotted code) | Raw-SQL paths surfacing a driver error | Inspect `sqlState` + `constraint` + `table` + `column`. Postgres `23505` = unique violation, `23503` = foreign-key violation, etc. Fix the data or the schema. |
120
122
  | TypeScript error mentioning a capability (e.g. `returning()` not on the type, `include` of a many-relation off a many-load) | Authoring-time, before any envelope fires | Capability gates are declared in the **contract** (`capabilities` block, namespaced by target/family), not in `prisma.config.ts`. Route to `references/contract.md` for capability declaration and to `references/queries.md` for which method gates on which capability. Re-emit (`pnpm prisma contract emit`) after enabling. |