@prisma/orm-mongo 8.0.0-rc.25-dev.29 → 8.0.0-rc.27
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 +6 -5
- package/dist/bson.d.mts +2 -1
- package/dist/components__runtime.d.mts +3 -1
- package/dist/config.d.mts +2 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/contract-builder.d.mts +11 -12
- package/dist/contract-builder.d.mts.map +1 -1
- package/dist/contract-types.d.mts +5 -3
- package/dist/contract__types.d.mts +3 -1
- package/dist/control.d.mts +2 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/family-contract.d.mts +3 -1
- package/dist/family-runtime.d.mts +3 -1
- package/dist/family.d.mts +2 -1
- package/dist/family__control.d.mts +3 -1
- package/dist/init-quick-reference.md +1 -1
- package/dist/init.d.mts +2 -1
- package/dist/init.d.mts.map +1 -1
- package/dist/migration-tools__aggregate.d.mts +3 -1
- package/dist/migration-tools__hash.d.mts +3 -1
- package/dist/migration-tools__io.d.mts +3 -1
- package/dist/migration-tools__spaces.d.mts +3 -1
- package/dist/migration.d.mts +3 -1
- package/dist/{mongo-static-CZlnpepm-DnjIfx0L.mjs → mongo-static-Uk6OGD4r-BoKXE7a6.mjs} +4 -4
- package/dist/mongo-static-Uk6OGD4r-BoKXE7a6.mjs.map +1 -0
- package/dist/orm.d.mts +3 -1
- package/dist/query-ast__execution.d.mts +3 -1
- package/dist/query-builder.d.mts +3 -1
- package/dist/runtime.d.mts +3 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +6 -6
- package/dist/runtime.mjs.map +1 -1
- package/dist/static.d.mts +2 -1
- package/dist/static.d.mts.map +1 -1
- package/dist/static.mjs +1 -1
- package/dist/target.d.mts +2 -1
- package/dist/target__codec-ids.d.mts +3 -1
- package/dist/target__codec-types.d.mts +3 -1
- package/dist/target__migration.d.mts +3 -1
- package/dist/target__runtime.d.mts +2 -1
- package/dist/value.d.mts +3 -1
- package/dist/vite-plugin-contract-emit.d.mts +3 -1
- package/package.json +12 -81
- package/skills/prisma-8/SKILL.md +8 -8
- package/skills/prisma-8/references/contract.md +9 -9
- package/skills/prisma-8/references/debug.md +11 -11
- package/skills/prisma-8/references/migration-model.md +17 -17
- package/skills/prisma-8/references/migration-review.md +21 -21
- package/skills/prisma-8/references/migrations.md +58 -42
- package/skills/prisma-8/references/queries-postgres.md +51 -8
- package/skills/prisma-8/references/queries.md +2 -2
- package/skills/prisma-8/references/quickstart.md +11 -11
- package/skills/prisma-8/references/runtime.md +3 -3
- package/skills/prisma-8/references/supabase.md +2 -2
- package/skills/prisma-8/references/upgrade-app.md +56 -23
- package/skills/prisma-8/references/upgrade-extension.md +35 -14
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/instructions.md +2478 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/contract-hash-inputs/contract-hash-inputs.ts +2125 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/contract-signature-names/contract-signature-names.ts +759 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/facade-paths-an-application-uses/facade-paths-an-application-uses.ts +689 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/platform-paths-an-extension-uses/platform-paths-an-extension-uses.ts +2053 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/stored-files-format-version/stored-files-format-version.ts +671 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.26-to-8.0.0-rc.27/instructions.md +100 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/instructions.md +1 -1
- package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/instructions.md +1 -1
- package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/instructions.md +1 -1
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/instructions.md +2057 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/contract-hash-inputs/contract-hash-inputs.ts +2125 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/contract-signature-names/contract-signature-names.ts +759 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/facade-paths-an-application-uses/facade-paths-an-application-uses.ts +689 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/platform-paths-an-extension-uses/platform-paths-an-extension-uses.ts +2053 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.25-to-8.0.0-rc.26/scripts/stored-files-format-version/stored-files-format-version.ts +671 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.26-to-8.0.0-rc.27/instructions.md +56 -0
- package/dist/adapter.d.mts +0 -1
- package/dist/adapter.mjs +0 -2
- package/dist/adapter__control.d.mts +0 -3
- package/dist/adapter__control.mjs +0 -3
- package/dist/adapter__runtime.d.mts +0 -3
- package/dist/adapter__runtime.mjs +0 -3
- package/dist/components.d.mts +0 -1
- package/dist/components.mjs +0 -2
- package/dist/components__authoring.d.mts +0 -1
- package/dist/components__authoring.mjs +0 -2
- package/dist/components__codec.d.mts +0 -1
- package/dist/components__codec.mjs +0 -2
- package/dist/components__components.d.mts +0 -1
- package/dist/components__components.mjs +0 -2
- package/dist/components__control.d.mts +0 -1
- package/dist/components__control.mjs +0 -2
- package/dist/components__emission.d.mts +0 -1
- package/dist/components__emission.mjs +0 -2
- package/dist/components__execution.d.mts +0 -1
- package/dist/components__execution.mjs +0 -2
- package/dist/components__ir.d.mts +0 -1
- package/dist/components__ir.mjs +0 -2
- package/dist/components__psl-ast.d.mts +0 -1
- package/dist/components__psl-ast.mjs +0 -2
- package/dist/components__utils.d.mts +0 -1
- package/dist/components__utils.mjs +0 -2
- package/dist/contract.d.mts +0 -1
- package/dist/contract.mjs +0 -2
- package/dist/contract__apply-specifier-default-control-policy.d.mts +0 -1
- package/dist/contract__apply-specifier-default-control-policy.mjs +0 -2
- package/dist/contract__contract-validation-error.d.mts +0 -1
- package/dist/contract__contract-validation-error.mjs +0 -2
- package/dist/contract__default-namespace.d.mts +0 -1
- package/dist/contract__default-namespace.mjs +0 -2
- package/dist/contract__enum-accessor.d.mts +0 -1
- package/dist/contract__enum-accessor.mjs +0 -2
- package/dist/contract__format-version.d.mts +0 -1
- package/dist/contract__format-version.mjs +0 -2
- package/dist/contract__hashing-utils.d.mts +0 -1
- package/dist/contract__hashing-utils.mjs +0 -2
- package/dist/contract__hashing.d.mts +0 -1
- package/dist/contract__hashing.mjs +0 -2
- package/dist/contract__internal__format-version.d.mts +0 -1
- package/dist/contract__internal__format-version.mjs +0 -2
- package/dist/contract__is-plain-record.d.mts +0 -1
- package/dist/contract__is-plain-record.mjs +0 -2
- package/dist/contract__resolve-domain-model.d.mts +0 -1
- package/dist/contract__resolve-domain-model.mjs +0 -2
- package/dist/contract__validate-domain.d.mts +0 -1
- package/dist/contract__validate-domain.mjs +0 -2
- package/dist/contract__validate-once.d.mts +0 -1
- package/dist/contract__validate-once.mjs +0 -2
- package/dist/contract__validate-storage.d.mts +0 -1
- package/dist/contract__validate-storage.mjs +0 -2
- package/dist/driver.d.mts +0 -1
- package/dist/driver.mjs +0 -2
- package/dist/driver__control.d.mts +0 -3
- package/dist/driver__control.mjs +0 -3
- package/dist/driver__runtime.d.mts +0 -3
- package/dist/driver__runtime.mjs +0 -3
- package/dist/family-contract__canonicalization-hooks.d.mts +0 -1
- package/dist/family-contract__canonicalization-hooks.mjs +0 -2
- package/dist/family-contract__data-type.d.mts +0 -1
- package/dist/family-contract__data-type.mjs +0 -2
- package/dist/family-contract__entity-kinds.d.mts +0 -1
- package/dist/family-contract__entity-kinds.mjs +0 -2
- package/dist/family__control-adapter.d.mts +0 -1
- package/dist/family__control-adapter.mjs +0 -2
- package/dist/family__ir.d.mts +0 -1
- package/dist/family__ir.mjs +0 -2
- package/dist/family__migration.d.mts +0 -1
- package/dist/family__migration.mjs +0 -2
- package/dist/family__pack.d.mts +0 -3
- package/dist/family__pack.mjs +0 -3
- package/dist/family__runtime.d.mts +0 -1
- package/dist/family__runtime.mjs +0 -2
- package/dist/family__schema-verify.d.mts +0 -1
- package/dist/family__schema-verify.mjs +0 -2
- package/dist/migration-tools__contract-snapshot-store.d.mts +0 -1
- package/dist/migration-tools__contract-snapshot-store.mjs +0 -2
- package/dist/mongo-static-CZlnpepm-DnjIfx0L.mjs.map +0 -1
- package/dist/query-ast.d.mts +0 -1
- package/dist/query-ast.mjs +0 -2
- package/dist/query-ast__control.d.mts +0 -1
- package/dist/query-ast__control.mjs +0 -2
- package/dist/query-builder__contract-free.d.mts +0 -1
- package/dist/query-builder__contract-free.mjs +0 -2
- package/dist/target__codecs.d.mts +0 -1
- package/dist/target__codecs.mjs +0 -2
- package/dist/target__control.d.mts +0 -1
- package/dist/target__control.mjs +0 -2
- package/dist/target__data-types.d.mts +0 -1
- package/dist/target__data-types.mjs +0 -2
- package/dist/target__pack.d.mts +0 -3
- package/dist/target__pack.mjs +0 -3
- package/dist/target__server-version.d.mts +0 -1
- package/dist/target__server-version.mjs +0 -2
- package/dist/utils.d.mts +0 -1
- package/dist/utils.mjs +0 -2
- package/dist/utils__abortable.d.mts +0 -1
- package/dist/utils__abortable.mjs +0 -2
- package/dist/utils__array-equal.d.mts +0 -1
- package/dist/utils__array-equal.mjs +0 -2
- package/dist/utils__assertions.d.mts +0 -1
- package/dist/utils__assertions.mjs +0 -2
- package/dist/utils__canonical-stringify.d.mts +0 -1
- package/dist/utils__canonical-stringify.mjs +0 -2
- package/dist/utils__casts.d.mts +0 -1
- package/dist/utils__casts.mjs +0 -2
- package/dist/utils__defined.d.mts +0 -1
- package/dist/utils__defined.mjs +0 -2
- package/dist/utils__guards.d.mts +0 -1
- package/dist/utils__guards.mjs +0 -2
- package/dist/utils__hash-content.d.mts +0 -1
- package/dist/utils__hash-content.mjs +0 -2
- package/dist/utils__internal-error.d.mts +0 -1
- package/dist/utils__internal-error.mjs +0 -2
- package/dist/utils__json.d.mts +0 -1
- package/dist/utils__json.mjs +0 -2
- package/dist/utils__promise.d.mts +0 -1
- package/dist/utils__promise.mjs +0 -2
- package/dist/utils__redact-db-url.d.mts +0 -1
- package/dist/utils__redact-db-url.mjs +0 -2
- package/dist/utils__result.d.mts +0 -1
- package/dist/utils__result.mjs +0 -2
- package/dist/utils__simplify-deep.d.mts +0 -1
- package/dist/utils__simplify-deep.mjs +0 -2
- package/dist/utils__structured-error.d.mts +0 -1
- package/dist/utils__structured-error.mjs +0 -2
- package/dist/utils__suppress-idle-connection-errors.d.mts +0 -1
- package/dist/utils__suppress-idle-connection-errors.mjs +0 -2
- package/dist/utils__text.d.mts +0 -1
- package/dist/utils__text.mjs +0 -2
- package/dist/utils__types.d.mts +0 -1
- package/dist/utils__types.mjs +0 -2
- package/dist/utils__upgrade-guides.d.mts +0 -1
- package/dist/utils__upgrade-guides.mjs +0 -2
- package/dist/value__mongodb-types.d.mts +0 -1
- package/dist/value__mongodb-types.mjs +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/orm-mongo",
|
|
3
|
-
"version": "8.0.0-rc.
|
|
3
|
+
"version": "8.0.0-rc.27",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -19,21 +19,21 @@
|
|
|
19
19
|
"temporal-spec": "1.0.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@internal/mongo": "8.0.0-rc.
|
|
23
|
-
"@prisma/orm-family-mongo": "8.0.0-rc.
|
|
24
|
-
"@prisma/orm-framework": "8.0.0-rc.
|
|
25
|
-
"@prisma/orm-target-mongo": "8.0.0-rc.
|
|
26
|
-
"@prisma/orm-toolchain": "8.0.0-rc.
|
|
27
|
-
"@repo/tsconfig": "8.0.0-rc.
|
|
28
|
-
"@repo/tsdown": "8.0.0-rc.
|
|
22
|
+
"@internal/mongo": "8.0.0-rc.27",
|
|
23
|
+
"@prisma/orm-family-mongo": "8.0.0-rc.27",
|
|
24
|
+
"@prisma/orm-framework": "8.0.0-rc.27",
|
|
25
|
+
"@prisma/orm-target-mongo": "8.0.0-rc.27",
|
|
26
|
+
"@prisma/orm-toolchain": "8.0.0-rc.27",
|
|
27
|
+
"@repo/tsconfig": "8.0.0-rc.27",
|
|
28
|
+
"@repo/tsdown": "8.0.0-rc.27",
|
|
29
29
|
"tsdown": "0.22.14",
|
|
30
30
|
"typescript": "5.9.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@prisma/orm-family-mongo": "8.0.0-rc.
|
|
34
|
-
"@prisma/orm-framework": "8.0.0-rc.
|
|
35
|
-
"@prisma/orm-target-mongo": "8.0.0-rc.
|
|
36
|
-
"@prisma/orm-toolchain": "8.0.0-rc.
|
|
33
|
+
"@prisma/orm-family-mongo": "8.0.0-rc.27",
|
|
34
|
+
"@prisma/orm-framework": "8.0.0-rc.27",
|
|
35
|
+
"@prisma/orm-target-mongo": "8.0.0-rc.27",
|
|
36
|
+
"@prisma/orm-toolchain": "8.0.0-rc.27",
|
|
37
37
|
"mongodb": "^7.0.0",
|
|
38
38
|
"temporal-polyfill": "^1.0.8",
|
|
39
39
|
"typescript": ">=5.9"
|
|
@@ -44,103 +44,34 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"exports": {
|
|
47
|
-
"./adapter": "./dist/adapter.mjs",
|
|
48
|
-
"./adapter/control": "./dist/adapter__control.mjs",
|
|
49
|
-
"./adapter/runtime": "./dist/adapter__runtime.mjs",
|
|
50
47
|
"./bson": "./dist/bson.mjs",
|
|
51
|
-
"./components": "./dist/components.mjs",
|
|
52
|
-
"./components/authoring": "./dist/components__authoring.mjs",
|
|
53
|
-
"./components/codec": "./dist/components__codec.mjs",
|
|
54
|
-
"./components/components": "./dist/components__components.mjs",
|
|
55
|
-
"./components/control": "./dist/components__control.mjs",
|
|
56
|
-
"./components/emission": "./dist/components__emission.mjs",
|
|
57
|
-
"./components/execution": "./dist/components__execution.mjs",
|
|
58
|
-
"./components/ir": "./dist/components__ir.mjs",
|
|
59
|
-
"./components/psl-ast": "./dist/components__psl-ast.mjs",
|
|
60
48
|
"./components/runtime": "./dist/components__runtime.mjs",
|
|
61
|
-
"./components/utils": "./dist/components__utils.mjs",
|
|
62
49
|
"./config": "./dist/config.mjs",
|
|
63
|
-
"./contract": "./dist/contract.mjs",
|
|
64
|
-
"./contract/apply-specifier-default-control-policy": "./dist/contract__apply-specifier-default-control-policy.mjs",
|
|
65
|
-
"./contract/contract-validation-error": "./dist/contract__contract-validation-error.mjs",
|
|
66
|
-
"./contract/default-namespace": "./dist/contract__default-namespace.mjs",
|
|
67
|
-
"./contract/enum-accessor": "./dist/contract__enum-accessor.mjs",
|
|
68
|
-
"./contract/format-version": "./dist/contract__format-version.mjs",
|
|
69
|
-
"./contract/hashing": "./dist/contract__hashing.mjs",
|
|
70
|
-
"./contract/hashing-utils": "./dist/contract__hashing-utils.mjs",
|
|
71
|
-
"./contract/internal/format-version": "./dist/contract__internal__format-version.mjs",
|
|
72
|
-
"./contract/is-plain-record": "./dist/contract__is-plain-record.mjs",
|
|
73
|
-
"./contract/resolve-domain-model": "./dist/contract__resolve-domain-model.mjs",
|
|
74
50
|
"./contract/types": "./dist/contract__types.mjs",
|
|
75
|
-
"./contract/validate-domain": "./dist/contract__validate-domain.mjs",
|
|
76
|
-
"./contract/validate-once": "./dist/contract__validate-once.mjs",
|
|
77
|
-
"./contract/validate-storage": "./dist/contract__validate-storage.mjs",
|
|
78
51
|
"./contract-builder": "./dist/contract-builder.mjs",
|
|
79
52
|
"./contract-types": "./dist/contract-types.mjs",
|
|
80
53
|
"./control": "./dist/control.mjs",
|
|
81
|
-
"./driver": "./dist/driver.mjs",
|
|
82
|
-
"./driver/control": "./dist/driver__control.mjs",
|
|
83
|
-
"./driver/runtime": "./dist/driver__runtime.mjs",
|
|
84
54
|
"./family": "./dist/family.mjs",
|
|
85
55
|
"./family/control": "./dist/family__control.mjs",
|
|
86
|
-
"./family/control-adapter": "./dist/family__control-adapter.mjs",
|
|
87
|
-
"./family/ir": "./dist/family__ir.mjs",
|
|
88
|
-
"./family/migration": "./dist/family__migration.mjs",
|
|
89
|
-
"./family/pack": "./dist/family__pack.mjs",
|
|
90
|
-
"./family/runtime": "./dist/family__runtime.mjs",
|
|
91
|
-
"./family/schema-verify": "./dist/family__schema-verify.mjs",
|
|
92
56
|
"./family-contract": "./dist/family-contract.mjs",
|
|
93
|
-
"./family-contract/canonicalization-hooks": "./dist/family-contract__canonicalization-hooks.mjs",
|
|
94
|
-
"./family-contract/data-type": "./dist/family-contract__data-type.mjs",
|
|
95
|
-
"./family-contract/entity-kinds": "./dist/family-contract__entity-kinds.mjs",
|
|
96
57
|
"./family-runtime": "./dist/family-runtime.mjs",
|
|
97
58
|
"./init": "./dist/init.mjs",
|
|
98
59
|
"./migration": "./dist/migration.mjs",
|
|
99
60
|
"./migration-tools/aggregate": "./dist/migration-tools__aggregate.mjs",
|
|
100
|
-
"./migration-tools/contract-snapshot-store": "./dist/migration-tools__contract-snapshot-store.mjs",
|
|
101
61
|
"./migration-tools/hash": "./dist/migration-tools__hash.mjs",
|
|
102
62
|
"./migration-tools/io": "./dist/migration-tools__io.mjs",
|
|
103
63
|
"./migration-tools/spaces": "./dist/migration-tools__spaces.mjs",
|
|
104
64
|
"./orm": "./dist/orm.mjs",
|
|
105
|
-
"./query-ast": "./dist/query-ast.mjs",
|
|
106
|
-
"./query-ast/control": "./dist/query-ast__control.mjs",
|
|
107
65
|
"./query-ast/execution": "./dist/query-ast__execution.mjs",
|
|
108
66
|
"./query-builder": "./dist/query-builder.mjs",
|
|
109
|
-
"./query-builder/contract-free": "./dist/query-builder__contract-free.mjs",
|
|
110
67
|
"./runtime": "./dist/runtime.mjs",
|
|
111
68
|
"./static": "./dist/static.mjs",
|
|
112
69
|
"./target": "./dist/target.mjs",
|
|
113
70
|
"./target/codec-ids": "./dist/target__codec-ids.mjs",
|
|
114
71
|
"./target/codec-types": "./dist/target__codec-types.mjs",
|
|
115
|
-
"./target/codecs": "./dist/target__codecs.mjs",
|
|
116
|
-
"./target/control": "./dist/target__control.mjs",
|
|
117
|
-
"./target/data-types": "./dist/target__data-types.mjs",
|
|
118
72
|
"./target/migration": "./dist/target__migration.mjs",
|
|
119
|
-
"./target/pack": "./dist/target__pack.mjs",
|
|
120
73
|
"./target/runtime": "./dist/target__runtime.mjs",
|
|
121
|
-
"./target/server-version": "./dist/target__server-version.mjs",
|
|
122
|
-
"./utils": "./dist/utils.mjs",
|
|
123
|
-
"./utils/abortable": "./dist/utils__abortable.mjs",
|
|
124
|
-
"./utils/array-equal": "./dist/utils__array-equal.mjs",
|
|
125
|
-
"./utils/assertions": "./dist/utils__assertions.mjs",
|
|
126
|
-
"./utils/canonical-stringify": "./dist/utils__canonical-stringify.mjs",
|
|
127
|
-
"./utils/casts": "./dist/utils__casts.mjs",
|
|
128
|
-
"./utils/defined": "./dist/utils__defined.mjs",
|
|
129
|
-
"./utils/guards": "./dist/utils__guards.mjs",
|
|
130
|
-
"./utils/hash-content": "./dist/utils__hash-content.mjs",
|
|
131
|
-
"./utils/internal-error": "./dist/utils__internal-error.mjs",
|
|
132
|
-
"./utils/json": "./dist/utils__json.mjs",
|
|
133
|
-
"./utils/promise": "./dist/utils__promise.mjs",
|
|
134
|
-
"./utils/redact-db-url": "./dist/utils__redact-db-url.mjs",
|
|
135
|
-
"./utils/result": "./dist/utils__result.mjs",
|
|
136
|
-
"./utils/simplify-deep": "./dist/utils__simplify-deep.mjs",
|
|
137
|
-
"./utils/structured-error": "./dist/utils__structured-error.mjs",
|
|
138
|
-
"./utils/suppress-idle-connection-errors": "./dist/utils__suppress-idle-connection-errors.mjs",
|
|
139
|
-
"./utils/text": "./dist/utils__text.mjs",
|
|
140
|
-
"./utils/types": "./dist/utils__types.mjs",
|
|
141
|
-
"./utils/upgrade-guides": "./dist/utils__upgrade-guides.mjs",
|
|
142
74
|
"./value": "./dist/value.mjs",
|
|
143
|
-
"./value/mongodb-types": "./dist/value__mongodb-types.mjs",
|
|
144
75
|
"./vite-plugin-contract-emit": "./dist/vite-plugin-contract-emit.mjs",
|
|
145
76
|
"./package.json": "./package.json"
|
|
146
77
|
},
|
package/skills/prisma-8/SKILL.md
CHANGED
|
@@ -15,7 +15,7 @@ description: >-
|
|
|
15
15
|
ORM 7 or earlier (schema.prisma + @prisma/client).
|
|
16
16
|
metadata:
|
|
17
17
|
library: '@prisma/orm-mongo'
|
|
18
|
-
library_version: '8.0.0-rc.
|
|
18
|
+
library_version: '8.0.0-rc.27'
|
|
19
19
|
version: '2026-09-12'
|
|
20
20
|
---
|
|
21
21
|
|
|
@@ -37,7 +37,7 @@ Check these before acting on anything below. Halt on the first one that fails an
|
|
|
37
37
|
|
|
38
38
|
## Never reset or drop a database
|
|
39
39
|
|
|
40
|
-
Never reset or drop a database to fix a migration,
|
|
40
|
+
Never reset or drop a database to fix a migration, contract signature or contract problem, and never propose it. A database can always be moved to the contract you want. When its migration history does not need to be kept (a local, development, staging or preview database), reconcile it with `prisma db update`. When it changes only through migrations, as production should, author the migrations that bring it there. The database's change policy, recorded in its signature, says which it is, and `db update` refuses one that permits only migrations; never edit a ref's `policies` or pass `--permit-policy-change` to get past that. A deploy that says there is no migration path, or `MIGRATION.SIGNATURE_NOT_IN_GRAPH`, is covered in [`references/migrations.md`](references/migrations.md) § *A database whose signature is not in the migration graph*.
|
|
41
41
|
|
|
42
42
|
Prisma 8 is a contract-first data layer. This skill routes every Prisma 8 task to the right reference file — open the reference before writing code; do not answer from this file alone.
|
|
43
43
|
|
|
@@ -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`, `@prisma/orm-postgres/config`, `@prisma/orm-postgres/contract-builder`, `@prisma/orm-mongo/config`, `extensions:`, pgvector, postgis,
|
|
66
|
-
| Author migrations | [`references/migrations.md`](references/migrations.md) | "no migration path", "migration path not found", "no authored path", `MIGRATION.
|
|
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, 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.SIGNATURE_NOT_IN_GRAPH`, `MIGRATION.CHANGE_POLICY_FORBIDS`, `MIGRATION.DATA_PROTECTION_FORBIDS`, `MIGRATION.POLICY_MISMATCH`, change policy, data protection policy, `migration ref policy show` / `set` / `delete`, declaring a ref's policies, `--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
|
-
| 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.
|
|
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.
|
|
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.SIGNATURE_NOT_IN_GRAPH`, `MIGRATION.MISSING_INVARIANTS`, `db migrate --show` |
|
|
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.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 })` clients, 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
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
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
|
-
| 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.
|
|
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.SIGNATURE_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
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),
|
|
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), exact-pin rule, which `prisma` CLI version an extension's tests use, per-transition instructions in [`upgrading/extension/upgrades/`](upgrading/extension/upgrades/) |
|
|
76
76
|
| Build the package for a new database | [`references/build-a-target-package.md`](references/build-a-target-package.md) | a new database target outside Prisma's repository, `prisma-orm-<name>`, `defineConfig` with `contract.typesModule` and `migrations.module`, `/contract-types`, `restateTypeDeclarations`, the `/init` entrypoint, `InitContribution`, `prisma orm init --target <package>`, `CONFIG.CONTRACT_TYPES_MODULE_MISSING`, `CONFIG.MIGRATION_MODULE_MISSING` |
|
|
77
77
|
| 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 |
|
|
78
78
|
|
|
@@ -27,7 +27,7 @@ Both files are **emitted artefacts**. Edit the source; never the JSON or `.d.ts`
|
|
|
27
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, database package imports, `@prisma/orm-postgres/config`, `@prisma/orm-postgres/contract-builder`, extensions, pgvector, postgis,
|
|
30
|
+
- User mentions: *schema, fields, models, attributes, prisma schema, PSL, contract.prisma, contract.ts, contract.json, contract.d.ts, contract emit, database package imports, `@prisma/orm-postgres/config`, `@prisma/orm-postgres/contract-builder`, extensions, pgvector, postgis, 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 `@prisma/orm-<target>` package 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 entry points — `@prisma/orm-extension-pgvector/control`, `@prisma/orm-extension-postgis/control
|
|
44
|
+
- **The `@prisma/orm-<target>` package 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 entry points — `@prisma/orm-extension-pgvector/control`, `@prisma/orm-extension-postgis/control`. **Never import the platform packages (`@prisma/orm-framework`, `@prisma/orm-family-*`, `@prisma/orm-target-*`, `@prisma/orm-toolchain`) from user code.** The database package 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
|
-
- **`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. On PostgreSQL the entry is an object that also lists every capability the contract requires: `contract: { path: './<path>/contract.prisma', requiredCapabilities: [...postgres18, ...postgresDriver] }`, with `postgres18` (what PostgreSQL 18 provides; `postgres15` to `postgres17` for older databases) and `postgresDriver` (what the driver's connection provides, such as interactive transactions) imported from `@prisma/orm-postgres/config`. The list must not be empty and nothing is added to it; filter a key out to stop requiring it. 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).
|
|
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. On PostgreSQL the entry is an object that also lists every capability the contract requires: `contract: { path: './<path>/contract.prisma', requiredCapabilities: [...postgres18, ...postgresDriver] }`, with `postgres18` (what PostgreSQL 18 provides; `postgres15` to `postgres17` for older databases) and `postgresDriver` (what the driver's connection provides, such as interactive transactions) imported from `@prisma/orm-postgres/config`. The list must not be empty and nothing is added to it; filter a key out to stop requiring it. After changing the list, run `prisma contract emit` and commit the migration snapshot it updates, then sign each existing database again with `prisma db sign --no-advance-ref`, since its signature records the old list. 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
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 database package detects the `.ts` extension and routes through the TS provider. On PostgreSQL, `defineContract` takes `requiredCapabilities: [...postgres18, ...postgresDriver]` the same way, imported from `@prisma/orm-postgres/contract-builder`. 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
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 database package 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
|
|
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/config` 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 { defineConfig as ormConfig, postgres18, postgresDriver } from '@prisma/orm-postgres/config';
|
|
55
|
-
import { definePrismaConfig } from '
|
|
55
|
+
import { definePrismaConfig } from 'prisma/config';
|
|
56
56
|
|
|
57
57
|
export default definePrismaConfig({
|
|
58
58
|
orm: ormConfig({
|
|
@@ -170,7 +170,7 @@ Values the client generates are written `@onCreate(fn())` and `@onUpdate(fn())`:
|
|
|
170
170
|
|
|
171
171
|
In the TS builder, an alias is a constant passed as the field, because field builders are immutable: `const Slug = field.column(type.String({ storage: 'varchar', length: 64 }))`, `const UpdatedAt = field.column(type.TimestampString(3)).onCreate(gen.now()).onUpdate(gen.now())`, then `slug: Slug, updatedAt: UpdatedAt.default(now())`. `type.*` has a helper for every PSL type constructor, and the contributed aliases are `type.temporal.CreatedAt()`, `type.temporal.UpdatedAt()` and the identifier aliases such as `type.Ulid()` (`type.sql.Ulid()` on every SQL target), used as `field.column(type.temporal.UpdatedAt())` and `field.column(type.Ulid()).id().onCreate(gen.ulid())`. A definition has no `types` key (`CONTRACT.TYPES_KEY_REMOVED`), and `field.namedType(...)` takes only an enum handle.
|
|
172
172
|
|
|
173
|
-
Note: scalar lists (e.g. `String[]`) are gated on the
|
|
173
|
+
Note: scalar lists (e.g. `String[]`) are gated on the contract requiring `db.scalarList`, which `postgres15` to `postgres18` include, so `tags String[]` lowers to an array column (with a generated no-NULL-elements check; write `tags String?[]` for a list whose elements may be null, which gets no such check); SQLite's list does not, and SQLite rejects the field with `PSL_SCALAR_LIST_UNSUPPORTED_TARGET`. Implicit Prisma-ORM many-to-many (list navigation on both sides without a join model) is rejected by the SQL interpreter — declare the join model explicitly and the ORM traverses it for you (`references/queries.md`). Composite/embeddable types (`type Address { ... }` with `address Address` on a model) are supported: the interpreter lowers them to storage value objects, at `storage.namespaces.<ns>.entries.valueObject`, and stores them as `jsonb` columns. See *Workflow — Value objects* below.
|
|
174
174
|
|
|
175
175
|
## Workflow — Edit a model / field / relation (TS builder)
|
|
176
176
|
|
|
@@ -211,7 +211,7 @@ The concept: an extension contributes a namespace (`pgvector.*`) plus two descri
|
|
|
211
211
|
|
|
212
212
|
```typescript
|
|
213
213
|
import 'dotenv/config';
|
|
214
|
-
import { definePrismaConfig } from '
|
|
214
|
+
import { definePrismaConfig } from 'prisma/config';
|
|
215
215
|
import pgvector from '@prisma/orm-extension-pgvector/control';
|
|
216
216
|
import { defineConfig as ormConfig, postgres18, postgresDriver } from '@prisma/orm-postgres/config';
|
|
217
217
|
|
|
@@ -480,7 +480,7 @@ The concept: the Supabase extension provides the `supabase` contract space (the
|
|
|
480
480
|
`prisma.config.ts` (mirrors `examples/supabase/prisma.config.ts`):
|
|
481
481
|
|
|
482
482
|
```typescript
|
|
483
|
-
import { definePrismaConfig } from '
|
|
483
|
+
import { definePrismaConfig } from 'prisma/config';
|
|
484
484
|
import supabasePack from '@prisma/orm-extension-supabase/pack';
|
|
485
485
|
import { defineConfig as ormConfig, postgres18, postgresDriver } from '@prisma/orm-postgres/config';
|
|
486
486
|
|
|
@@ -541,7 +541,7 @@ Infer captures indexes at full fidelity — expression, partial (`where:`), uniq
|
|
|
541
541
|
## Checklist
|
|
542
542
|
|
|
543
543
|
- [ ] Read `prisma.config.ts` and identified the contract source (path string ending in `.prisma` or `.ts`) and the installed `extensions: [...]`.
|
|
544
|
-
- [ ] 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
|
|
544
|
+
- [ ] 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/config`. No imports from `@prisma/orm-framework`, `@prisma/orm-family-*`, `@prisma/orm-target-*` or `@prisma/orm-toolchain` in user files.
|
|
545
545
|
- [ ] Edited the contract source (`contract.prisma` or `contract.ts`), not an emitted artefact.
|
|
546
546
|
- [ ] 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
547
|
- [ ] `prisma.config.ts` is the envelope form — `definePrismaConfig({ orm: ormConfig({...}) })` — not a flat `defineConfig({...})`.
|
|
@@ -49,7 +49,7 @@ Every code is a dotted `NAMESPACE.SUBCODE`; the namespace is the prefix (`CONFIG
|
|
|
49
49
|
{ name: 'RuntimeError', code: 'BUDGET.TIME_EXCEEDED', category: 'BUDGET', severity: 'error', message: '...', details: { ... } }
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
`category` is the prefix of `code` (`PLAN`, `CONTRACT`, `LINT`, `BUDGET`, `RUNTIME`, `ORM`, …). `details` holds the structured context (`details` is the runtime envelope's equivalent of the CLI envelope's `meta`). Recognise
|
|
52
|
+
`category` is the prefix of `code` (`PLAN`, `CONTRACT`, `LINT`, `BUDGET`, `RUNTIME`, `ORM`, …). `details` holds the structured context (`details` is the runtime envelope's equivalent of the CLI envelope's `meta`). Recognise a thrown runtime error with `isStructuredError`, imported from the database package's `runtime` (`import { isStructuredError } from '@prisma/orm-postgres/runtime'`), and match on `error.code` — never `instanceof`. The CLI envelope is JSON output, with `summary` and no `message`, so `isStructuredError` does not recognise it; a script reads `code` from the parsed JSON instead.
|
|
53
53
|
|
|
54
54
|
**3. SQL driver errors** — surface as `SqlQueryError` / `SqlConnectionError` (see `packages/2-sql-family/1-core/errors/`). Fields on `SqlQueryError`: `kind: 'sql_query'`, `sqlState` (Postgres SQLSTATE, e.g. `'23505'`), `constraint`, `table`, `column`, `detail`, `cause`. These carry no dotted code — route on `sqlState` and the constraint metadata. SQL driver errors are typically wrapped by middleware before reaching the user, but raw-SQL paths can surface them directly.
|
|
55
55
|
|
|
@@ -84,18 +84,18 @@ The single source of truth: read the envelope, find the row by `code`, follow th
|
|
|
84
84
|
| `CONTRACT.VALIDATION_FAILED` | `contract emit`, `db *` | Re-run `pnpm prisma contract emit` after fixing the contract source named in `where.path`; `meta.errors` lists the issues. See `references/contract.md`. |
|
|
85
85
|
| `CONFIG.DB_CONNECTION_REQUIRED` | `db *`, `db migrate`, `migration status` | Pass `--db <url>` or set `db.connection` in `prisma.config.ts`. |
|
|
86
86
|
| `CONFIG.MISSING_EXTENSION_PACKS` | `contract emit` (e.g. contract uses `pgvector.Vector(...)` but config does not list the pgvector descriptor) | Add the descriptors named in `meta.missingExtensionPacks` to `extensions` in `prisma.config.ts`. See `references/contract.md`. |
|
|
87
|
-
| `MIGRATION.PLANNING_FAILED` | `db init`, `db update`, `migration plan` | Inspect `meta.conflicts`. Recovery is per-conflict — chain to `references/migrations.md`. When `migration plan` raises it for a first migration whose contract describes nothing to create (conflict kind `nothingToCreate`), the conflict's `why` gives the next step: `migration new`, with the operations written by hand. A plan from an earlier contract with no operations is not refused: it is written, and `db migrate` moves the
|
|
87
|
+
| `MIGRATION.PLANNING_FAILED` | `db init`, `db update`, `migration plan` | Inspect `meta.conflicts`. Recovery is per-conflict — chain to `references/migrations.md`. When `migration plan` raises it for a first migration whose contract describes nothing to create (conflict kind `nothingToCreate`), the conflict's `why` gives the next step: `migration new`, with the operations written by hand. A plan from an earlier contract with no operations is not refused: it is written, and `db migrate` moves the contract signature. |
|
|
88
88
|
| `CLI.INIT_MISSING_FLAGS` / `CLI.INIT_INVALID_FLAG_VALUE` / `CLI.INIT_REINIT_NEEDS_FORCE` / `CLI.INIT_*` | `prisma orm init` | Re-run with the flags listed in `meta.missingFlags` or `meta.allowed`; a re-init needs `--confirm <directory name>`. `CLI.INIT_INSTALL_FAILED` (exit 4) and `CLI.INIT_EMIT_FAILED` (exit 5) are findings on a completed scaffold — the files are on disk; fix and re-run the named step. |
|
|
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
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
|
-
| `CONTRACT.
|
|
95
|
-
| `CONTRACT.
|
|
94
|
+
| `CONTRACT.SIGNATURE_MISSING` | `db verify` (`error` diagnostic, exit 4), runtime startup (warning) | DB has no signature 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
|
+
| `CONTRACT.SIGNATURE_MISMATCH` | `db verify` (exit 4), runtime startup (warning) | Signature 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`. |
|
|
96
96
|
| `CONTRACT.TARGET_MISMATCH` | `db verify`, runtime startup | Contract target ≠ config target; align them (see `meta.expected` / `meta.actual`). |
|
|
97
97
|
| `CONTRACT.SCHEMA_VERIFICATION_FAILED` | `db verify`, `db sign` (both exit 4 with the finding) | Live schema does not satisfy the contract; `meta.schemaIssues` lists the schema diff issues per `meta.space`, in the same shape as `MIGRATION.SCHEMA_VERIFY_FAILED`. Run `db update` to reconcile, or adjust the contract. |
|
|
98
|
-
| `MIGRATION.SCHEMA_VERIFY_FAILED` | `db migrate`, `db update`, `db init` | The schema after apply does not satisfy the contract; the
|
|
98
|
+
| `MIGRATION.SCHEMA_VERIFY_FAILED` | `db migrate`, `db update`, `db init` | The schema after apply does not satisfy the contract; the signature stays at its origin, and on SQL targets the apply rolled back (on MongoDB the operations that ran stay applied). `meta.schemaIssues` lists the issues and `why` names them. Change the contract source to resolve them, re-emit, and re-run; `db migrate` also says how to plan the failed migration again. |
|
|
99
99
|
| `MIGRATION.PRECHECK_FAILED` | `db migrate`, `db update`, `db init` | An operation's check before it ran did not hold (`meta.failedCheck`); the apply rolled back on SQL targets. `meta.rowsWithoutValue` is set when a field becoming required has rows with no value. Follow `nextActions`. |
|
|
100
100
|
| `CLI.CONSENT_REQUIRED` | `migration plan` / `db update` when a plan would lose data (or, on `db update`, widen access) and nobody can answer (`--no-interactive`, CI, `--yes`) | `meta.unanswered[]` and `nextActions` list each question with its flags. Re-run with `--delete <subject>`, `--rename <subject>:<new name>` or `--allow <Model>` as each subject means. `--confirm` and `--yes` answer none of them. `db migrate` does not ask. |
|
|
101
101
|
| `CLI.CONSENT_UNUSED` | `migration plan` / `db update` | Every question was answered, and a `--delete` or `--allow` was left over: a typo, a subject the plan does not touch, or a `--confirm` (which consents to nothing). Fix or drop the flag. A typo next to a question nobody answered is reported as `CLI.CONSENT_REQUIRED` instead, which names the flag that matched nothing. On `db update --dry-run` the same mistake is `MIGRATION.STATEMENT_ANSWERS_NO_QUESTION`. |
|
|
@@ -103,14 +103,14 @@ The single source of truth: read the envelope, find the row by `code`, follow th
|
|
|
103
103
|
| `MIGRATION.NO_INVARIANT_PATH` / `MIGRATION.UNKNOWN_INVARIANT` | `db migrate` | Concurrent-migration and invariant flows — `references/migration-review.md`. |
|
|
104
104
|
| `DRIVER.NOT_CONNECTED` with message `Runtime is closed` | A query, prepared statement or `db.runtime().connection()` that starts after `db.close()` and after the runtime was idle for one turn of the event loop, or after the `await using` scope that held a serverless connection ended | The work started after the runtime closed. Almost always it is a lazy read (`db.orm...all()`, `db.query(...)`) returned without `await`, which starts only when the caller awaits it, or work that waited on something other than the database first. Write `return await ...`, or move the call before `close()`. See `references/runtime.md` § *Workflow — Serverless and per-request runtimes*. |
|
|
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
|
-
| `MIGRATION.
|
|
106
|
+
| `MIGRATION.SIGNATURE_NOT_IN_GRAPH` | `db migrate`, `db migrate --show`, a Composer deploy | The database's signature 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 signature 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, follow its advice: apply the migrations on disk that already lead to the target with `db migrate`, or author one (with `migration plan`, or with `migration new` when the database is already at the target and lacks only invariants) and apply it with `db migrate`. See `references/migrations.md` § *Policies*. |
|
|
108
108
|
| `MIGRATION.DATA_PROTECTION_FORBIDS` | `db update`, `db migrate`, `migration plan --to <ref>`, a Composer deploy | The database's data protection policy (or the ref's, for `migration plan --to <ref>` and a run given `--permit-policy-change`) 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. For `db update` and `migration plan`, a refused data loss: state a `--rename` if it was only a rename, plan a type change with `migration plan --convert`, or keep the model or field. A refused access change: keep the contract's access rules as they are. For `db migrate`, first find out whether another database has applied the refused migration; if one has, keep it as it is and tell the user that this database cannot run it. If none has, delete it and every later migration no database has applied, and plan once from where the first one started, with `--rename`, `--convert`, or after putting back in the contract what it removes; never only take the operation out of the migration. The full steps (saving hand-written operations, `--from`, `contract emit`, moving refs) are in `references/migrations.md` § *Policies*. For `db migrate` and `db update`, an operation in an extension's contract space belongs to the extension: do not edit or delete its migration; ask the extension's author for a version without the operation, and tell the user. `--delete` and `--allow` do not help. Never change a database's or a ref's policy to make a deploy pass, and never suggest that anyone does. See `references/migrations.md` § *Policies*. |
|
|
109
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, and nothing runs while they differ. The error says to report the difference to whoever owns the database: tell the user. Never change the ref's or the database's policies to make them match, and never suggest that anyone does. See `references/migrations.md` § *Policies*. |
|
|
110
|
-
| `MIGRATION.PATH_UNREACHABLE` | `db migrate`, a Composer deploy | The
|
|
110
|
+
| `MIGRATION.PATH_UNREACHABLE` | `db migrate`, a Composer deploy | The signature is in the graph but no migration reaches the target from it. Run the two commands the error prints: a `migration plan --from <contract>`, 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. To the emitted contract, `--from` is where the history that continues from the signature ends, so the new migration extends the history instead of forking it; to any other target it is the signature. On an empty database, `--from` is where the migration history ends. When the history has more than one end, the error names each end for you to choose from. A database with no signature in a project with no migrations gets the plan from `@empty` as a choice: run it only on an empty database, and adopt one that already has tables with `db sign` first. When the path ends at the empty contract (`--to @empty`), or the project has migrations and the path starts at a contract none of them records, no plan can author it, and the error prints only `migration list`. In a project with no migrations yet, the plan starts from the ref that names the database's contract, and with no such ref the error prints no plan and says why. 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. |
|
|
111
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*. |
|
|
112
|
-
| `MIGRATION.MISSING_INVARIANTS` | `migration status` `warn` diagnostic (exit 0) | The live
|
|
113
|
-
| `MIGRATION.
|
|
112
|
+
| `MIGRATION.MISSING_INVARIANTS` | `migration status` `warn` diagnostic (exit 0) | The live signature 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`. |
|
|
113
|
+
| `MIGRATION.SIGNATURE_NOT_IN_GRAPH` / `CONTRACT.UNREADABLE` | `migration status` `warn` diagnostics (exit 0) | Read `severity` *and* `code`. Up-to-date / pending / no-signature states are not codes — read `spaces[].currentContract` and `migrations[].status` in the `--json` document. `references/migration-review.md` covers the signature-out-of-history flow. |
|
|
114
114
|
| `BUDGET.ROWS_EXCEEDED` / `BUDGET.TIME_EXCEEDED` | Runtime, when the `budgets` middleware is active | Tune `budgets({ maxRows, maxLatencyMs, ... })` or rewrite the query. See `references/runtime.md`. |
|
|
115
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`. |
|
|
116
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. |
|
|
@@ -130,8 +130,8 @@ If the envelope's `code` is not in this table, follow the envelope's `fix` field
|
|
|
130
130
|
1. **Reading only `summary`, not the rest of the envelope.** `code`, `severity`, `why`, `fix`, `meta`/`details`, and (for CLI errors) `where` all carry information the recovery depends on. The agent routes on `code`; the user sees `summary`.
|
|
131
131
|
2. **Ignoring `severity`.** `migration status` emits warn-level diagnostics and **exits 0**. An agent that only checks exit code misses every concurrent-migration warning.
|
|
132
132
|
3. **Matching `MIGRATION.RUNNER_FAILED`.** That code no longer exists: an apply failure carries the runner's own code, and its facts are in typed `meta` keys.
|
|
133
|
-
4. **Treating drift as something to silence with `db sign`.** `db sign` writes the
|
|
134
|
-
5. **Re-running `db migrate` after a partial failure without inspecting state.** `db schema --db <url>` shows the live shape; `migration status --db <url> --json` shows where the
|
|
133
|
+
4. **Treating drift as something to silence with `db sign`.** `db sign` writes the contract signature from the current contract hash and, by default, advances the `db` ref to it (`--no-advance-ref` skips the ref), but it requires schema verification to pass first. Run `db verify` before reaching for `db sign`.
|
|
134
|
+
5. **Re-running `db migrate` after a partial failure without inspecting state.** `db schema --db <url>` shows the live shape; `migration status --db <url> --json` shows where the signature actually is.
|
|
135
135
|
|
|
136
136
|
## What Prisma 8 doesn't do yet
|
|
137
137
|
|
|
@@ -28,12 +28,12 @@ The on-disk migrations under `migrations/<space>/` form a directed graph. **Each
|
|
|
28
28
|
Consequences worth internalising:
|
|
29
29
|
|
|
30
30
|
- **No node is privileged.** There is no "current" node, no HEAD, no special tip the planner chains from. Multiple branch tips are legal (two migrations planned off the same node). Cycles are legal (a rollback edge back to an earlier hash creates one).
|
|
31
|
-
- **The graph does not know where your database is.** "Where is my database" is answered by the database's **
|
|
31
|
+
- **The graph does not know where your database is.** "Where is my database" is answered by the database's **contract signature** (a live-DB record of "this database is at hash X") and, offline, by **refs**. Never by the graph.
|
|
32
32
|
- **The graph does not know where your next migration should start.** The planner has to be told an origin. That is the entire job of refs and `--from`.
|
|
33
33
|
|
|
34
34
|
### What a migration may contain
|
|
35
35
|
|
|
36
|
-
Because a migration is an edge, `db migrate` can run it on any database whose
|
|
36
|
+
Because a migration is an edge, `db migrate` can run it on any database whose contract signature is at its `from` hash, however that database got there: created by `db init`, adopted with `db sign`, restored from a backup, or brought along a different path through the graph. Those databases share a schema but not their rows, so every operation must be correct on any of them. A schema change tests the live schema before and after it runs. Most operation factories do this for you, but not all: on Postgres, `createNativeEnumType` and `dropNativeEnumType` emit no checks. A `rawSql` DDL step you write must carry its own precheck and postcheck. A data change is a data transform; on Postgres and Mongo its `check` decides on each database whether there is work to do. `references/migrations.md` § *Data changes go in a data transform* gives the rule, the reason, and what each target checks.
|
|
37
37
|
|
|
38
38
|
### Refs — version-controlled pointers
|
|
39
39
|
|
|
@@ -60,21 +60,21 @@ A ref's `policies` are read and written with `migration ref policy show`, `set`
|
|
|
60
60
|
|
|
61
61
|
| Command | Ref advancement |
|
|
62
62
|
|---|---|
|
|
63
|
-
| `db init` / `db update`
|
|
64
|
-
| `db sign` | Advances `db` after a successful signature (override the name with `--advance-ref <name>`; `--no-advance-ref` skips it, writing no ref and no snapshot); an existing ref is overwritten and the previous hash is reported in the human output (the JSON `advancedRefs` lists `{ space, name, hash }` for each contract space it advanced). `--db`
|
|
63
|
+
| `db init` / `db update` | Advance `db` when the connection comes from `prisma.config.ts` and the CLI does not detect CI, by the same rule as `db migrate` below: never when `--db` is passed without `--advance-ref`, regardless of the URL (even `--db $DATABASE_URL` pointing at the default database), and never in CI (the run then reports `MIGRATION.REF_NOT_ADVANCED_IN_CI`). `--advance-ref <name>` advances that ref instead, in every case; `--no-advance-ref` advances none. A ref that cannot be written is a warning (`MIGRATION.REF_NOT_WRITTEN`), not a failure; its next action is the command the warning prints: `migration ref set` when a migration ends at that contract, otherwise the run's command with `--advance-ref <name>` and without its statements (`--rename`, `--delete`, `--allow`), which applies nothing if the contract has not changed since. Without a ref they also store no snapshot, which a later `db update --rename` needs |
|
|
64
|
+
| `db sign` | Advances `db` after a successful signature (override the name with `--advance-ref <name>`; `--no-advance-ref` skips it, writing no ref and no snapshot); an existing ref is overwritten and the previous hash is reported in the human output (the JSON `advancedRefs` lists `{ space, name, hash }` for each contract space it advanced). `--db` and CI do **not** suppress it, unlike init/update/migrate: sign never mutates the schema, and adoption is normally done via `--db` |
|
|
65
65
|
| `db migrate` | Advances `db` after a successful apply when the connection comes from `prisma.config.ts` and the CLI does not detect CI. Never with `--db`, and never in CI (unless the `CI` environment variable is `false`, which turns detection off whatever else is set, the CLI detects CI when `CI` is set or when a variable that CI services set is present, such as `BUILD_NUMBER`, `BUILD_ID` or `GITHUB_ACTIONS`; the run then reports `MIGRATION.REF_NOT_ADVANCED_IN_CI`), so deploys and pipelines write no ref. `--advance-ref <name>` advances that ref instead, in every case; `--no-advance-ref` advances none. A run that ends at the empty contract, which a ref cannot name, leaves `db` unchanged and, when `db` exists and the run passes neither `--db` nor `--no-advance-ref`, warns (`MIGRATION.REF_NOT_ADVANCED_TO_EMPTY`; when that database is your development database, remove the stale ref with `migration ref delete db`), and refuses an explicit `--advance-ref` before applying. A ref that cannot be written is a warning (`MIGRATION.REF_NOT_WRITTEN`), not a failure: the migrations have already applied |
|
|
66
66
|
| `migration plan` | Never advances anything — chaining discipline is yours |
|
|
67
|
-
| deploys (Composer / CD) | Write the database's
|
|
67
|
+
| deploys (Composer / CD) | Write the database's contract signature; structurally cannot and do not touch repo refs |
|
|
68
68
|
|
|
69
69
|
### How `migration plan` picks its origin
|
|
70
70
|
|
|
71
71
|
`migration plan` resolves its origin in exactly this order:
|
|
72
72
|
|
|
73
|
-
1. Explicit `--from <ref-name | hash | hash-prefix | migration-dir | migration-dir^ | @empty>` — `@empty` names the empty database deliberately. The reserved forms `@db` and `@contract` exist in the shared ref grammar but do not resolve here: `migration plan` is offline, so `@db` (the live
|
|
73
|
+
1. Explicit `--from <ref-name | hash | hash-prefix | migration-dir | migration-dir^ | @empty>` — `@empty` names the empty database deliberately. The reserved forms `@db` and `@contract` exist in the shared ref grammar but do not resolve here: `migration plan` is offline, so `@db` (the live contract signature) has nothing to read, and `@contract` needs a contract hash the plan resolver does not pass. Use them with `db migrate --show` / `migration status`, not with `plan`.
|
|
74
74
|
2. No `--from` → the `db` ref (`migrations/app/refs/db.json`).
|
|
75
75
|
3. No `db` ref → **greenfield: the plan starts from the empty database.** On an empty graph the human output adds a muted notice beneath the summary — `No db ref set — planning from an empty database. Run db init, db update, or db sign if a database already exists.` — and the JSON document carries `fromDefaulted: true`, so this case is distinguishable from an explicit `--from @empty`.
|
|
76
76
|
|
|
77
|
-
It is **offline** — it never consults a database, never reads a
|
|
77
|
+
It is **offline** — it never consults a database, never reads a signature (which is why `--from @db` is not an option here). Whatever the refs on disk say is what it believes. The destination defaults to the emitted `contract.json` (`--to` overrides).
|
|
78
78
|
|
|
79
79
|
When the origin came from the `db` ref by default and that node **already has an outgoing migration**, the plan still succeeds but warns: planning from there forks the graph. Pass `--from` to name the origin deliberately if that is what you want.
|
|
80
80
|
|
|
@@ -86,7 +86,7 @@ The human output names the resolved origin on its `from:` line. **`from: (baseli
|
|
|
86
86
|
|
|
87
87
|
## The trap — a greenfield plan over existing migrations
|
|
88
88
|
|
|
89
|
-
**A plan whose origin is the empty contract while migrations already exist on disk is almost always a mistake.** A full-create migration cannot do what you meant: a database that has the prior migrations applied refuses it (`MIGRATION.PATH_UNREACHABLE` — no path from its
|
|
89
|
+
**A plan whose origin is the empty contract while migrations already exist on disk is almost always a mistake.** A full-create migration cannot do what you meant: a database that has the prior migrations applied refuses it (`MIGRATION.PATH_UNREACHABLE` — no path from its contract signature to the new plan's destination), and running its create statements against any populated schema fails outright. The CLI refuses this at plan time: when origin resolution falls all the way through (no `--from`, no `db` ref) and migrations exist, `migration plan` stops with `MIGRATION.PLAN_ORIGIN_UNKNOWN` instead of writing the package — the error's suggestions are the three exits below; do not reflexively take the `--from @empty` one, pick by intent.
|
|
90
90
|
|
|
91
91
|
How the fall-through happens: a project whose only commands run in CI or deploys (the deploy-first path below) never acquires a `db` ref, so *every* default plan resolves to the empty origin. Running the dev loop with an explicit `--db` has the same effect: `db init`, `db update` and `db migrate` with that flag never advance the ref, whatever URL it carries (`db sign` is the exception — it advances the ref with or without `--db`). The first time that is correct (it is the baseline; an empty migration graph plans with only the muted notice); every later time it is the trap the refusal catches.
|
|
92
92
|
|
|
@@ -117,7 +117,7 @@ Full mechanics, refusals, and recovery: `references/migrations.md` § *Dev → s
|
|
|
117
117
|
|
|
118
118
|
## Workflow — the deploy-first loop (Composer / CD-managed databases)
|
|
119
119
|
|
|
120
|
-
The concept: the deploy pipeline owns the databases, so `db init` / `db update` never run, `db migrate` runs only in CI or with `--db`, and nothing ever advances a `db` ref for you. Deploys replay each database from its
|
|
120
|
+
The concept: the deploy pipeline owns the databases, so `db init` / `db update` never run, `db migrate` runs only in CI or with `--db`, and nothing ever advances a `db` ref for you. Deploys replay each database from its contract signature to the contract emitted at build time; they never write to `migrations/app/refs/`. Two disciplines keep this loop safe:
|
|
121
121
|
|
|
122
122
|
**Author the baseline before the first deploy.** Before anything is deployed:
|
|
123
123
|
|
|
@@ -127,7 +127,7 @@ pnpm prisma migration plan --name init # from: (baseline) — intended, thi
|
|
|
127
127
|
git add migrations/ && git commit
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
This is the one intended greenfield plan. With the baseline committed, the deployed database's
|
|
130
|
+
This is the one intended greenfield plan. With the baseline committed, the deployed database's signature always corresponds to a graph node, and every later state is reachable by planned migrations.
|
|
131
131
|
|
|
132
132
|
**Chain every later plan from the last shipped contract.** Nothing advances refs in this loop, so either keep the `db` ref current yourself — after each plan, `migration ref set db <new-migration-to-hash>` (the hash is a graph node as soon as the plan is written; `migration list` shows it) — or pass `--from <last-migration-dir>` on every plan. Committing the ref together with the migration keeps teammates' default plans chaining correctly too.
|
|
133
133
|
|
|
@@ -135,7 +135,7 @@ If you skip the chaining, the next default plan resolves to greenfield: the trap
|
|
|
135
135
|
|
|
136
136
|
## Workflow — adopt a pre-existing database
|
|
137
137
|
|
|
138
|
-
The concept: a database that predates Prisma 8 enters the system by describing it, not migrating it — `contract infer` derives the contract from the live schema, and after review + `contract emit`, `db sign` records the
|
|
138
|
+
The concept: a database that predates Prisma 8 enters the system by describing it, not migrating it — `contract infer` derives the contract from the live schema, and after review + `contract emit`, `db sign` records the contract signature. Full recipe: `references/quickstart.md` § *Brownfield-DB*.
|
|
139
139
|
|
|
140
140
|
```bash
|
|
141
141
|
pnpm prisma contract infer --db "$DATABASE_URL" --output src/prisma/contract.prisma
|
|
@@ -148,9 +148,9 @@ By default `db sign` sets the `db` ref to the signed contract's hash and stores
|
|
|
148
148
|
|
|
149
149
|
## Workflow — retrofit a database that has no on-disk migrations
|
|
150
150
|
|
|
151
|
-
The concept: the database exists and its
|
|
151
|
+
The concept: the database exists and its contract signature is accurate (hash **M**) — it was built by `db update` or signed with `db sign` in another checkout, or built by a deploy pipeline — but the migration graph doesn't reach M. (A database adopted with `db sign` in *this* checkout already has its ref set; retrofit is for the case where the ref was never set here.) The goal is to **make the graph reach the signature's hash**: once a baseline `null → M` exists, applying against the marked database is clean by construction — the runner starts at the signature, so the baseline never executes; only real deltas past M run.
|
|
152
152
|
|
|
153
|
-
- **It's your dev database.** Run `db update` (default URL; no-op on the DB when the contract already matches) — it advances the `db` ref and stores the contract snapshot
|
|
153
|
+
- **It's your dev database.** Run `db update` (default URL; no-op on the DB when the contract already matches) — outside CI it advances the `db` ref and stores the contract snapshot; with `--db` or in CI it does neither unless you pass `--advance-ref db`. The next `migration plan` auto-emits the baseline plus your delta. This is just the dev loop's dev → ship transition.
|
|
154
154
|
- **It's a deployed database you must not touch.** Build the baseline offline, at the deployed contract state:
|
|
155
155
|
1. Bring the contract source back to the deployed state (check out the deployed revision of the contract file, or stash your edits), then `contract emit`.
|
|
156
156
|
2. `migration plan --name baseline` — greenfield, intended: one bundle `null → M`. Confirm its `to` matches the database (`db verify --db "$URL"` is clean at this revision).
|
|
@@ -162,8 +162,8 @@ The concept: the database exists and its marker is accurate (hash **M**) — it
|
|
|
162
162
|
## Common Pitfalls
|
|
163
163
|
|
|
164
164
|
1. **Assuming `migration plan` or `migration new` chains from the newest migration on disk.** Neither does. The origin is `--from`, else the `db` ref. With neither, only an empty graph plans from scratch (with the muted `No db ref set` notice); once migrations exist, both commands refuse with `MIGRATION.PLAN_ORIGIN_UNKNOWN`.
|
|
165
|
-
2. **Expecting `migration plan`, or `db migrate` with `--db` or in CI, to keep the `db` ref current.** None of them touches refs. `db init`, `db update` and `db migrate` advance `db` only when the connection comes from `prisma.config.ts`
|
|
166
|
-
3. **Expecting a deploy to update refs.** Deploys write the database's
|
|
165
|
+
2. **Expecting `migration plan`, or `db migrate` with `--db` or in CI, to keep the `db` ref current.** None of them touches refs. `db init`, `db update` and `db migrate` advance `db` only when the connection comes from `prisma.config.ts` and the CLI does not detect CI; `db sign` advances it even with `--db`. Elsewhere, pass `--advance-ref db`.
|
|
166
|
+
3. **Expecting a deploy to update refs.** Deploys write the database's contract signature; the files under `migrations/app/refs/` only change when you change them.
|
|
167
167
|
4. **Reading `from: (baseline)` as informational.** Over a non-empty migrations directory it is the trap announcing itself. Stop and pick an exit before applying or committing.
|
|
168
168
|
5. **`migration ref set` with a hash no on-disk migration produces.** A ref target must be the `to` hash of an on-disk migration bundle. A hash outside the graph is refused (`MIGRATION.HASH_NOT_IN_GRAPH`); a from-only graph node is refused with `MIGRATION.REF_SET_BUNDLE_NOT_FOUND`, whose fix text points at fixtures and is unhelpful here. Either way: plan the edge whose `to` is the hash first (baseline or delta), then set the ref.
|
|
169
169
|
6. **Treating `db` as reserved.** It's a naming default. Setting it yourself is fine and sometimes exactly right (deploy-first chaining, retrofit); just expect dev commands on the config's database (`db init`, `db update`, and `db migrate` outside CI) to overwrite it.
|
|
@@ -179,6 +179,6 @@ The concept: the database exists and its marker is accurate (hash **M**) — it
|
|
|
179
179
|
- [ ] Read the plan output's `from:` line and confirmed it names that origin — not `(baseline)` over an existing graph.
|
|
180
180
|
- [ ] In a deploy-first project: baseline authored and committed before the first deploy; every later plan chained via the `db` ref or `--from`.
|
|
181
181
|
- [ ] After each plan in a loop where nothing advances refs: advanced the `db` ref (`migration ref set db <to-hash>`) or resolved to pass `--from` next time.
|
|
182
|
-
- [ ] For a marked database with no on-disk migrations: made the graph reach the
|
|
183
|
-
- [ ] Expected plain `db migrate` to advance `db` only when
|
|
182
|
+
- [ ] For a marked database with no on-disk migrations: made the graph reach the contract signature's hash (auto-baseline via `db update` or `db sign`, or an offline baseline plan) before planning deltas.
|
|
183
|
+
- [ ] Expected plain `db init`, `db update` and `db migrate` to advance `db` only when the connection comes from `prisma.config.ts`, the CLI does not detect CI and neither `--advance-ref` nor `--no-advance-ref` is passed; expected `--advance-ref <name>` to advance `<name>` with `--db` and in CI too; did NOT expect `migration plan`, or any of them with `--db` or in CI and without `--advance-ref`, to advance any ref.
|
|
184
184
|
- [ ] Did NOT apply or commit a `from: (baseline)` plan without confirming the empty origin was the intent.
|