@prisma/orm-mongo 8.0.0-rc.9-dev.13 → 8.0.1-dev.2
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.
- package/README.md +48 -8
- package/dist/components-CWskH7lF-Dkc9ysZz.mjs +18 -0
- package/dist/components-CWskH7lF-Dkc9ysZz.mjs.map +1 -0
- package/dist/config.d.mts +14 -5
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +47 -25
- package/dist/config.mjs.map +1 -1
- package/dist/contract-builder.d.mts +33 -91
- package/dist/contract-builder.d.mts.map +1 -1
- package/dist/contract-builder.mjs +23 -7
- package/dist/contract-builder.mjs.map +1 -1
- package/dist/contract-types.d.mts +3 -0
- package/dist/contract-types.mjs +1 -0
- package/dist/contract__format-version.d.mts +1 -0
- package/dist/contract__format-version.mjs +2 -0
- package/dist/contract__internal__format-version.d.mts +1 -0
- package/dist/contract__internal__format-version.mjs +2 -0
- package/dist/contract__validate-once.d.mts +1 -0
- package/dist/contract__validate-once.mjs +2 -0
- package/dist/contract__validate-storage.d.mts +1 -0
- package/dist/contract__validate-storage.mjs +2 -0
- package/dist/control.d.mts +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +3 -9
- package/dist/control.mjs.map +1 -1
- package/dist/driver__runtime.d.mts +3 -0
- package/dist/driver__runtime.mjs +3 -0
- package/dist/family-contract__data-type.d.mts +1 -0
- package/dist/family-contract__data-type.mjs +2 -0
- package/dist/init-quick-reference.md +116 -0
- package/dist/init-readme.md +35 -0
- package/dist/init.d.mts +7 -0
- package/dist/init.d.mts.map +1 -0
- package/dist/init.mjs +245 -0
- package/dist/init.mjs.map +1 -0
- package/dist/migration.d.mts +1 -0
- package/dist/migration.mjs +2 -0
- package/dist/module-base-B70DHaBE-k_c3Klu4.mjs +6 -0
- package/dist/module-base-B70DHaBE-k_c3Klu4.mjs.map +1 -0
- package/dist/mongo-static-BrplLPTr-DGOk19X8.mjs +74 -0
- package/dist/mongo-static-BrplLPTr-DGOk19X8.mjs.map +1 -0
- package/dist/{mongo-static-BdSGXYgQ-DSA-2DiK.d.mts → mongo-static-DabeBtmV-DILuhcbE.d.mts} +18 -5
- package/dist/mongo-static-DabeBtmV-DILuhcbE.d.mts.map +1 -0
- package/dist/runtime.d.mts +49 -44
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +104 -42
- package/dist/runtime.mjs.map +1 -1
- package/dist/static.d.mts +24 -2
- package/dist/static.d.mts.map +1 -0
- package/dist/static.mjs +2 -2
- package/dist/target__codec-ids.d.mts +1 -0
- package/dist/target__codec-ids.mjs +2 -0
- package/dist/target__codecs.d.mts +1 -0
- package/dist/target__codecs.mjs +2 -0
- package/dist/target__data-types.d.mts +1 -0
- package/dist/target__data-types.mjs +2 -0
- package/dist/target__server-version.d.mts +1 -0
- package/dist/target__server-version.mjs +2 -0
- package/dist/utils__guards.d.mts +1 -0
- package/dist/utils__guards.mjs +2 -0
- package/dist/utils__text.d.mts +1 -0
- package/dist/utils__text.mjs +2 -0
- package/dist/utils__upgrade-guides.d.mts +1 -0
- package/dist/utils__upgrade-guides.mjs +2 -0
- package/package.json +37 -13
- package/skills/prisma-8/SKILL.md +23 -18
- package/skills/prisma-8/references/build-a-target-package.md +117 -0
- package/skills/prisma-8/references/build.md +12 -16
- package/skills/prisma-8/references/contract.md +181 -75
- package/skills/prisma-8/references/debug.md +35 -24
- package/skills/prisma-8/references/feedback.md +8 -8
- package/skills/prisma-8/references/migration-model.md +23 -14
- package/skills/prisma-8/references/migration-review.md +23 -52
- package/skills/prisma-8/references/migrations.md +294 -80
- package/skills/prisma-8/references/queries-mongo.md +53 -17
- package/skills/prisma-8/references/queries-postgres.md +345 -34
- package/skills/prisma-8/references/queries.md +44 -25
- package/skills/prisma-8/references/quickstart.md +25 -22
- package/skills/prisma-8/references/runtime.md +172 -72
- package/skills/prisma-8/references/supabase.md +22 -19
- package/skills/prisma-8/references/upgrade-app.md +57 -22
- package/skills/prisma-8/references/upgrade-extension.md +72 -23
- package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/instructions.md +1 -1
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.10-to-8.0.0-rc.11/instructions.md +34 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +639 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/multifile-psl/add-use-prisma-8-directive.mjs +60 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/psl-verbatim-table-names/add-model-map.mjs +256 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/instructions.md +332 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/scripts/execution-ref-entry-field/rename-execution-ref-keys.ts +193 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.13-to-8.0.0-rc.14/instructions.md +489 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/instructions.md +1368 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/scripts/data-type-in-contract/data-type-in-contract.ts +1492 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md +108 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.16-to-8.0.0-rc.17/instructions.md +755 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/instructions.md +973 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/scripts/sql-expression-literals-psl/rewrite-sql-strings.mjs +271 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +1862 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/client-takes-contract-value/contract-from-json.ts +597 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/data-type-values/data-type-values.ts +1120 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/default-generators-to-on-create/rewrite-default-generators.mjs +86 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/mongo-field-storage-names/mongo-field-storage-names.ts +304 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/remove-nocheck/remove-nocheck.ts +2462 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +513 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/scripts/expand-type-aliases/expand-type-aliases.ts +1206 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.20-to-8.0.0-rc.21/instructions.md +803 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.21-to-8.0.0-rc.22/instructions.md +586 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.21-to-8.0.0-rc.22/scripts/value-objects-in-storage/value-objects-in-storage.ts +1184 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.22-to-8.0.0-rc.23/instructions.md +480 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.22-to-8.0.0-rc.23/scripts/mongo-index-names/mongo-index-names.ts +317 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/instructions.md +336 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/scripts/mongo-convenience-date-time-types/rewrite-mongo-date-types.ts +220 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/scripts/mongo-type-helpers/rewrite-mongo-field-types.ts +621 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.24-to-8.0.0-rc.25/instructions.md +1561 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.9-to-8.0.0-rc.10/instructions.md +13 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/instructions.md +1 -1
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.10-to-8.0.0-rc.11/instructions.md +34 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +857 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/psl-verbatim-table-names/add-model-map.mjs +256 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/instructions.md +504 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/scripts/execution-ref-entry-field/rename-execution-ref-keys.ts +193 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.13-to-8.0.0-rc.14/instructions.md +143 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/instructions.md +2168 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/scripts/data-type-in-contract/data-type-in-contract.ts +1492 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md +223 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.16-to-8.0.0-rc.17/instructions.md +583 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/instructions.md +1008 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +2186 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/client-takes-contract-value/contract-from-json.ts +597 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/data-type-values/data-type-values.ts +1120 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/default-generators-to-on-create/rewrite-default-generators.mjs +86 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/mongo-field-storage-names/mongo-field-storage-names.ts +304 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/remove-nocheck/remove-nocheck.ts +2462 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +381 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/scripts/expand-type-aliases/expand-type-aliases.ts +1206 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.20-to-8.0.0-rc.21/instructions.md +570 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.21-to-8.0.0-rc.22/instructions.md +464 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.22-to-8.0.0-rc.23/instructions.md +410 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/instructions.md +303 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/scripts/mongo-convenience-date-time-types/rewrite-mongo-date-types.ts +220 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/scripts/mongo-type-helpers/rewrite-mongo-field-types.ts +621 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.24-to-8.0.0-rc.25/instructions.md +1593 -0
- package/dist/adapter__codec-ids.d.mts +0 -1
- package/dist/adapter__codec-ids.mjs +0 -2
- package/dist/adapter__codec-types.d.mts +0 -1
- package/dist/adapter__codec-types.mjs +0 -2
- package/dist/adapter__codecs.d.mts +0 -1
- package/dist/adapter__codecs.mjs +0 -2
- package/dist/mongo-static-BdSGXYgQ-DSA-2DiK.d.mts.map +0 -1
- package/dist/mongo-static-_wy-fC4P-mXlhePy0.mjs +0 -38
- package/dist/mongo-static-_wy-fC4P-mXlhePy0.mjs.map +0 -1
|
@@ -23,9 +23,9 @@ This skill covers using Prisma 8 against a **Supabase** project end-to-end: comp
|
|
|
23
23
|
|
|
24
24
|
## Key Concepts
|
|
25
25
|
|
|
26
|
-
- **The pack is an `external` contract space.** `@
|
|
26
|
+
- **The pack is an `external` contract space.** `@prisma/orm-extension-supabase/pack` ships a complete, introspection-generated contract of everything Supabase owns — the `auth` and `storage` schemas, their native enum types, and the platform roles (`anon`, `authenticated`, `service_role`) — all with control policy `external`. Composed via `extensions`, it means: the migration planner **emits no DDL** for those objects (Supabase manages them), and `db verify` **confirms they exist** in the live database. Your own tables stay `managed` as usual.
|
|
27
27
|
- **Roles come from the pack; you never declare them.** RLS `roles = [authenticated]` identifiers resolve against the composed contract. Pointing the runtime at a non-Supabase Postgres fails verify with a `not-found` issue naming the missing role — the common "wrong database" misconfiguration surfaces before queries run.
|
|
28
|
-
- **The runtime is role-first.** `supabase()` returns a `SupabaseDb` with **no top-level query surface** — there is no `db.sql` / `db.orm` until you bind a role. `await db.asUser(jwt)` / `db.asAnon()` / `db.asServiceRole()` each return a `RoleBoundDb` exposing `.sql`, `.orm`, `.raw`, `.query(plan)` (rows), `.execute(plan)` (affected count), and `.transaction(fn)`. This is deliberate: in a Supabase app there is no meaningful "no role" execution context, and defaulting to the connection's login role is a silent-RLS-bypass footgun.
|
|
28
|
+
- **The runtime is role-first.** `supabase()` returns a `SupabaseDb` with **no top-level query surface** — there is no `db.sql` / `db.orm` until you bind a role. `await db.asUser(jwt)` / `db.asAnon()` / `db.asServiceRole()` each return a `RoleBoundDb` exposing `.sql`, `.orm`, `.raw`, `.prepare(...)`, `.query(plan)` (rows), `.execute(plan)` (affected count), `.enums`, `.nativeEnums`, and `.transaction(fn)`. This is deliberate: in a Supabase app there is no meaningful "no role" execution context, and defaulting to the connection's login role is a silent-RLS-bypass footgun.
|
|
29
29
|
- **Role binding is below middleware and cannot leak.** Each role-bound query runs on a connection that had `set_config('role', …)` and `set_config('request.jwt.claims', …)` applied beneath the user-middleware chain, with `RESET ALL` on release. Postgres-side `auth.uid()` / `auth.jwt()` read those session vars — RLS enforcement is Postgres's job; the runtime's job is binding the context.
|
|
30
30
|
- **RLS is enforced by policies *and* grants.** Policies filter *rows*; `GRANT` controls *table access*. Prisma 8 authors and migrates the policies; it does not author grants (see *What Prisma 8 doesn't do yet*). A role with policies but no `GRANT` gets a permission error, not filtered rows. On Supabase your `public` tables already carry the platform-role grants via default privileges — the grant that is actually missing out of the box is `service_role`'s on `auth.*` / `storage.*` (see *Workflow — Grants*).
|
|
31
31
|
- **JWT validation is eager and configurable — current Supabase projects need `jwksUrl`.** `asUser(jwt)` verifies the token (via `jose`) *before* any connection is acquired: signature + expiry against `jwksUrl` (asymmetric signing keys — **the default on current Supabase projects**, which sign ES256) **xor** `jwtSecret` (the symmetric HS256 secret — legacy projects only). Both or neither → a structured error with code `SUPABASE.CONFIG_INVALID`. Bad tokens throw a structured error with code `SUPABASE.JWT_INVALID` and a typed `meta.reason` — including a mismatch between the token's algorithm and the configured key source (an ES256 token against a `jwtSecret` client names the problem and tells you to switch to `jwksUrl`). The Postgres role is derived from the token's `role` claim (defaults to `authenticated`). Note: `supabase status` still prints a `JWT_SECRET` even on projects that sign ES256 — its presence does not mean your project uses it.
|
|
@@ -38,12 +38,12 @@ The concept: the pack registers the Supabase contract space so your contract can
|
|
|
38
38
|
```typescript
|
|
39
39
|
// prisma.config.ts
|
|
40
40
|
import { definePrismaConfig } from '@prisma/cli-engine';
|
|
41
|
-
import supabasePack from '@
|
|
42
|
-
import { defineConfig as ormConfig } from '@
|
|
41
|
+
import supabasePack from '@prisma/orm-extension-supabase/pack';
|
|
42
|
+
import { defineConfig as ormConfig, postgres18, postgresDriver } from '@prisma/orm-postgres/config';
|
|
43
43
|
|
|
44
44
|
export default definePrismaConfig({
|
|
45
45
|
orm: ormConfig({
|
|
46
|
-
contract: './src/contract.prisma',
|
|
46
|
+
contract: { path: './src/contract.prisma', requiredCapabilities: [...postgres18, ...postgresDriver] },
|
|
47
47
|
extensions: [supabasePack],
|
|
48
48
|
migrations: { dir: 'migrations' },
|
|
49
49
|
}),
|
|
@@ -57,7 +57,7 @@ The concept: your models live in your namespaces (`public`); Supabase's live in
|
|
|
57
57
|
```prisma
|
|
58
58
|
namespace public {
|
|
59
59
|
model Profile {
|
|
60
|
-
id Uuid @id @
|
|
60
|
+
id Uuid @id @onCreate(uuid())
|
|
61
61
|
username String
|
|
62
62
|
userId Uuid @unique
|
|
63
63
|
user supabase:auth.AuthUser @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
@@ -69,14 +69,14 @@ namespace public {
|
|
|
69
69
|
policy_select profile_owner_read {
|
|
70
70
|
target = Profile
|
|
71
71
|
roles = [authenticated]
|
|
72
|
-
using = "
|
|
72
|
+
using = sql`"userId"::uuid = auth.uid()`
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// anon may read every profile (a public directory listing).
|
|
76
76
|
policy_select profile_public_read {
|
|
77
77
|
target = Profile
|
|
78
78
|
roles = [anon]
|
|
79
|
-
using =
|
|
79
|
+
using = sql`true`
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// authenticated may update only their own profile, and may not
|
|
@@ -84,8 +84,8 @@ namespace public {
|
|
|
84
84
|
policy_update profile_owner_write {
|
|
85
85
|
target = Profile
|
|
86
86
|
roles = [authenticated]
|
|
87
|
-
using = "
|
|
88
|
-
withCheck = "
|
|
87
|
+
using = sql`"userId"::uuid = auth.uid()`
|
|
88
|
+
withCheck = sql`"userId"::uuid = auth.uid()`
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
```
|
|
@@ -94,10 +94,10 @@ The `Uuid` constructor selects native UUID storage in type position. The legacy
|
|
|
94
94
|
|
|
95
95
|
The pieces:
|
|
96
96
|
|
|
97
|
-
- **Per-operation policy blocks**: `policy_select`, `policy_insert`, `policy_update`, `policy_delete`, `policy_all`. Body is `key = value`: `target` (a model in this namespace), `roles` (resolve against the composed contract — the pack supplies `anon` / `authenticated` / `service_role`), `using`, and (for write operations) `withCheck`. Multiple permissive policies per `(target, operation)` are valid — Postgres ORs them. A block may also carry `@@map("physical name")` to adopt an existing live policy under its exact name (no wire-name hash; drift detection then byte-compares the body against Postgres's reprint, so keep the text as captured — hand-authoring it warns).
|
|
97
|
+
- **Per-operation policy blocks**: `policy_select`, `policy_insert`, `policy_update`, `policy_delete`, `policy_all`. Body is `key = value`: `target` (a model in this namespace), `roles` (resolve against the composed contract — the pack supplies `anon` / `authenticated` / `service_role`), `using`, and (for write operations) `withCheck`. `using` and `withCheck` are `sql` literals, as in `` using = sql`"userId"::uuid = auth.uid()` ``; a quoted string is refused, and the error message gives the rewrite. Multiple permissive policies per `(target, operation)` are valid — Postgres ORs them. A block may also carry `@@map("physical name")` to adopt an existing live policy under its exact name (no wire-name hash; drift detection then byte-compares the body against Postgres's reprint, so keep the text as captured — hand-authoring it warns).
|
|
98
98
|
- **`@@rls` is required on policy targets.** A `policy_*` block whose target model lacks `@@rls` fails emit with `PSL_EXTENSION_TARGET_MODEL_MISSING_ATTRIBUTE`. A model with `@@rls` and *no* policies is also meaningful: RLS enabled, deny-all.
|
|
99
|
-
- **Predicates are verbatim SQL
|
|
100
|
-
- **TS-builder parity exists.** `@
|
|
99
|
+
- **Predicates are `sql` literals holding verbatim SQL.** Quote camelCase column names inside them with ordinary double quotes (`"userId"`; inside a backtick `sql` literal the only escapes are `` \` `` and `\\`), and cast where needed — `auth.uid()` returns `uuid`. Renames in your contract do not rewrite predicate bodies.
|
|
100
|
+
- **TS-builder parity exists.** `@prisma/orm-postgres/contract-builder` exports `policySelect` / `policyInsert` / `policyUpdate` / `policyDelete` / `policyAll`, `rlsEnabled(Model)`, and `role('anon')` — mirroring the PSL lowering key-for-key (identical emitted wire names). PSL is the canonical path shown here.
|
|
101
101
|
|
|
102
102
|
Emit + migrate as usual (`prisma contract emit`, then `references/migrations.md`). The plan creates your table, its FK, `ENABLE ROW LEVEL SECURITY`, and the `CREATE POLICY` statements — and **no DDL for `auth.*`**.
|
|
103
103
|
|
|
@@ -107,19 +107,22 @@ The concept: instead of the stock `postgres()` factory, a Supabase app builds it
|
|
|
107
107
|
|
|
108
108
|
```typescript
|
|
109
109
|
// src/prisma/db.ts
|
|
110
|
-
import { supabase } from '@
|
|
110
|
+
import { supabase } from '@prisma/orm-extension-supabase/runtime';
|
|
111
|
+
import { contractFromJson } from '@prisma/orm-postgres/static';
|
|
111
112
|
import type { Contract } from './contract.d';
|
|
112
113
|
import contractJson from './contract.json' with { type: 'json' };
|
|
113
114
|
|
|
114
|
-
export const
|
|
115
|
-
|
|
115
|
+
export const contract = contractFromJson<Contract>(contractJson);
|
|
116
|
+
|
|
117
|
+
export const db = await supabase({
|
|
118
|
+
contract,
|
|
116
119
|
url: process.env['DATABASE_URL'], // direct Postgres connection — see pitfalls
|
|
117
120
|
jwksUrl: process.env['SUPABASE_JWKS_URL'], // https://<project-ref>.supabase.co/auth/v1/.well-known/jwks.json
|
|
118
121
|
// Legacy HS256 projects use jwtSecret: process.env['SUPABASE_JWT_SECRET'] instead — exactly one of the two.
|
|
119
122
|
});
|
|
120
123
|
```
|
|
121
124
|
|
|
122
|
-
Options beyond the basics: `middleware` (same composition as `postgres()` — see `references/runtime.md`; middleware never sees the role-binding `set_config` calls), `poolOptions`, `pg` (BYO `pg.Pool`
|
|
125
|
+
Options beyond the basics: `middleware` (same composition as `postgres()` — see `references/runtime.md`; middleware never sees the role-binding `set_config` calls), `poolOptions`, `pg` (BYO `pg.Pool` instead of `url`; a `pg.Client` is rejected with `SUPABASE.CONFIG_INVALID`). Teardown is `await db.close()` / `await using` exactly as in `references/runtime.md` — the same script-hang rules apply.
|
|
123
126
|
|
|
124
127
|
## Workflow — Role-bound queries
|
|
125
128
|
|
|
@@ -143,7 +146,7 @@ const updated = await userDb.orm.public.Profile
|
|
|
143
146
|
.updateAndCount({ username: 'new-name' });
|
|
144
147
|
```
|
|
145
148
|
|
|
146
|
-
Notes: `asAnon()` / `asServiceRole()` are sync; only `asUser` is async. Multi-namespace contracts address models by coordinate (`orm.public.Profile`, `sql.public.profile`) — see `references/queries.md` § *Namespace-aware accessors*. `RoleBoundDb.transaction(fn)` wraps work in a transaction on the role-bound session.
|
|
149
|
+
Notes: `asAnon()` / `asServiceRole()` are sync; only `asUser` is async. Multi-namespace contracts address models by coordinate (`orm.public.Profile`, `sql.public.profile`) — see `references/queries.md` § *Namespace-aware accessors*. `RoleBoundDb.transaction(fn)` wraps work in a transaction on the role-bound session; its `tx` offers `sql`, `orm` (with the client's custom collection classes), `raw`, `prepare`, `query`, `execute`, `enums` and `nativeEnums`, and runs every statement under the bound role. A prepared statement runs on what it is given: `ps.query(userDb, params)` runs under that client's role, and `ps.query(tx, params)` runs inside the transaction.
|
|
147
150
|
|
|
148
151
|
## Workflow — Admin reads of `auth.*` / `storage.*`
|
|
149
152
|
|
|
@@ -223,7 +226,7 @@ The concept: the runtime needs a **direct, session-capable** Postgres connection
|
|
|
223
226
|
- [ ] `extensions: [supabasePack]` (the `pack` export) in `ormConfig({...})` inside `definePrismaConfig({ orm: ... })`.
|
|
224
227
|
- [ ] Cross-space FK typed `supabase:auth.AuthUser` with explicit `fields` / `references` (+ `onDelete` if wanted).
|
|
225
228
|
- [ ] Every policy target model carries `@@rls`; predicates quote camelCase columns and cast for `auth.uid()`.
|
|
226
|
-
- [ ] `db.ts` uses `await supabase
|
|
229
|
+
- [ ] `db.ts` uses `await supabase({ contract, url, jwksUrl | jwtSecret })`, with `contract` from `contractFromJson<Contract>(contractJson)` of `@prisma/orm-postgres/static` — exactly one JWT key source; `jwksUrl` for current projects, `jwtSecret` only for legacy HS256.
|
|
227
230
|
- [ ] Queries go through a `RoleBoundDb` from `asUser` / `asAnon` / `asServiceRole`; `asUser` is awaited.
|
|
228
231
|
- [ ] `auth.*` / `storage.*` reads go through `asServiceRole().supabase` only, after the one-time narrow grant (`GRANT USAGE ON SCHEMA auth` + `GRANT SELECT` on the tables you read).
|
|
229
232
|
- [ ] No per-table grants added for your own `public` tables — Supabase default privileges cover them; RLS does the protecting.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Upgrade Prisma 8 (user app)
|
|
2
2
|
|
|
3
|
-
This reference upgrades a project that **consumes** Prisma 8 via the public package API (`@
|
|
3
|
+
This reference upgrades a project that **consumes** Prisma 8 via the public package API (a database package, `@prisma/orm-postgres`, `@prisma/orm-mongo`, `@prisma/orm-sqlite`, `@prisma/orm-mysql` or `@prisma/orm-mariadb`, the contract files in `prisma/`, etc.). Package names below are the published `@prisma/orm-*` names, which is what `package.json`, the lockfile, and the registry use. The other references in this skill use the same names. If the project is itself a Prisma 8 *extension*, use [`upgrade-extension.md`](upgrade-extension.md) instead — or both, if the repo contains both an app and an extension package.
|
|
4
4
|
|
|
5
5
|
The per-transition instructions this reference reads live under [`../upgrading/app/upgrades/`](../upgrading/app/upgrades/).
|
|
6
6
|
|
|
@@ -12,18 +12,30 @@ Do the version bump first (step 1 of the per-step flow below), re-sync the skill
|
|
|
12
12
|
|
|
13
13
|
## Pre-flight — extension compatibility
|
|
14
14
|
|
|
15
|
-
Before changing any code,
|
|
15
|
+
Before changing any code, work out how far the chain can go. The application can take a step only when every extension published by someone else has a release that accepts the Prisma versions of that step.
|
|
16
|
+
|
|
17
|
+
- **Until release 8.0,** an extension lists every `@prisma/orm-*` package it uses as a peer dependency at one exact version, with no caret and no range. That version is the one release the extension was validated against. An application on any other release makes the extension's peer dependencies disagree with the application's own lines, until the extension publishes a release for it.
|
|
18
|
+
- **From release 8.0,** an extension normally lists a caret on the first release it works with, such as `^8.1.0`, which accepts every later release in the major. Such an extension does not limit how far the application can go. It limits it only when it lists a range within one minor, such as `~8.1.0`, or an exact version.
|
|
19
|
+
|
|
20
|
+
When the lines disagree, npm refuses the install if the packages that disagree are ones the application lists itself. pnpm, Yarn and Bun install anyway and print a peer dependency warning, so a successful install does not prove that the versions match.
|
|
21
|
+
|
|
22
|
+
This pre-flight covers only extensions published by someone else. Every `@prisma/orm-*` package is published from the Prisma repository at every release: `@prisma/orm-extension-pgvector`, `@prisma/orm-postgres-contrib` and `@prisma/orm-better-auth`, for example. It moves to `<to>` together with the database package in the bump step below, so it does not limit how far the application can go.
|
|
16
23
|
|
|
17
24
|
Steps:
|
|
18
25
|
|
|
19
|
-
1. **Read `prisma.config.ts`** (or its TS-discoverable equivalent at the project root) and enumerate the list of extension packages it imports. Each `extensions: [...]` entry corresponds to an installed npm package.
|
|
20
|
-
2. **For each extension**, read its installed `package.json` from `node_modules/<extension-package-name>/package.json` and find
|
|
21
|
-
3. **
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
- (b) Re-run with `--to=<highest-reachable>` (or whatever flag/option the user is using to set the target).
|
|
26
|
+
1. **Read `prisma.config.ts`** (or its TS-discoverable equivalent at the project root) and enumerate the list of extension packages it imports. Each `extensions: [...]` entry corresponds to an installed npm package. Leave out every `@prisma/orm-*` package.
|
|
27
|
+
2. **For each extension**, read its installed `package.json` from `node_modules/<extension-package-name>/package.json` and find every `@prisma/orm-*` entry under `dependencies`, `peerDependencies`, or `optionalDependencies` (`@prisma/orm-framework`, `@prisma/orm-family-sql` or `@prisma/orm-family-mongo`, `@prisma/orm-toolchain`, and a `@prisma/orm-target-*` package). Until release 8.0, by construction those entries are exact-version pins (e.g. `"8.0.0-rc.11"`), set when the extension author last ran their own upgrade.
|
|
28
|
+
3. **Find each extension's releases.** List its published versions with `pnpm view <extension> versions --json`. For each version, read the `@prisma/orm-*` entries it lists under `dependencies`, `peerDependencies` and `optionalDependencies`, as in step 2: `pnpm view <extension>@<version> dependencies peerDependencies optionalDependencies --json`. Then, for each step in the chain below, work out the version each of those Prisma packages has at that step, as the bump step of the per-step flow defines it:
|
|
29
|
+
- on the `8.0.0` release candidates, it is `<to>` itself;
|
|
30
|
+
- from release 8.0, it is that package's first version in the `<to>` release, such as `8.0.1` for a GA package and `8.0.1-ea.0` for one below GA.
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
Note the release of each extension whose every entry accepts its package's version at that step.
|
|
33
|
+
4. **Find the last step every extension allows.** Walk the chain from the first step. The chain can go as far as the last step before the first one for which some extension has no release. If that is short of the user's target, tell the user before installing anything: which extension has no release for which Prisma version, how far the upgrade can go, and their options:
|
|
34
|
+
- (a) Wait for, or ask for, a release of the extension for that version, then re-run.
|
|
35
|
+
- (b) Upgrade only as far as the last step every extension allows.
|
|
36
|
+
- (c) Remove the extension, and upgrade without it.
|
|
37
|
+
|
|
38
|
+
Do not skip a step, do not leave an extension at a release that names another Prisma version, and do not install past the last step every extension allows.
|
|
27
39
|
|
|
28
40
|
If `prisma.config.ts` is absent or names no extensions, skip the pre-flight.
|
|
29
41
|
|
|
@@ -31,15 +43,18 @@ If `prisma.config.ts` is absent or names no extensions, skip the pre-flight.
|
|
|
31
43
|
|
|
32
44
|
This flow applies when the project **consumes** Prisma 8:
|
|
33
45
|
|
|
34
|
-
- `package.json` declares
|
|
35
|
-
-
|
|
46
|
+
- `package.json` declares a database package, `@prisma/orm-postgres`, `@prisma/orm-mongo`, `@prisma/orm-sqlite`, `@prisma/orm-mysql` or `@prisma/orm-mariadb`, under `dependencies` / `devDependencies`, and
|
|
47
|
+
- it names no `@prisma/orm-framework` or other platform package under `peerDependencies`: an application lists them under `dependencies` beside its database package. A package that names one as a peer, such as an extension, a library integration or a database package built outside this repository, takes [`upgrade-extension.md`](upgrade-extension.md#role-detection) instead, even when it also lists a database package.
|
|
36
48
|
|
|
37
|
-
If the
|
|
49
|
+
If the repository also holds an extension, in a `package.json` of its own, run **this** flow for the application first and then [`upgrade-extension.md`](upgrade-extension.md) for the extension, in the same session. If detection is ambiguous, ask the user.
|
|
38
50
|
|
|
39
51
|
## Version detection
|
|
40
52
|
|
|
41
|
-
- **From-version.** Read the
|
|
42
|
-
- **
|
|
53
|
+
- **From-version.** Read the installed Prisma 8 version from `pnpm-lock.yaml` (or `package-lock.json` / `yarn.lock`): take the resolved version of the application's database package, which is `@prisma/orm-postgres`, `@prisma/orm-mongo`, `@prisma/orm-sqlite`, `@prisma/orm-mysql` or `@prisma/orm-mariadb`. Do not read it from an extension published by someone else. Such an extension has its own version, and the pre-flight above deals with it.
|
|
54
|
+
- **On the `8.0.0` release candidates,** compare the full version strings, including the part after the hyphen. `8.0.0-rc.10` and `8.0.0-rc.11` are different versions, and different steps in the chain below.
|
|
55
|
+
- **From release 8.0,** each package has its own patch number or level suffix, and a step is named by the release, which is the major and minor: `8.0-to-8.1`. So the from-version is the release that the database package's version belongs to. `8.0.1-ea.0`, `8.0.1` and `8.0.2` all belong to release `8.0`.
|
|
56
|
+
- If the lockfile shows the application's Prisma packages on different releases, which is already a broken state, the **lowest** is the from-version.
|
|
57
|
+
- **To-version.** Either the version the user specified, or whatever `npm view @prisma/orm-postgres dist-tags.latest` reports. Do not assume that is a stable version: while Prisma 8 is a release candidate, `latest` tracks the newest release, `8.0.0-rc.N` included. If the user wants a stable version specifically, they must name it.
|
|
43
58
|
|
|
44
59
|
Report both back to the user before continuing.
|
|
45
60
|
|
|
@@ -51,26 +66,46 @@ If the from-to delta spans more than one release (e.g. `0.6 → 0.8`), build the
|
|
|
51
66
|
0.6 → 0.7 → 0.8
|
|
52
67
|
```
|
|
53
68
|
|
|
54
|
-
The [`../upgrading/app/upgrades/`](../upgrading/app/upgrades/) directories name the steps — read the chain off the directory names rather than deriving it arithmetically. Each directory is `<from>-to-<to>`. A step
|
|
69
|
+
The [`../upgrading/app/upgrades/`](../upgrading/app/upgrades/) directories name the steps — read the chain off the directory names rather than deriving it arithmetically. Each directory is `<from>-to-<to>`. A step normally spans one stable minor (`0.7-to-0.8`) or one release candidate (`8.0.0-rc.1-to-8.0.0-rc.2`). When intermediate versions were not published, a guide may span a larger hop; follow the available directory chain rather than inventing missing steps. Moving onto the RC line from the last stable minor is a single step of its own (`0.17-to-8.0.0-rc.1`).
|
|
55
70
|
|
|
56
71
|
Apply each step in order, fully: bump, install, run instructions, validate, commit — before moving to the next. Halt the chain on the first failed step; do not skip ahead.
|
|
57
72
|
|
|
58
|
-
The chain order does not depend on which extensions are installed; the pre-flight has already
|
|
73
|
+
The chain order does not depend on which extensions are installed; the pre-flight has already worked out how far it can go.
|
|
59
74
|
|
|
60
75
|
## Per-step flow
|
|
61
76
|
|
|
62
77
|
For each `(from, to)` step in the chain:
|
|
63
78
|
|
|
64
|
-
1. **Bump
|
|
79
|
+
1. **Bump the app's Prisma packages.** Change these entries in the project's `package.json`, under both `dependencies` and `devDependencies`:
|
|
80
|
+
- the database package, such as `@prisma/orm-postgres`;
|
|
81
|
+
- the platform packages that the database package lists as peer dependencies;
|
|
82
|
+
- every extension or library integration published from the Prisma repository: `@prisma/orm-extension-*`, `@prisma/orm-postgres-contrib` and `@prisma/orm-better-auth`.
|
|
83
|
+
|
|
84
|
+
Each of these is published at every release and lists the other Prisma packages at that release, so one that is left behind disagrees with the rest.
|
|
85
|
+
|
|
86
|
+
**What to write, on the `8.0.0` release candidates.** Rewrite every entry to the exact `<to>` version, with no caret and no tilde. All entries move to the same version.
|
|
87
|
+
|
|
88
|
+
**What to write, from release 8.0.** The entries no longer share one version. Each moves to its own package's first version in the `<to>` release. From release 8.1 on, that is the plain `X.Y.0` for a GA package and `X.Y.0-<level>.0` for one below GA. At release 8.0 it is `8.0.1` and `8.0.1-ea.0`. `pnpm view <name> versions --json` lists a package's versions. Which range goes in front depends on the database package, as [Versions and support](https://github.com/prisma/orm/blob/main/docs/oss/versioning.md#what-an-application-writes) describes:
|
|
89
|
+
- beside a GA database package, a GA entry gets a caret and an entry below GA gets a tilde;
|
|
90
|
+
- beside a database package below GA, every entry gets a tilde.
|
|
91
|
+
|
|
92
|
+
**Write a caret only when `<to>` is the newest published release,** which `pnpm view <database package> versions --json` shows. A caret accepts later releases, so at any other step the install would take a release later than `<to>`, whose instructions have not been applied. That is every step before the last one, and the last one too when the user's target is older than the newest release. At such a step write a tilde in place of the caret: a tilde stays within `<to>` and still takes its fixes. If the upgrade ends on a release that is not the newest, say in the final report that those entries have a tilde where [Versions and support](https://github.com/prisma/orm/blob/main/docs/oss/versioning.md#what-an-application-writes) gives a caret.
|
|
93
|
+
|
|
94
|
+
**A peer dependency the project does not list.** If the database package at `<to>` lists an `@prisma/orm-*` peer dependency that the project's `package.json` does not have, add it, written as that package's entry for `<to>` would be. The application lists every one of them, so that it has one copy of each. A monorepo whose applications are on different Prisma releases can still get two copies under npm workspaces and under Bun's hoisted linker; keep such applications on one release, or use pnpm, Yarn or Bun's isolated linker.
|
|
95
|
+
|
|
96
|
+
**Extensions published by someone else.** Set each one to the release the pre-flight noted for this step: the one whose every Prisma entry accepts that package's version at the step. If an extension has no such release, halt before this step's install. The project stays at the last step that worked, and the user gets the pre-flight's message for that extension and step.
|
|
97
|
+
|
|
98
|
+
The skill itself ships inside the Prisma packages, so bumping them is what updates it. There is no separate skill package to bump.
|
|
65
99
|
|
|
66
100
|
2. **Install.** Run `pnpm install` (or the project's lockfile-managing command). The project's code is now broken against the new types — the upgrade instructions for `<from> → <to>` exist to fix it.
|
|
67
101
|
|
|
68
102
|
3. **Read the upgrade instructions.** Re-sync the skills (`prisma skills sync`) so the tree matches the version just installed, then load `../upgrading/app/upgrades/<from>-to-<to>/instructions.md`. Parse the YAML frontmatter and pay particular attention to its `changes[]` array.
|
|
69
103
|
|
|
70
|
-
4. **Apply each change.** For each entry in `changes[]`:
|
|
71
|
-
- If the entry has a `detection` block (glob + content predicate), run it; skip the change if no files match. No `detection` → apply unconditionally.
|
|
104
|
+
4. **Apply each change.** When the guide's body has a section that orders the steps, such as `Order of the steps`, apply the changes in that order: it says which script runs before which, and when to sign the databases and when to plan and apply a migration. Where an entry's prose says to sign or migrate, do it at the step that section names. Otherwise take the entries in the order of `changes[]`. For each entry in `changes[]`:
|
|
105
|
+
- If the entry has a `detection` block (glob + content predicate), run it; skip the change if no files match. No `detection` → apply unconditionally. Run the glob over the project's own files: skip `node_modules`, and build output such as `dist`, `build`, `.next` or `out` (whatever directories the project's build writes). A match there is generated code, which the next build rewrites; editing it changes nothing. Migration snapshots under `migrations/snapshots/` are committed files, not build output, so keep them.
|
|
106
|
+
- How a `detection` block runs: `glob` selects files relative to the project root. Each `matches` entry, once read from the YAML, is a JavaScript regular expression, built as `new RegExp(pattern)` with no flags and tested against the whole content of one file at a time; each `contains` entry is a plain substring. A file is a hit when any entry matches it. Patterns may span lines, and some look at the whole file (for example, to skip a file that declares something elsewhere in it), so a line-by-line search such as `grep` or `rg` without `-U` is not the same test and can report files the pattern excludes. From a shell, `rg -U --pcre2 -l -e '<pattern>' <files>` tests whole files and gives the same hits.
|
|
72
107
|
- If the entry names a `script:` (a relative path next to `instructions.md`), invoke it from the project root:
|
|
73
|
-
- `*.ts` → `pnpm exec tsx <skill>/upgrading/app/upgrades/<from>-to-<to>/<script>`
|
|
108
|
+
- `*.ts` → the command the guide's prose gives, such as `node <script>` (Node 24 or later runs TypeScript directly); with no command in the prose, `pnpm exec tsx <skill>/upgrading/app/upgrades/<from>-to-<to>/<script>`
|
|
74
109
|
- `*.sh` → `bash <skill>/upgrading/app/upgrades/<from>-to-<to>/<script>`
|
|
75
110
|
- codemods → invoke per the script's own prose.
|
|
76
111
|
|
|
@@ -83,7 +118,7 @@ For each `(from, to)` step in the chain:
|
|
|
83
118
|
6. **Commit.** One commit per step containing the `package.json` bump, lockfile churn, and any source rewrites:
|
|
84
119
|
|
|
85
120
|
```text
|
|
86
|
-
chore: upgrade @
|
|
121
|
+
chore: upgrade @prisma/orm-* to <to-version>
|
|
87
122
|
```
|
|
88
123
|
|
|
89
124
|
(Or the project's own commit-message convention.) Never squash steps. The user may squash on merge; the in-flight history must be per-step so a failed step is bisectable.
|
|
@@ -98,4 +133,4 @@ Report back to the user: the number of steps applied, the SHAs of the commits yo
|
|
|
98
133
|
|
|
99
134
|
When a step fails: surface a structured error with code `PN-UPGRADE-NNNN`, the failing change's `id`, the file paths touched (or the lockfile, or the validation command), and the inferred remediation. Do not retry automatically; do not auto-roll-back. The user can revert if they want a clean slate.
|
|
100
135
|
|
|
101
|
-
If
|
|
136
|
+
If the pre-flight finds that the first step is already blocked, do not bump anything; the project is left unchanged. A halt at a later step leaves the project at the last step that worked.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Upgrade Prisma 8 (extension)
|
|
2
2
|
|
|
3
|
-
This reference upgrades a project that **is** a Prisma 8 extension — a package that consumes the framework SPI (`@
|
|
3
|
+
This reference upgrades a project that **is** a Prisma 8 extension — a package that consumes the framework SPI (`@prisma/orm-framework`, `@prisma/orm-family-sql` or `@prisma/orm-family-mongo`, `@prisma/orm-toolchain`, `@prisma/orm-target-*`, each a peer dependency) and exposes contract / middleware / codec / migration surfaces that downstream apps install via `prisma.config.ts`.
|
|
4
4
|
|
|
5
|
-
If the project you are upgrading is a consumer **app** (it
|
|
5
|
+
If the project you are upgrading is a consumer **app** (it depends on a database package, `@prisma/orm-postgres`, `@prisma/orm-mongo`, `@prisma/orm-sqlite`, `@prisma/orm-mysql` or `@prisma/orm-mariadb`, from its application code), use [`upgrade-app.md`](upgrade-app.md) instead — or both, if the repo contains both a consumer app and an extension package, in which case run the app flow first then this one in the same session.
|
|
6
6
|
|
|
7
7
|
The per-transition instructions this reference reads live under [`../upgrading/extension/upgrades/`](../upgrading/extension/upgrades/).
|
|
8
8
|
|
|
@@ -14,20 +14,24 @@ Do the version bump first (step 1 of the per-step flow below), re-sync the skill
|
|
|
14
14
|
|
|
15
15
|
## Role detection
|
|
16
16
|
|
|
17
|
-
This flow applies when the project **is** a Prisma 8 extension.
|
|
17
|
+
This flow applies when the project **is** a Prisma 8 extension, a library integration such as `@prisma/orm-better-auth`, or a database package built outside this repository ([`build-a-target-package.md`](build-a-target-package.md)). It is one when either holds:
|
|
18
18
|
|
|
19
|
-
- `package.json` declares `@
|
|
20
|
-
-
|
|
21
|
-
- the package is referenced as an `extensions` entry from a sibling app's `prisma.config.ts` in the same monorepo.
|
|
19
|
+
- `package.json` declares `@prisma/orm-framework` or another `@prisma/orm-*` platform package under `peerDependencies`, whatever else it declares (`@prisma/orm-extension-supabase` also names `@prisma/orm-postgres` as a peer, and is an extension); or
|
|
20
|
+
- it declares a platform package under `dependencies` with no database package (`@prisma/orm-postgres`, `@prisma/orm-mongo`, …) beside it, as an extension written for an earlier release does, and its `name` matches `^@.*/extension-` (the convention used by `@prisma/orm-extension-pgvector`, etc.), its `keywords` include `prisma-orm-extension`, or a sibling app's `prisma.config.ts` in the same monorepo lists it as an `extensions` entry.
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
An application never names a platform package as a peer, so a package that does is never an application.
|
|
23
|
+
|
|
24
|
+
If the repository also holds an application, in a `package.json` of its own, run [`upgrade-app.md`](upgrade-app.md) for it first, then this flow for the extension, in the same session.
|
|
24
25
|
|
|
25
26
|
If detection is ambiguous, ask the user which role to operate under.
|
|
26
27
|
|
|
27
28
|
## Version detection
|
|
28
29
|
|
|
29
|
-
- **From-version.** Read the
|
|
30
|
-
- **
|
|
30
|
+
- **From-version.** Read the installed Prisma 8 version from `pnpm-lock.yaml` (or `package-lock.json` / `yarn.lock`): take the resolved version of any `@prisma/orm-*` platform package (`@prisma/orm-framework`, `@prisma/orm-family-*`, `@prisma/orm-target-*`, `@prisma/orm-toolchain`). Do not read it from an extension published by someone else, which has its own version.
|
|
31
|
+
- **On the `8.0.0` release candidates,** compare the full version strings, including the part after the hyphen. `8.0.0-rc.10` and `8.0.0-rc.11` are different versions, and different steps in the chain below.
|
|
32
|
+
- **From release 8.0,** a step is named by the release, which is the major and minor: `8.0-to-8.1`. So the from-version is the release that a package's version belongs to. `8.0.1-ea.0`, `8.0.1` and `8.0.2` all belong to release `8.0`. (A platform package below GA has a level suffix, such as `8.0.1-ea.0` for `@prisma/orm-family-mongo`.)
|
|
33
|
+
- If the lockfile shows the platform packages on different releases, the lowest is the from-version.
|
|
34
|
+
- **To-version.** Either the version the user specified, or whatever `npm view @prisma/orm-framework dist-tags.latest` reports. Do not assume that is a stable version: while Prisma 8 is a release candidate, `latest` tracks the newest release, `8.0.0-rc.N` included. If the user wants a stable version specifically, they must name it.
|
|
31
35
|
|
|
32
36
|
Report both back to the user before continuing.
|
|
33
37
|
|
|
@@ -39,29 +43,52 @@ If the from-to delta spans more than one release (e.g. `0.6 → 0.8`), build the
|
|
|
39
43
|
0.6 → 0.7 → 0.8
|
|
40
44
|
```
|
|
41
45
|
|
|
42
|
-
The [`../upgrading/extension/upgrades/`](../upgrading/extension/upgrades/) directories name the steps — read the chain off the directory names rather than deriving it arithmetically. Each directory is `<from>-to-<to>`. A step
|
|
46
|
+
The [`../upgrading/extension/upgrades/`](../upgrading/extension/upgrades/) directories name the steps — read the chain off the directory names rather than deriving it arithmetically. Each directory is `<from>-to-<to>`. A step normally spans one stable minor (`0.7-to-0.8`) or one release candidate (`8.0.0-rc.1-to-8.0.0-rc.2`). When intermediate versions were not published, a guide may span a larger hop; follow the available directory chain rather than inventing missing steps. Moving onto the RC line from the last stable minor is a single step of its own (`0.17-to-8.0.0-rc.1`).
|
|
43
47
|
|
|
44
48
|
Apply each step in order, fully: bump, install, run instructions, check pins, validate, commit — before moving to the next. Halt the chain on the first failed step.
|
|
45
49
|
|
|
46
50
|
## Per-step flow
|
|
47
51
|
|
|
48
|
-
This flow assumes you are an **external extension author
|
|
52
|
+
This flow assumes you are an **external extension author**: your extension lives in its own repository and gets `@prisma/orm-*` from npm. Extensions inside the Prisma ORM repository do not run this skill. Their versions and ranges are written by `pnpm bump-version` and `scripts/set-version.ts`, from the repository's release plan.
|
|
49
53
|
|
|
50
54
|
For each `(from, to)` step in the chain:
|
|
51
55
|
|
|
52
|
-
1. **Bump `@
|
|
56
|
+
1. **Bump `@prisma/orm-*` deps.** What to write depends on the release:
|
|
57
|
+
- **On the `8.0.0` release candidates,** rewrite every `@prisma/orm-*` entry in the extension's `package.json` to the exact `<to>` version, such as `"8.0.0-rc.11"`: no caret, no tilde, no range, and no `workspace:` specifier. The exact-pin rule below says why. All entries move to the same version. That includes another extension published from the Prisma repository, such as `@prisma/orm-extension-pgvector`: every `@prisma/orm-*` package is published at every release, and each lists the others at that release's version.
|
|
58
|
+
- **From release 8.0,** the two sections of `package.json` differ.
|
|
59
|
+
- Under `peerDependencies`, write the ranges that [the last section](#from-release-80-number-your-package-and-declare-ranges) gives. They say which releases your package accepts, and a caret there need not change at every step.
|
|
60
|
+
- Under `devDependencies`, write each package's first version in the `<to>` release, so that your build and tests run against `<to>`: `8.2.0` for a GA package at the step to release 8.2, whatever the peer range says. Put a tilde in front of every one, such as `~8.2.0` or `~8.2.0-ea.0`. A tilde stays within `<to>` and still takes its fixes. A caret would let the install take a later release, whose instructions have not been applied, and would let a GA package move ahead of a package below GA that the tests use.
|
|
61
|
+
|
|
62
|
+
Where each entry goes is the same on every release:
|
|
63
|
+
- A package that the extension's shipped code imports belongs under `peerDependencies`, and again under `devDependencies`.
|
|
64
|
+
- A package that only the extension's tests use, such as a database package the tests run against, belongs under `devDependencies` alone.
|
|
65
|
+
- Move any entry that is still under `dependencies` or `optionalDependencies`. An extension written for an earlier release had the framework, the family and the toolchain as ordinary dependencies.
|
|
66
|
+
|
|
67
|
+
The skill itself ships inside the Prisma packages, so bumping them is what updates it. There is no separate skill package to bump.
|
|
53
68
|
|
|
54
69
|
2. **Install.** Run `pnpm install` (or the project's lockfile-managing command). The extension's source is now broken against the new SPI — the upgrade instructions for `<from> → <to>` exist to fix it.
|
|
55
70
|
|
|
56
|
-
3. **Check pins.**
|
|
71
|
+
3. **Check pins.** This check is for the `8.0.0` release candidates. From release 8.0 it does not apply, because the entries are ranges, described in [the last section](#from-release-80-number-your-package-and-declare-ranges). On the release candidates:
|
|
72
|
+
- every `@prisma/orm-*` entry under `peerDependencies` or `devDependencies` must be the single exact string `<to>`;
|
|
73
|
+
- every such peer dependency must also be under `devDependencies`;
|
|
74
|
+
- none may be under `dependencies` or `optionalDependencies`.
|
|
75
|
+
|
|
76
|
+
A development dependency with no peer entry is one that only the tests use, and passes. This prints any entry that breaks the rule, and exits 1:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
node -e 'const p=require("./package.json");const to=process.argv[1];const ours=(n)=>n.startsWith("@prisma/orm-");const bad=[];for(const f of ["dependencies","optionalDependencies"])for(const n of Object.keys(p[f]??{}))if(ours(n))bad.push(f+": "+n+" belongs in peerDependencies, or in devDependencies alone if only tests use it");for(const f of ["peerDependencies","devDependencies"])for(const [n,v] of Object.entries(p[f]??{}))if(ours(n)&&v!==to)bad.push(f+": "+n+"@"+v);for(const n of Object.keys(p.peerDependencies??{}))if(ours(n)&&!(n in (p.devDependencies??{})))bad.push("devDependencies: "+n+" is missing");if(bad.length){console.error(bad.join("\n"));process.exit(1)}' <to>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
If it fails, the bump step did not rewrite every entry. Fix the entries it printed and run it again before going on.
|
|
57
83
|
|
|
58
84
|
4. **Read the upgrade instructions.** Re-sync the skills (`prisma skills sync`) so the tree matches the version just installed, then load `../upgrading/extension/upgrades/<from>-to-<to>/instructions.md`. Parse the YAML frontmatter and pay particular attention to its `changes[]` array.
|
|
59
85
|
|
|
60
|
-
5. **Apply each change.** For each entry in `changes[]`:
|
|
61
|
-
- If the entry has a `detection` block (a glob + content predicate), run it. If no files match, skip this change.
|
|
86
|
+
5. **Apply each change.** When the guide's body has a section that orders the steps, such as `Order of the steps`, apply the changes in that order: it says which script runs before which, and when to sign the databases and when to plan and apply a migration. Where an entry's prose says to sign or migrate, do it at the step that section names. Otherwise take the entries in the order of `changes[]`. For each entry in `changes[]`:
|
|
87
|
+
- If the entry has a `detection` block (a glob + content predicate), run it. If no files match, skip this change. Run the glob over the project's own files: skip `node_modules`, and build output such as `dist`, `build`, `.next` or `out` (whatever directories the project's build writes). A match there is generated code, which the next build rewrites; editing it changes nothing. Migration snapshots under `migrations/snapshots/` are committed files, not build output, so keep them.
|
|
88
|
+
- How a `detection` block runs: `glob` selects files relative to the project root. Each `matches` entry, once read from the YAML, is a JavaScript regular expression, built as `new RegExp(pattern)` with no flags and tested against the whole content of one file at a time; each `contains` entry is a plain substring. A file is a hit when any entry matches it. Patterns may span lines, and some look at the whole file (for example, to skip a file that declares something elsewhere in it), so a line-by-line search such as `grep` or `rg` without `-U` is not the same test and can report files the pattern excludes. From a shell, `rg -U --pcre2 -l -e '<pattern>' <files>` tests whole files and gives the same hits.
|
|
62
89
|
- If the entry has no `detection`, apply unconditionally.
|
|
63
90
|
- If the entry names a `script:` (a relative path next to `instructions.md`), invoke it from the project root:
|
|
64
|
-
- `*.ts` → `pnpm exec tsx <skill>/upgrading/extension/upgrades/<from>-to-<to>/<script>`
|
|
91
|
+
- `*.ts` → the command the guide's prose gives, such as `node <script>` (Node 24 or later runs TypeScript directly); with no command in the prose, `pnpm exec tsx <skill>/upgrading/extension/upgrades/<from>-to-<to>/<script>`
|
|
65
92
|
- `*.sh` → `bash <skill>/upgrading/extension/upgrades/<from>-to-<to>/<script>`
|
|
66
93
|
- codemods → invoke per the script's own `instructions.md` prose.
|
|
67
94
|
- If the entry has no `script`, follow the prose body in `instructions.md` directly.
|
|
@@ -73,7 +100,7 @@ For each `(from, to)` step in the chain:
|
|
|
73
100
|
7. **Commit.** Create one commit containing this step's changes: the `package.json` bump, the lockfile churn from `pnpm install`, and any source-file rewrites from the applied changes. Use the message:
|
|
74
101
|
|
|
75
102
|
```text
|
|
76
|
-
chore: upgrade @
|
|
103
|
+
chore: upgrade @prisma/orm-* to <to-version>
|
|
77
104
|
```
|
|
78
105
|
|
|
79
106
|
(Or the extension's own commit-message convention, if it has one.) One commit per step — never squash steps.
|
|
@@ -82,15 +109,37 @@ Move on to the next step. Repeat.
|
|
|
82
109
|
|
|
83
110
|
## Exact-pin rule
|
|
84
111
|
|
|
85
|
-
|
|
112
|
+
This rule holds until release 8.0, while every Prisma 8 package is published as `8.0.0-rc.N`. From release 8.0, ranges replace it; see [the last section](#from-release-80-number-your-package-and-declare-ranges).
|
|
86
113
|
|
|
87
|
-
|
|
114
|
+
A Prisma 8 extension names every `@prisma/orm-*` package its shipped code uses, another extension published from the Prisma repository included, as a **peer dependency** at a single **exact** version (no `^`, no `~`, no range, no wildcard, no `workspace:` specifier in the published `package.json`), and lists the same packages under `devDependencies` at that version, so its own build and tests install them. A package of ours that only its tests use is a development dependency alone, at that version. None of them is an ordinary dependency. All of those entries share the same version. The pin advances after each successful upgrade step, release-candidate steps included.
|
|
88
115
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
116
|
+
The version is the one the application's database package (`@prisma/orm-postgres`, `@prisma/orm-mongo`, …) uses.
|
|
117
|
+
|
|
118
|
+
An application must have one copy of each Prisma package, and peer dependencies are what make the package manager check that. A version that does not match is reported at install: npm refuses, and pnpm, Yarn and Bun install and print a peer dependency warning, so read the warnings. With an ordinary dependency, a version that does not fit would quietly become a second copy, which fails at run time.
|
|
119
|
+
|
|
120
|
+
To list every copy and the package that brought it, run `npm ls @prisma/orm-framework`, `pnpm why @prisma/orm-framework` or `bun why @prisma/orm-framework`. [ADR 329](https://github.com/prisma/orm/blob/main/docs/architecture%20docs/adrs/ADR%20329%20-%20An%20application%20lists%20the%20platform%20packages%20and%20our%20packages%20name%20each%20other%20as%20peers.md) explains the reasons, and the one case peer dependencies do not cover, a monorepo with applications on different Prisma releases.
|
|
121
|
+
|
|
122
|
+
The one-line check in step 3 of the per-step flow enforces the rule; the `prisma-8-check-pins` guard the monorepo uses for its own extensions is not published. Wire the check into the extension's CI alongside the build/test step so an accidental range pin fails the PR before it lands.
|
|
123
|
+
|
|
124
|
+
## From release 8.0: number your package and declare ranges
|
|
125
|
+
|
|
126
|
+
From release 8.0, Prisma's packages share a release number, which is the major and minor of the version. Each package then has its own patch number, or a level suffix such as `-preview.0` while it is below Generally Available (GA). [Versions and support](https://github.com/prisma/orm/blob/main/docs/oss/versioning.md#version-numbers) explains the scheme. For a package maintained outside the Prisma repository we recommend the same convention ([ADR 330](https://github.com/prisma/orm/blob/main/docs/architecture%20docs/adrs/ADR%20330%20-%20A%20maturity%20level%20is%20written%20in%20a%20package's%20version%20and%20an%20API's%20name.md#packages-maintained-outside-this-repository)).
|
|
127
|
+
|
|
128
|
+
**Your package's version.** Take the major and minor of the first Prisma release your package works with. The patch number is your own. A package built on release `8.1` is `8.1.0`, then `8.1.1` and `8.1.2` for your own changes. The number means "needs at least this release". It does not have to equal the application's release.
|
|
129
|
+
|
|
130
|
+
**The ranges you list on Prisma's packages,** as peer dependencies:
|
|
131
|
+
|
|
132
|
+
| Situation | Range | Example |
|
|
133
|
+
| --- | --- | --- |
|
|
134
|
+
| A GA package, and you use only its GA functions | A caret on the first release your package works with | `^8.1.0` |
|
|
135
|
+
| A GA package, and you use a function below GA, such as `preview_search` | A tilde: that function may change in the next release | `~8.1.0` |
|
|
136
|
+
| A package below GA | A tilde on its first version in that release | `~8.1.0-preview.0` |
|
|
137
|
+
|
|
138
|
+
With a caret, your package keeps working when an application moves to a later release: a package at `8.1.2` that lists `^8.1.0` works in an application on `8.4`. An application on a release below `8.1` gets a mismatch reported at install. With a tilde, you publish a new version of your package for each Prisma release.
|
|
139
|
+
|
|
140
|
+
**At release 8.0, write `^8.0.1` and `~8.0.1-ea.0`** (or `-preview.0`, `-rc.0`). Every Prisma package starts release 8.0 at patch 1. Never write `8.0.0` in a range on Prisma's packages: `~8.0.0-ea.0` accepts the old `8.0.0-rc.N` release candidates, because `rc` sorts after `ea`, and some package managers then install one.
|
|
92
141
|
|
|
93
|
-
|
|
142
|
+
The convention has two costs. A feature of yours that needs no newer Prisma release ships as a patch. And once your package is GA, you cannot make a breaking change of your own until Prisma's next major version.
|
|
94
143
|
|
|
95
144
|
## When the chain is done
|
|
96
145
|
|
|
@@ -348,7 +348,7 @@ After re-emitting, run `pnpm typecheck && pnpm test`. The regenerated `contract.
|
|
|
348
348
|
|
|
349
349
|
## `runtime-qualified-sql-default-namespace`
|
|
350
350
|
|
|
351
|
-
Starting at the 0.12 release, runtime SQL on Postgres qualifies table identifiers with the storage namespace the flat DSL/ORM surface resolved ([ADR 223](
|
|
351
|
+
Starting at the 0.12 release, runtime SQL on Postgres qualifies table identifiers with the storage namespace the flat DSL/ORM surface resolved ([ADR 223](https://github.com/prisma/orm/blob/main/docs/architecture%20docs/adrs/ADR%20223%20-%20Target-owned%20default%20namespace.md)). Un-namespaced Postgres models continue to resolve through the `public` default; explicit `namespace unbound { … }` in PSL still maps to `__unbound__`.
|
|
352
352
|
|
|
353
353
|
### Application code
|
|
354
354
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
from: "8.0.0-rc.10"
|
|
3
|
+
to: "8.0.0-rc.11"
|
|
4
|
+
changes:
|
|
5
|
+
- id: engine-pin-moves-to-0-4-0
|
|
6
|
+
summary: |
|
|
7
|
+
The toolchain now requires `@prisma/cli-engine@0.4.0` (up from 0.3.0). Projects assembled
|
|
8
|
+
by the unified `prisma` CLI resolve the engine automatically. A project that pins
|
|
9
|
+
`@prisma/cli-engine` itself must move the pin to `0.4.0`. The new engine adds a
|
|
10
|
+
`--format markdown` output format to every command; nothing else in its public API changed.
|
|
11
|
+
detection:
|
|
12
|
+
glob: "**/package.json"
|
|
13
|
+
contains:
|
|
14
|
+
- '"@prisma/cli-engine": "0.3.0"'
|
|
15
|
+
- id: contract-artifacts-restamp
|
|
16
|
+
summary: |
|
|
17
|
+
The emitted `contract.json` / `contract.d.ts` embed the toolchain version, which moves
|
|
18
|
+
to 8.0.0-rc.11. Run `contract emit` once after upgrading so the emitted artifacts match
|
|
19
|
+
the installed toolchain.
|
|
20
|
+
detection:
|
|
21
|
+
glob: "**/contract.json"
|
|
22
|
+
contains:
|
|
23
|
+
- '"version": "8.0.0-rc.10"'
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
# 8.0.0-rc.10 → 8.0.0-rc.11 — User upgrade instructions
|
|
27
|
+
|
|
28
|
+
## `engine-pin-moves-to-0-4-0`
|
|
29
|
+
|
|
30
|
+
For every `package.json` matched by `detection`, change the `@prisma/cli-engine` version from `0.3.0` to `0.4.0` and reinstall. No code changes are needed: the engine only adds `--format markdown`, and every existing flag and output format keeps working.
|
|
31
|
+
|
|
32
|
+
## `contract-artifacts-restamp`
|
|
33
|
+
|
|
34
|
+
For every `contract.json` matched by `detection`, run the project's emit command (`prisma contract emit`, or the project's `contract:emit` script) once after upgrading. The only expected diff is the embedded `version` moving to `8.0.0-rc.11`.
|