@prisma/orm-sqlite 8.0.0-rc.20-dev.13 → 8.0.0-rc.20-dev.15

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.
@@ -1,5 +1,5 @@
1
1
  import sqlitePackRef from "@prisma/orm-target-sqlite/target/pack";
2
- import { ComposedAuthoringHelpers, ComposedAuthoringHelpers as ComposedAuthoringHelpers$1, ContractDefinition, ContractInput, ContractInput as ContractInput$1, ContractModelBuilder, EnumTypeHandle, FieldNode, ForeignKeyNode, IndexNode, MergeEnums, ModelLike, ModelLike as ModelLike$1, ModelNode, PrimaryKeyNode, RelationNode, ScalarFieldBuilder, SqlExpression, UniqueConstraintNode, autoincrement, buildBoundContract, field, member, model, now, rel, sql } from "@prisma/orm-family-sql/contract-ts/contract-builder";
2
+ import { ComposedAuthoringHelpers, ComposedAuthoringHelpers as ComposedAuthoringHelpers$1, ContractDefinition, ContractInput, ContractInput as ContractInput$1, ContractModelBuilder, EnumTypeHandle, FieldNode, ForeignKeyNode, IndexNode, MergeEnums, ModelLike, ModelLike as ModelLike$1, ModelNode, PrimaryKeyNode, RelationNode, ScalarFieldBuilder, SqlExpression, UniqueConstraintNode, autoincrement, buildBoundContract, member, model, now, rel, sql } from "@prisma/orm-family-sql/contract-ts/contract-builder";
3
3
  import { sqliteAdapterContractContributions } from "@prisma/orm-target-sqlite/adapter/adapter";
4
4
  import sqlFamilyPack from "@prisma/orm-family-sql/family/pack";
5
5
  import "@prisma/orm-framework/components/authoring";
@@ -212,11 +212,22 @@ declare const enumType: BoundEnumType<{
212
212
  }, "traits" | "output" | "input">;
213
213
  }>;
214
214
  //#endregion
215
+ //#region src/contract/field.d.ts
216
+ type SqliteHelpers = ComposedAuthoringHelpers$1<typeof sqlFamilyPack, typeof sqlitePackRef, undefined>;
217
+ /**
218
+ * The field builders of the `defineContract` callback for SQLite, without extensions: `field.column(type.DateTime())`. Use it outside a contract, for example to declare the fields of a query fragment.
219
+ */
220
+ declare const field: SqliteHelpers['field'];
221
+ /**
222
+ * The type constructors and type aliases of the `defineContract` callback for SQLite, without extensions, for `field.column(...)`: `type.DateTime()`, `type.sql.Ulid()`, `type.temporal.CreatedAt()`.
223
+ */
224
+ declare const type: SqliteHelpers['type'];
225
+ //#endregion
215
226
  //#region src/contract/gen.d.ts
216
227
  /**
217
228
  * The generator function calls of the `defineContract` callback for SQLite, built from the same family and target packs, for `.onCreate(...)` and `.onUpdate(...)`: `gen.now()`, `gen.uuid(7)`, `gen.cuid(2)`, `gen.ulid()`, `gen.nanoid(16)` and `gen.ksuid()`.
218
229
  */
219
230
  declare const gen: ComposedAuthoringHelpers$1<typeof sqlFamilyPack, typeof sqlitePackRef, undefined>['gen'];
220
231
  //#endregion
221
- export { type ComposedAuthoringHelpers, type ContractDefinition, type ContractInput, type ContractModelBuilder, type FieldNode, type ForeignKeyNode, type IndexNode, type ModelLike, type ModelNode, type PrimaryKeyNode, type RelationNode, type ScalarFieldBuilder, type SqlExpression, type UniqueConstraintNode, autoincrement, defineContract, enumType, field, gen, member, model, now, rel, sql };
232
+ export { type ComposedAuthoringHelpers, type ContractDefinition, type ContractInput, type ContractModelBuilder, type FieldNode, type ForeignKeyNode, type IndexNode, type ModelLike, type ModelNode, type PrimaryKeyNode, type RelationNode, type ScalarFieldBuilder, type SqlExpression, type UniqueConstraintNode, autoincrement, defineContract, enumType, field, gen, member, model, now, rel, sql, type };
222
233
  //# sourceMappingURL=contract-builder.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../../../../3-targets/sqlite/9-facade/dist/contract-builder.d.mts"],"mappings":";;;;;;;;;;;;KAWK,mBAAmB;KACnB,oBAAoB;KACpB,0BAA0B,eAAe;KACzC,mBAAmB,eAAe;KAClC,kBAAkB,eAAe;KACjC,+BAA+B;;KAE/B,uBAAuB;KACvB,aAAa,sBAAsB,yBAAyB,eAAe,kBAAkB,mBAAmB,eAAe,8CAA8C,cAAc,iBAA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AEF,yBAAyB;aACvB;aACA;aACA,yCAAyC;aACzC;;WAEF,aAAa;aACX;aACA;aACA,yCAAyC;aACzC;;;;;;;;cAQC,KAAK,kCAAkC,sBAAsB"}
1
+ {"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../../../../3-targets/sqlite/9-facade/dist/contract-builder.d.mts"],"mappings":";;;;;;;;;;;;KAWK,mBAAmB;KACnB,oBAAoB;KACpB,0BAA0B,eAAe;KACzC,mBAAmB,eAAe;KAClC,kBAAkB,eAAe;KACjC,+BAA+B;;KAE/B,uBAAuB;KACvB,aAAa,sBAAsB,yBAAyB,eAAe,kBAAkB,mBAAmB,eAAe,8CAA8C,cAAc,iBAAiB,2BAA2B,4CAA4C,kBAAkB,mBAAmB,WAAW;WAC7T,gBAAgB;WAChB,SAAS;WACT,aAAa;WACb,QAAQ;WACR,SAAS;WACT,qBAAqB;WACrB,kBAAkB,OAAO,sBAAsB;WAC/C,aAAa;WACb,gBAAgB;;KAEtB,mBAAmB,mBAAmB,eAAe,8CAA8C,2BAA2B,4CAA4C,KAAK,gBAAgB,WAAW,YAAY,sBAAsB,sBAAsB;;WAE5P,qBAAqB;;WAErB,cAAc;;;;WAId,iBAAiB;;KAEvB,iBAAiB,sBAAsB,yBAAyB,eAAe,kBAAkB,mBAAmB,eAAe,8CAA8C,cAAc,iBAAiB,2BAA2B,gCAAgC,mBAAmB,YAAY;WACpS,gBAAgB;WAChB,SAAS;WACT,QAAQ;;KAEd,eAAe,mBAAmB,eAAe,8CAA8C,cAAc,iBAAiB,2BAA2B,gCAAgC,mBAAmB,YAAY;WAClN,QAAQ;;iBAEF,qBAAqB,sBAAsB,0BAA0B,4BAA4B,eAAe,mBAAmB,4BAA4B,mBAAmB,eAAe,gEAAgE,cAAc,kBAAkB,4BAA4B,2BAA2B,0CAA0C,YAAY,iBAAiB,eAAe,QAAQ,YAAY,OAAO,sBAAsB,aAAa,eAAe,QAAQ,YAAY,OAAO;iBACthB,qBAAqB,sBAAsB,0BAA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zC;;WAEF,eAAe;aACb;aACA;aACA,yCAAyC;aACzC;;WAEF,iBAAiB;aACf;aACA;aACA,yCAAyC;aACzC;;WAEF,oBAAoB;aAClB;aACA;aACA,yCAAyC;aACzC;;WAEF,iBAAiB;aACf;aACA;aACA,yCAAyC;aACzC;;WAEF,iBAAiB;aACf,OAAO,WAAW;aAClB,QAAQ,WAAW;aACnB,yCAAyC;aACzC;;WAEF,qBAAqB;aACnB,OAAO;aACP,QAAQ;aACR,yCAAyC;aACzC;;WAEF,iBAAiB;aACf,0CAA0C;aAC1C,2CAA2C;aAC3C,yCAAyC;aACzC;;WAEF,mBAAmB;aACjB;aACA;aACA,yCAAyC;aACzC;;WAEF,yBAAyB;aACvB;aACA;aACA,yCAAyC;aACzC;;WAEF,aAAa;aACX;aACA;aACA,yCAAyC;aACzC;;;;;KAKR,gBAAgB,kCAAkC,sBAAsB;;;;cAI/D,OAAO;;;;cAIP,MAAM;;;;;;cAMN,KAAK,kCAAkC,sBAAsB"}
@@ -1,10 +1,10 @@
1
1
  import { sqliteCreateNamespace } from "@prisma/orm-target-sqlite/target/control";
2
2
  import sqlitePackRef from "@prisma/orm-target-sqlite/target/pack";
3
- import { autoincrement, bindEnumType, buildBoundContract, field, member, model, now, rel, sql } from "@prisma/orm-family-sql/contract-ts/contract-builder";
3
+ import { autoincrement, bindEnumType, buildBoundContract, createComposedAuthoringHelpers, member, model, now, rel, sql } from "@prisma/orm-family-sql/contract-ts/contract-builder";
4
4
  import { sqliteAdapterContractContributions } from "@prisma/orm-target-sqlite/adapter/adapter";
5
5
  import sqlFamilyPack from "@prisma/orm-family-sql/family/pack";
6
6
  import { assembleDataTypeSupport } from "@prisma/orm-framework/components/authoring";
7
- import { assembleSqliteCodecRegistry } from "@prisma/orm-target-sqlite/target/codecs";
7
+ import { assembleSqliteCodecRegistry, createSqliteBuiltinCodecLookup } from "@prisma/orm-target-sqlite/target/codecs";
8
8
  import { createGeneratorHelpers } from "@prisma/orm-framework/components/components";
9
9
  //#region ../../../3-targets/sqlite/9-facade/dist/contract-builder.mjs
10
10
  const adapter = sqliteAdapterContractContributions;
@@ -27,11 +27,24 @@ function defineContract(definition, factory) {
27
27
  }
28
28
  /** `enumType` bound to the pack's codec types, so each `member()` value is checked against the enum codec's input type. */
29
29
  const enumType = bindEnumType();
30
+ const helpers = createComposedAuthoringHelpers({
31
+ family: sqlFamilyPack,
32
+ target: sqlitePackRef,
33
+ codecLookup: createSqliteBuiltinCodecLookup()
34
+ });
35
+ /**
36
+ * The field builders of the `defineContract` callback for SQLite, without extensions: `field.column(type.DateTime())`. Use it outside a contract, for example to declare the fields of a query fragment.
37
+ */
38
+ const field = helpers.field;
39
+ /**
40
+ * The type constructors and type aliases of the `defineContract` callback for SQLite, without extensions, for `field.column(...)`: `type.DateTime()`, `type.sql.Ulid()`, `type.temporal.CreatedAt()`.
41
+ */
42
+ const type = helpers.type;
30
43
  /**
31
44
  * The generator function calls of the `defineContract` callback for SQLite, built from the same family and target packs, for `.onCreate(...)` and `.onUpdate(...)`: `gen.now()`, `gen.uuid(7)`, `gen.cuid(2)`, `gen.ulid()`, `gen.nanoid(16)` and `gen.ksuid()`.
32
45
  */
33
46
  const gen = createGeneratorHelpers([sqlFamilyPack, sqlitePackRef]);
34
47
  //#endregion
35
- export { autoincrement, defineContract, enumType, field, gen, member, model, now, rel, sql };
48
+ export { autoincrement, defineContract, enumType, field, gen, member, model, now, rel, sql, type };
36
49
 
37
50
  //# sourceMappingURL=contract-builder.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-builder.mjs","names":[],"sources":["../../../../3-targets/sqlite/9-facade/dist/contract-builder.mjs"],"sourcesContent":["import { sqliteCreateNamespace } from \"@internal/target-sqlite/control\";\nimport sqlitePackRef from \"@internal/target-sqlite/pack\";\nimport { autoincrement, bindEnumType, buildBoundContract, field, member, model, now, rel, sql } from \"@internal/sql-contract-ts/contract-builder\";\nimport { sqliteAdapterContractContributions } from \"@internal/adapter-sqlite/adapter\";\nimport sqlFamilyPack from \"@internal/family-sql/pack\";\nimport { assembleDataTypeSupport } from \"@internal/framework-components/authoring\";\nimport { assembleSqliteCodecRegistry } from \"@internal/target-sqlite/codecs\";\nimport { createGeneratorHelpers } from \"@internal/framework-components/components\";\n//#region src/contract/define-contract.ts\nconst adapter = sqliteAdapterContractContributions;\nconst target = sqlitePackRef;\nfunction defineContract(definition, factory) {\n\tconst extensionPacks = Object.values(definition.extensions ?? {});\n\tconst bound = {\n\t\t...definition,\n\t\tadapter,\n\t\tcreateNamespace: sqliteCreateNamespace,\n\t\tcodecLookup: definition.codecLookup ?? assembleSqliteCodecRegistry(target, extensionPacks),\n\t\tdataTypeLookup: definition.dataTypeLookup ?? assembleDataTypeSupport([\n\t\t\tsqlFamilyPack,\n\t\t\ttarget,\n\t\t\t...extensionPacks\n\t\t], () => void 0).support.lookup\n\t};\n\tif (factory !== void 0) return buildBoundContract(sqlFamilyPack, sqlitePackRef, bound, factory);\n\treturn buildBoundContract(sqlFamilyPack, sqlitePackRef, bound);\n}\n//#endregion\n//#region src/contract/enum-type.ts\n/** `enumType` bound to the pack's codec types, so each `member()` value is checked against the enum codec's input type. */\nconst enumType = bindEnumType();\n//#endregion\n//#region src/contract/gen.ts\n/**\n* The generator function calls of the `defineContract` callback for SQLite, built from the same family and target packs, for `.onCreate(...)` and `.onUpdate(...)`: `gen.now()`, `gen.uuid(7)`, `gen.cuid(2)`, `gen.ulid()`, `gen.nanoid(16)` and `gen.ksuid()`.\n*/\nconst gen = createGeneratorHelpers([sqlFamilyPack, sqlitePackRef]);\n//#endregion\nexport { autoincrement, defineContract, enumType, field, gen, member, model, now, rel, sql };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;AASA,MAAM,UAAU;AAChB,MAAM,SAAS;AACf,SAAS,eAAe,YAAY,SAAS;CAC5C,MAAM,iBAAiB,OAAO,OAAO,WAAW,cAAc,CAAC,CAAC;CAChE,MAAM,QAAQ;EACb,GAAG;EACH;EACA,iBAAiB;EACjB,aAAa,WAAW,eAAe,4BAA4B,QAAQ,cAAc;EACzF,gBAAgB,WAAW,kBAAkB,wBAAwB;GACpE;GACA;GACA,GAAG;EACJ,SAAS,KAAK,CAAC,CAAC,CAAC,QAAQ;CAC1B;CACA,IAAI,YAAY,KAAK,GAAG,OAAO,mBAAmB,eAAe,eAAe,OAAO,OAAO;CAC9F,OAAO,mBAAmB,eAAe,eAAe,KAAK;AAC9D;;AAIA,MAAM,WAAW,aAAa;;;;AAM9B,MAAM,MAAM,uBAAuB,CAAC,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"contract-builder.mjs","names":[],"sources":["../../../../3-targets/sqlite/9-facade/dist/contract-builder.mjs"],"sourcesContent":["import { sqliteCreateNamespace } from \"@internal/target-sqlite/control\";\nimport sqlitePackRef from \"@internal/target-sqlite/pack\";\nimport { autoincrement, bindEnumType, buildBoundContract, createComposedAuthoringHelpers, member, model, now, rel, sql } from \"@internal/sql-contract-ts/contract-builder\";\nimport { sqliteAdapterContractContributions } from \"@internal/adapter-sqlite/adapter\";\nimport sqlFamilyPack from \"@internal/family-sql/pack\";\nimport { assembleDataTypeSupport } from \"@internal/framework-components/authoring\";\nimport { assembleSqliteCodecRegistry, createSqliteBuiltinCodecLookup } from \"@internal/target-sqlite/codecs\";\nimport { createGeneratorHelpers } from \"@internal/framework-components/components\";\n//#region src/contract/define-contract.ts\nconst adapter = sqliteAdapterContractContributions;\nconst target = sqlitePackRef;\nfunction defineContract(definition, factory) {\n\tconst extensionPacks = Object.values(definition.extensions ?? {});\n\tconst bound = {\n\t\t...definition,\n\t\tadapter,\n\t\tcreateNamespace: sqliteCreateNamespace,\n\t\tcodecLookup: definition.codecLookup ?? assembleSqliteCodecRegistry(target, extensionPacks),\n\t\tdataTypeLookup: definition.dataTypeLookup ?? assembleDataTypeSupport([\n\t\t\tsqlFamilyPack,\n\t\t\ttarget,\n\t\t\t...extensionPacks\n\t\t], () => void 0).support.lookup\n\t};\n\tif (factory !== void 0) return buildBoundContract(sqlFamilyPack, sqlitePackRef, bound, factory);\n\treturn buildBoundContract(sqlFamilyPack, sqlitePackRef, bound);\n}\n//#endregion\n//#region src/contract/enum-type.ts\n/** `enumType` bound to the pack's codec types, so each `member()` value is checked against the enum codec's input type. */\nconst enumType = bindEnumType();\n//#endregion\n//#region src/contract/field.ts\nconst helpers = createComposedAuthoringHelpers({\n\tfamily: sqlFamilyPack,\n\ttarget: sqlitePackRef,\n\tcodecLookup: createSqliteBuiltinCodecLookup()\n});\n/**\n* The field builders of the `defineContract` callback for SQLite, without extensions: `field.column(type.DateTime())`. Use it outside a contract, for example to declare the fields of a query fragment.\n*/\nconst field = helpers.field;\n/**\n* The type constructors and type aliases of the `defineContract` callback for SQLite, without extensions, for `field.column(...)`: `type.DateTime()`, `type.sql.Ulid()`, `type.temporal.CreatedAt()`.\n*/\nconst type = helpers.type;\n//#endregion\n//#region src/contract/gen.ts\n/**\n* The generator function calls of the `defineContract` callback for SQLite, built from the same family and target packs, for `.onCreate(...)` and `.onUpdate(...)`: `gen.now()`, `gen.uuid(7)`, `gen.cuid(2)`, `gen.ulid()`, `gen.nanoid(16)` and `gen.ksuid()`.\n*/\nconst gen = createGeneratorHelpers([sqlFamilyPack, sqlitePackRef]);\n//#endregion\nexport { autoincrement, defineContract, enumType, field, gen, member, model, now, rel, sql, type };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;AASA,MAAM,UAAU;AAChB,MAAM,SAAS;AACf,SAAS,eAAe,YAAY,SAAS;CAC5C,MAAM,iBAAiB,OAAO,OAAO,WAAW,cAAc,CAAC,CAAC;CAChE,MAAM,QAAQ;EACb,GAAG;EACH;EACA,iBAAiB;EACjB,aAAa,WAAW,eAAe,4BAA4B,QAAQ,cAAc;EACzF,gBAAgB,WAAW,kBAAkB,wBAAwB;GACpE;GACA;GACA,GAAG;EACJ,SAAS,KAAK,CAAC,CAAC,CAAC,QAAQ;CAC1B;CACA,IAAI,YAAY,KAAK,GAAG,OAAO,mBAAmB,eAAe,eAAe,OAAO,OAAO;CAC9F,OAAO,mBAAmB,eAAe,eAAe,KAAK;AAC9D;;AAIA,MAAM,WAAW,aAAa;AAG9B,MAAM,UAAU,+BAA+B;CAC9C,QAAQ;CACR,QAAQ;CACR,aAAa,+BAA+B;AAC7C,CAAC;;;;AAID,MAAM,QAAQ,QAAQ;;;;AAItB,MAAM,OAAO,QAAQ;;;;AAMrB,MAAM,MAAM,uBAAuB,CAAC,eAAe,aAAa,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "@prisma/orm-family-sql/contract/generated-id-column-aliases";
@@ -0,0 +1,2 @@
1
+ export * from "@prisma/orm-family-sql/contract/generated-id-column-aliases";
2
+ export {};
package/dist/runtime.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as validateSqliteContract, t as buildSqliteStaticContext } from "./sqlite-static-C5p_wvZP-DM1ZSMaU.mjs";
1
+ import { i as validateSqliteContract, t as buildSqliteStaticContext } from "./sqlite-static-BIIbuAL4-DJZzEgdh.mjs";
2
2
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
3
  import sqliteAdapter from "@prisma/orm-target-sqlite/adapter/runtime";
4
4
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/sqlite/9-facade/dist/runtime.mjs"],"sourcesContent":["import { i as validateSqliteContract, t as buildSqliteStaticContext } from \"./sqlite-static-C5p_wvZP.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport sqliteDriver from \"@internal/driver-sqlite/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, delegatingRuntime, withTransaction, withTransactionMembers } from \"@internal/sql-runtime\";\nimport sqliteTarget from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/errors.ts\nfunction sqliteError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/runtime/binding.ts\nfunction resolveSqliteBinding(input) {\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: input.path\n\t};\n}\nfunction resolveOptionalSqliteBinding(options) {\n\tif (options.path === void 0) return;\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: options.path\n\t};\n}\n//#endregion\n//#region src/runtime/sqlite-runtime.ts\nvar SqliteRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/sqlite.ts\nfunction sqliteOrm(orm) {\n\tconst namespace = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(namespace, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn blindCast(Reflect.get(namespace, \"fragment\") === void 0 ? Object.create(namespace, { fragment: { value: Reflect.get(orm, \"fragment\") } }) : namespace);\n}\n/**\n* Builds the members of a SQLite transaction over `txCtx`, so every statement they run goes through the transaction. Preparing sends nothing to the database, so `prepare` uses `prepareRuntime`; the prepared statement runs on the queryable it is given.\n*/\nfunction buildSqliteTransactionMembers(options, txCtx) {\n\tconst { context, collections, rawCodecInferer, enums, toSql, prepareRuntime } = options;\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn {\n\t\tsql: blindCast(sqlNamespace),\n\t\torm: sqliteOrm(orm({\n\t\t\truntime: {\n\t\t\t\tquery(plan) {\n\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t},\n\t\t\t\texecute(plan) {\n\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t},\n\t\t\t\t[activitySource]: delegatingActivitySource(() => txCtx)\n\t\t\t},\n\t\t\tcontext,\n\t\t\t...ifDefined(\"collections\", collections)\n\t\t})),\n\t\traw: createRawLane({\n\t\t\tcontext,\n\t\t\trawCodecInferer\n\t\t}),\n\t\tenums,\n\t\ttoSql,\n\t\tprepare(declaration, callback) {\n\t\t\treturn prepareQuery(prepareRuntime, declaration, callback);\n\t\t}\n\t};\n}\n/**\n* Creates a lazy SQLite client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The database opens on the first query\n* or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-sqlite/static';\n* import sqlite from '@prisma/orm-sqlite/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = sqlite({ contract, path: './dev.db' });\n* ```\n*/\nfunction sqlite(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tlet binding = resolveOptionalSqliteBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\tdriver: sqliteDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: sqliteDriver\n\t});\n\tconst { sql, raw: rawSqlTag, enums, toSql } = buildSqliteStaticContext(contract, context, stack);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet closePromise;\n\tlet backgroundConnectError;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"SQLite runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconnectPromise = runtimeDriver.connect(resolvedBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch((err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst adapter = stack.adapter.create(stack);\n\t\tconst driverDescriptor = stack.driver;\n\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\tconst driver = driverDescriptor.create();\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new SqliteRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter,\n\t\t\tdriver,\n\t\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t\t...ifDefined(\"middleware\", options.middleware),\n\t\t\t...ifDefined(\"log\", options.log),\n\t\t\t...ifDefined(\"mode\", options.mode),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst workRuntime = delegatingRuntime(getRuntime);\n\tconst orm$1 = sqliteOrm(orm({\n\t\tcontext,\n\t\t...ifDefined(\"collections\", options.collections),\n\t\truntime: workRuntime\n\t}));\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(workRuntime, declaration, callback);\n\t}\n\treturn {\n\t\tsql,\n\t\torm: orm$1,\n\t\tenums,\n\t\traw: rawSqlTag,\n\t\ttoSql,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tquery(plan, execOptions) {\n\t\t\treturn workRuntime.query(plan, execOptions);\n\t\t},\n\t\texecute(plan, execOptions) {\n\t\t\treturn workRuntime.execute(plan, execOptions);\n\t\t},\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\t\tif (driverConnected || connectPromise) throw sqliteError(\"DRIVER.ALREADY_CONNECTED\", \"SQLite client already connected\", { meta: { extension: \"sqlite\" } });\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveSqliteBinding(bindingInput);\n\t\t\tif (binding === void 0) throw sqliteError(\"RUNTIME.BINDING_MISSING\", \"SQLite binding not configured. Pass path to sqlite(...) or call db.connect({ path }).\", { meta: { extension: \"sqlite\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\ttransaction(fn) {\n\t\t\treturn withTransaction(workRuntime, (txCtx) => {\n\t\t\t\treturn fn(withTransactionMembers(txCtx, buildSqliteTransactionMembers({\n\t\t\t\t\tcontext,\n\t\t\t\t\tcollections: options.collections,\n\t\t\t\t\trawCodecInferer: stack.adapter.rawCodecInferer,\n\t\t\t\t\tenums,\n\t\t\t\t\ttoSql,\n\t\t\t\t\tprepareRuntime: workRuntime\n\t\t\t\t}, txCtx)));\n\t\t\t});\n\t\t},\n\t\tclose() {\n\t\t\tif (closePromise) return closePromise;\n\t\t\tclosed = true;\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\t\tawait ownedDispose?.();\n\t\t\t})();\n\t\t\treturn closePromise;\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { SqliteRuntimeImpl, sqlite as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,YAAY,MAAM,SAAS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GACX,CAAC;EACF;EACA,QAAQ;GACP,IAAI,cAAc,OAAO;GACzB,SAAS;GACT,gBAAgB,YAAY;IAC3B,MAAM,gBAAgB,YAAY,KAAK,CAAC;IACxC,MAAM,eAAe;GACtB,EAAA,CAAG;GACH,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/sqlite/9-facade/dist/runtime.mjs"],"sourcesContent":["import { i as validateSqliteContract, t as buildSqliteStaticContext } from \"./sqlite-static-BIIbuAL4.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport sqliteDriver from \"@internal/driver-sqlite/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, delegatingRuntime, withTransaction, withTransactionMembers } from \"@internal/sql-runtime\";\nimport sqliteTarget from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/errors.ts\nfunction sqliteError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/runtime/binding.ts\nfunction resolveSqliteBinding(input) {\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: input.path\n\t};\n}\nfunction resolveOptionalSqliteBinding(options) {\n\tif (options.path === void 0) return;\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: options.path\n\t};\n}\n//#endregion\n//#region src/runtime/sqlite-runtime.ts\nvar SqliteRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/sqlite.ts\nfunction sqliteOrm(orm) {\n\tconst namespace = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(namespace, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn blindCast(Reflect.get(namespace, \"fragment\") === void 0 ? Object.create(namespace, { fragment: { value: Reflect.get(orm, \"fragment\") } }) : namespace);\n}\n/**\n* Builds the members of a SQLite transaction over `txCtx`, so every statement they run goes through the transaction. Preparing sends nothing to the database, so `prepare` uses `prepareRuntime`; the prepared statement runs on the queryable it is given.\n*/\nfunction buildSqliteTransactionMembers(options, txCtx) {\n\tconst { context, collections, rawCodecInferer, enums, toSql, prepareRuntime } = options;\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn {\n\t\tsql: blindCast(sqlNamespace),\n\t\torm: sqliteOrm(orm({\n\t\t\truntime: {\n\t\t\t\tquery(plan) {\n\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t},\n\t\t\t\texecute(plan) {\n\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t},\n\t\t\t\t[activitySource]: delegatingActivitySource(() => txCtx)\n\t\t\t},\n\t\t\tcontext,\n\t\t\t...ifDefined(\"collections\", collections)\n\t\t})),\n\t\traw: createRawLane({\n\t\t\tcontext,\n\t\t\trawCodecInferer\n\t\t}),\n\t\tenums,\n\t\ttoSql,\n\t\tprepare(declaration, callback) {\n\t\t\treturn prepareQuery(prepareRuntime, declaration, callback);\n\t\t}\n\t};\n}\n/**\n* Creates a lazy SQLite client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The database opens on the first query\n* or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-sqlite/static';\n* import sqlite from '@prisma/orm-sqlite/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = sqlite({ contract, path: './dev.db' });\n* ```\n*/\nfunction sqlite(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tlet binding = resolveOptionalSqliteBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\tdriver: sqliteDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: sqliteDriver\n\t});\n\tconst { sql, raw: rawSqlTag, enums, toSql } = buildSqliteStaticContext(contract, context, stack);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet closePromise;\n\tlet backgroundConnectError;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"SQLite runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconnectPromise = runtimeDriver.connect(resolvedBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch((err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst adapter = stack.adapter.create(stack);\n\t\tconst driverDescriptor = stack.driver;\n\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\tconst driver = driverDescriptor.create();\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new SqliteRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter,\n\t\t\tdriver,\n\t\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t\t...ifDefined(\"middleware\", options.middleware),\n\t\t\t...ifDefined(\"log\", options.log),\n\t\t\t...ifDefined(\"mode\", options.mode),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst workRuntime = delegatingRuntime(getRuntime);\n\tconst orm$1 = sqliteOrm(orm({\n\t\tcontext,\n\t\t...ifDefined(\"collections\", options.collections),\n\t\truntime: workRuntime\n\t}));\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(workRuntime, declaration, callback);\n\t}\n\treturn {\n\t\tsql,\n\t\torm: orm$1,\n\t\tenums,\n\t\traw: rawSqlTag,\n\t\ttoSql,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tquery(plan, execOptions) {\n\t\t\treturn workRuntime.query(plan, execOptions);\n\t\t},\n\t\texecute(plan, execOptions) {\n\t\t\treturn workRuntime.execute(plan, execOptions);\n\t\t},\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\t\tif (driverConnected || connectPromise) throw sqliteError(\"DRIVER.ALREADY_CONNECTED\", \"SQLite client already connected\", { meta: { extension: \"sqlite\" } });\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveSqliteBinding(bindingInput);\n\t\t\tif (binding === void 0) throw sqliteError(\"RUNTIME.BINDING_MISSING\", \"SQLite binding not configured. Pass path to sqlite(...) or call db.connect({ path }).\", { meta: { extension: \"sqlite\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\ttransaction(fn) {\n\t\t\treturn withTransaction(workRuntime, (txCtx) => {\n\t\t\t\treturn fn(withTransactionMembers(txCtx, buildSqliteTransactionMembers({\n\t\t\t\t\tcontext,\n\t\t\t\t\tcollections: options.collections,\n\t\t\t\t\trawCodecInferer: stack.adapter.rawCodecInferer,\n\t\t\t\t\tenums,\n\t\t\t\t\ttoSql,\n\t\t\t\t\tprepareRuntime: workRuntime\n\t\t\t\t}, txCtx)));\n\t\t\t});\n\t\t},\n\t\tclose() {\n\t\t\tif (closePromise) return closePromise;\n\t\t\tclosed = true;\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\t\tawait ownedDispose?.();\n\t\t\t})();\n\t\t\treturn closePromise;\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { SqliteRuntimeImpl, sqlite as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,YAAY,MAAM,SAAS,SAAS;CAC5C,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;AAGA,SAAS,qBAAqB,OAAO;CACpC,OAAO;EACN,MAAM;EACN,MAAM,MAAM;CACb;AACD;AACA,SAAS,6BAA6B,SAAS;CAC9C,IAAI,QAAQ,SAAS,KAAK,GAAG;CAC7B,OAAO;EACN,MAAM;EACN,MAAM,QAAQ;CACf;AACD;AAGA,IAAI,oBAAoB,cAAc,eAAe,CAAC;AAGtD,SAAS,UAAU,KAAK;CACvB,MAAM,YAAY,IAAI;CACtB,cAAc,WAAW,gEAAgE;CACzF,OAAO,UAAU,QAAQ,IAAI,WAAW,UAAU,MAAM,KAAK,IAAI,OAAO,OAAO,WAAW,EAAE,UAAU,EAAE,OAAO,QAAQ,IAAI,KAAK,UAAU,EAAE,EAAE,CAAC,IAAI,SAAS;AAC7J;;;;AAIA,SAAS,8BAA8B,SAAS,OA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YAAY,wBAAwB,2BAA2B,EAAE,MAAM,EAAE,WAAW,SAAS,EAAE,CAAC;GAClH,IAAI,mBAAmB,gBAAgB,MAAM,YAAY,4BAA4B,mCAAmC,EAAE,MAAM,EAAE,WAAW,SAAS,EAAE,CAAC;GACzJ,yBAAyB,KAAK;GAC9B,IAAI,iBAAiB,KAAK,GAAG,UAAU,qBAAqB,YAAY;GACxE,IAAI,YAAY,KAAK,GAAG,MAAM,YAAY,2BAA2B,yFAAyF,EAAE,MAAM,EAAE,WAAW,SAAS,EAAE,CAAC;GAC/L,MAAM,UAAU,WAAW;GAC3B,IAAI,iBAAiB,OAAO;GAC5B,MAAM,cAAc,OAAO;GAC3B,OAAO;EACR;EACA,UAAU;GACT,OAAO,WAAW;EACnB;EACA;EACA,YAAY,IAAI;GACf,OAAO,gBAAgB,cAAc,UAAU;IAC9C,OAAO,GAAG,uBAAuB,OAAO,8BAA8B;KACrE;KACA,aAAa,QAAQ;KACrB,iBAAiB,MAAM,QAAQ;KAC/B;KACA;KACA,gBAAgB;IACjB,GAAG,KAAK,CAAC,CAAC;GACX,CAAC;EACF;EACA,QAAQ;GACP,IAAI,cAAc,OAAO;GACzB,SAAS;GACT,gBAAgB,YAAY;IAC3B,MAAM,gBAAgB,YAAY,KAAK,CAAC;IACxC,MAAM,eAAe;GACtB,EAAA,CAAG;GACH,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
@@ -7,8 +7,8 @@ import { assertDefined } from "@prisma/orm-framework/utils/assertions";
7
7
  import { blindCast } from "@prisma/orm-framework/utils/casts";
8
8
  import { validateContractOnce } from "@prisma/orm-framework/contract/validate-once";
9
9
  import { buildNamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
10
- //#region ../../../3-targets/sqlite/9-facade/dist/sqlite-static-C5p_wvZP.mjs
11
- var version = "8.0.0-rc.20-dev.13";
10
+ //#region ../../../3-targets/sqlite/9-facade/dist/sqlite-static-BIIbuAL4.mjs
11
+ var version = "8.0.0-rc.20-dev.15";
12
12
  const serializer = new SqliteContractSerializer();
13
13
  const validator = `${sqliteTarget.targetId}@${version}`;
14
14
  /**
@@ -80,4 +80,4 @@ function sqliteStatic(options) {
80
80
  //#endregion
81
81
  export { validateSqliteContract as i, contractFromJson as n, sqliteStatic as r, buildSqliteStaticContext as t };
82
82
 
83
- //# sourceMappingURL=sqlite-static-C5p_wvZP-DM1ZSMaU.mjs.map
83
+ //# sourceMappingURL=sqlite-static-BIIbuAL4-DJZzEgdh.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite-static-C5p_wvZP-DM1ZSMaU.mjs","names":[],"sources":["../../../../3-targets/sqlite/9-facade/dist/sqlite-static-C5p_wvZP.mjs"],"sourcesContent":["import sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, createToSql } from \"@internal/sql-runtime\";\nimport sqliteTarget, { SqliteContractSerializer } from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\n//#region package.json\nvar version = \"8.0.0-rc.20-dev.13\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new SqliteContractSerializer();\nconst validator = `${sqliteTarget.targetId}@${version}`;\n/**\n* Validates an emitted SQLite `contract.json` and returns it as the contract type the application\n* names, ready to pass to `sqlite({ contract })` and `sqliteStatic({ contract })`. Clients built\n* from the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateSqliteContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\n//#region src/static/sqlite-static.ts\nfunction buildSqliteStaticContext(contract, context, stack) {\n\tconst { rawCodecInferer } = stack.adapter;\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\tconst sqlDb = blindCast(sqlNamespace);\n\tconst raw = createRawLane({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId })))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tsql: sqlDb,\n\t\traw,\n\t\ttoSql: createToSql(stack, contract)\n\t};\n}\n/**\n* The query surfaces of a SQLite client without a driver: `sql`, `raw`, `enums` and `toSql`. Use\n* it where loading `node:sqlite` is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = sqliteStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction sqliteStatic(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildSqliteStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack);\n}\n//#endregion\nexport { validateSqliteContract as i, sqliteStatic as n, contractFromJson as r, buildSqliteStaticContext as t };\n\n//# sourceMappingURL=sqlite-static-C5p_wvZP.mjs.map"],"mappings":";;;;;;;;;;AAUA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,yBAAyB;AAChD,MAAM,YAAY,GAAG,aAAa,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiB9C,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,uBAAuB,UAAU;CACzC,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H;AAGA,SAAS,yBAAyB,UAAU,SAAS,OAAO;CAC3D,MAAM,EAAE,oBAAoB,MAAM;CAClC,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,gEAAgE;CAC5F,MAAM,QAAQ,UAAU,YAAY;CACpC,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzI,cAAc,OAAO,gEAAgE;CACrF,OAAO;EACN;EACA;EACA;EACA,KAAK;EACL;EACA,OAAO,YAAY,OAAO,QAAQ;CACnC;AACD;;;;;;;;;;AAUA,SAAS,aAAa,SAAS;CAC9B,MAAM,WAAW,uBAAuB,QAAQ,QAAQ;CACxD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,yBAAyB,UAAU,uBAAuB;EAChE;EACA;CACD,CAAC,GAAG,KAAK;AACV"}
1
+ {"version":3,"file":"sqlite-static-BIIbuAL4-DJZzEgdh.mjs","names":[],"sources":["../../../../3-targets/sqlite/9-facade/dist/sqlite-static-BIIbuAL4.mjs"],"sourcesContent":["import sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, createToSql } from \"@internal/sql-runtime\";\nimport sqliteTarget, { SqliteContractSerializer } from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\n//#region package.json\nvar version = \"8.0.0-rc.20-dev.15\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new SqliteContractSerializer();\nconst validator = `${sqliteTarget.targetId}@${version}`;\n/**\n* Validates an emitted SQLite `contract.json` and returns it as the contract type the application\n* names, ready to pass to `sqlite({ contract })` and `sqliteStatic({ contract })`. Clients built\n* from the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateSqliteContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\n//#region src/static/sqlite-static.ts\nfunction buildSqliteStaticContext(contract, context, stack) {\n\tconst { rawCodecInferer } = stack.adapter;\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\tconst sqlDb = blindCast(sqlNamespace);\n\tconst raw = createRawLane({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId })))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tsql: sqlDb,\n\t\traw,\n\t\ttoSql: createToSql(stack, contract)\n\t};\n}\n/**\n* The query surfaces of a SQLite client without a driver: `sql`, `raw`, `enums` and `toSql`. Use\n* it where loading `node:sqlite` is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = sqliteStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction sqliteStatic(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildSqliteStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack);\n}\n//#endregion\nexport { validateSqliteContract as i, sqliteStatic as n, contractFromJson as r, buildSqliteStaticContext as t };\n\n//# sourceMappingURL=sqlite-static-BIIbuAL4.mjs.map"],"mappings":";;;;;;;;;;AAUA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,yBAAyB;AAChD,MAAM,YAAY,GAAG,aAAa,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiB9C,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,uBAAuB,UAAU;CACzC,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H;AAGA,SAAS,yBAAyB,UAAU,SAAS,OAAO;CAC3D,MAAM,EAAE,oBAAoB,MAAM;CAClC,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,gEAAgE;CAC5F,MAAM,QAAQ,UAAU,YAAY;CACpC,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzI,cAAc,OAAO,gEAAgE;CACrF,OAAO;EACN;EACA;EACA;EACA,KAAK;EACL;EACA,OAAO,YAAY,OAAO,QAAQ;CACnC;AACD;;;;;;;;;;AAUA,SAAS,aAAa,SAAS;CAC9B,MAAM,WAAW,uBAAuB,QAAQ,QAAQ;CACxD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,yBAAyB,UAAU,uBAAuB;EAChE;EACA;CACD,CAAC,GAAG,KAAK;AACV"}
package/dist/static.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as contractFromJson, r as sqliteStatic } from "./sqlite-static-C5p_wvZP-DM1ZSMaU.mjs";
1
+ import { n as contractFromJson, r as sqliteStatic } from "./sqlite-static-BIIbuAL4-DJZzEgdh.mjs";
2
2
  export { contractFromJson, sqliteStatic as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-sqlite",
3
- "version": "8.0.0-rc.20-dev.13",
3
+ "version": "8.0.0-rc.20-dev.15",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -10,17 +10,17 @@
10
10
  "skills"
11
11
  ],
12
12
  "dependencies": {
13
- "@prisma/orm-family-sql": "8.0.0-rc.20-dev.13",
14
- "@prisma/orm-framework": "8.0.0-rc.20-dev.13",
15
- "@prisma/orm-target-sqlite": "8.0.0-rc.20-dev.13",
16
- "@prisma/orm-toolchain": "8.0.0-rc.20-dev.13",
13
+ "@prisma/orm-family-sql": "8.0.0-rc.20-dev.15",
14
+ "@prisma/orm-framework": "8.0.0-rc.20-dev.15",
15
+ "@prisma/orm-target-sqlite": "8.0.0-rc.20-dev.15",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.20-dev.15",
17
17
  "pathe": "^2.0.3",
18
18
  "tinyglobby": "^0.2.17"
19
19
  },
20
20
  "devDependencies": {
21
- "@internal/sqlite": "8.0.0-rc.20-dev.13",
22
- "@repo/tsconfig": "8.0.0-rc.20-dev.13",
23
- "@repo/tsdown": "8.0.0-rc.20-dev.13",
21
+ "@internal/sqlite": "8.0.0-rc.20-dev.15",
22
+ "@repo/tsconfig": "8.0.0-rc.20-dev.15",
23
+ "@repo/tsdown": "8.0.0-rc.20-dev.15",
24
24
  "tsdown": "0.22.14",
25
25
  "typescript": "5.9.3"
26
26
  },
@@ -93,6 +93,7 @@
93
93
  "./family-contract/entity-kinds": "./dist/family-contract__entity-kinds.mjs",
94
94
  "./family-contract/factories": "./dist/family-contract__factories.mjs",
95
95
  "./family-contract/foreign-key-materialization": "./dist/family-contract__foreign-key-materialization.mjs",
96
+ "./family-contract/generated-id-column-aliases": "./dist/family-contract__generated-id-column-aliases.mjs",
96
97
  "./family-contract/index-naming": "./dist/family-contract__index-naming.mjs",
97
98
  "./family-contract/index-type-validation": "./dist/family-contract__index-type-validation.mjs",
98
99
  "./family-contract/index-types": "./dist/family-contract__index-types.mjs",
@@ -15,7 +15,7 @@ description: >-
15
15
  ORM 7 or earlier (schema.prisma + @prisma/client).
16
16
  metadata:
17
17
  library: '@prisma/orm-sqlite'
18
- library_version: '8.0.0-rc.20-dev.13'
18
+ library_version: '8.0.0-rc.20-dev.15'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -35,6 +35,10 @@ Check these before acting on anything below. Halt on the first one that fails an
35
35
 
36
36
  **Import paths in the references.** The reference files spell façade imports as `@internal/<target>/<subpath>` and `@internal/extension-<name>/<subpath>`. In an application those packages are published as `@prisma/orm-<target>/<subpath>` (`@prisma/orm-postgres/runtime`, `@prisma/orm-mongo/config`, `@prisma/orm-sqlite/runtime`) and `@prisma/orm-extension-<name>/<subpath>` (`@prisma/orm-extension-pgvector/control`). Write the `@prisma/orm-*` name in user code; the two spellings are the same package. Paths already written as `@prisma/orm-*` in the references are exact. The `metadata.library_version` in this file's frontmatter is the version it was published with; if it does not match the project's installed Prisma packages, run `prisma skills sync` and re-read.
37
37
 
38
+ ## Never reset or drop a database
39
+
40
+ Never reset or drop a database to fix a migration, marker 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. A deploy that says there is no migration path, or `MIGRATION.MARKER_MISMATCH`, is covered in [`references/migrations.md`](references/migrations.md) § *A database whose marker is not in the migration graph*.
41
+
38
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.
39
43
 
40
44
  ## The canonical model (one paragraph)
@@ -59,7 +63,7 @@ Open the reference whose triggers match the task. If more than one matches, open
59
63
  | --- | --- | --- |
60
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` |
61
65
  | Edit the data contract | [`references/contract.md`](references/contract.md) | schema, models, fields, attributes, relations, indexes, enums, value objects (composite types), type aliases, namespaces (Postgres schemas), cross-contract foreign keys (cross-space FK), polymorphic types (`@@discriminator` / `@@base`), extension namespaces (`pgvector.Vector(...)`, `postgis.Geometry(...)`), `prisma.config.ts` / `definePrismaConfig` / `ormConfig`, `prisma contract emit`, PSL, `contract.prisma`, `contract.ts`, `contract.json`, `contract.d.ts`, `@internal/postgres/config`, `@internal/postgres/contract-builder`, `@internal/mongo/config`, `extensions:`, pgvector, postgis, paradedb, Temporal / `temporal-polyfill` / `RUNTIME.TEMPORAL_UNAVAILABLE`, `@@control`, control policy (managed / tolerated / external / observed), soft delete, validations, callbacks |
62
- | Author migrations | [`references/migrations.md`](references/migrations.md) | `db update` vs `migration plan`, `db migrate`, `migration new`, `migration show`, `db update --dry-run`, `db verify`, `db sign`, data migration, `dataTransform`, placeholder sentinels in framework-rendered `migration.ts`, `MIGRATION.HASH_MISMATCH`, `MIGRATION.UNFILLED_PLACEHOLDER`, data-loss questions (`--delete`, `--rename`, `--allow`, `CLI.CONSENT_REQUIRED`), schema drift |
66
+ | Author migrations | [`references/migrations.md`](references/migrations.md) | "no migration path", "migration path not found", "no authored path", `MIGRATION.MARKER_MISMATCH`, "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 |
63
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 |
64
68
  | Review migrations on deploy | [`references/migration-review.md`](references/migration-review.md) | "what migrations are going to run", "what runs on deploy / merge", merge conflict, diamond convergence, concurrent migrations, migration status, ref management for CI, staging / production environment refs, `MIGRATION.MARKER_NOT_IN_HISTORY`, `MIGRATION.MISSING_INVARIANTS`, `db migrate --show` |
65
69
  | Write queries | [`references/queries.md`](references/queries.md) | query, where, select, project, orderBy, limit, offset, take, skip, include, lookup, first, all, count, aggregate, groupBy, create, update, delete, upsert, returning, transaction, `db.orm`, `db.sql`, `runtime.query(plan)` vs `runtime.execute(plan)`, `db.prepare` / prepared statements, streaming / `for await`, many-to-many `include` and nested `connect`, `and` / `or` / `not` from `@prisma/orm-postgres/orm-client`, `db.query.from(...)` (Mongo pipeline), namespace-aware accessors, `.all()` Thenable, single-use iterators (`RUNTIME.ITERATOR_CONSUMED`), target-declared aggregate types (`count`, integer `sum`, and integer `avg` are `number`; `count` and integer `sum` throw outside ±(2^53 − 1) rather than round, while `avg` is a fraction already and carries no guard; `countBigInt` / `sumBigInt` / `avgDecimal` are the lossless forms, `avgDecimal` on PostgreSQL only), custom collection class (`extends Collection`), `with` and query fragments (`QueryFragment`, `Filtered`, `Ordered`), shared query fragments and scopes (`db.orm.fragment(fields, body)` for a filter on every model with given fields, `CodecField`, `db.orm.public.Post.fragment(...)` for a shared `select` / `include`, `orderByField` for an order or sort parameter from a request), drizzle-style, kysely-style. Naming types (§ *Naming model and result types*): "type of my model", "return type of a query", `ResultType`, `Scalars`, `Shape`, `models` / `Models` namespace in `contract.d.ts`, `Models.public_User`, Prisma 7 `Prisma.User` / `GetPayload` / `UserGetPayload` equivalents. Postgres/SQLite specifics: [`references/queries-postgres.md`](references/queries-postgres.md); Mongo specifics: [`references/queries-mongo.md`](references/queries-mongo.md) |
@@ -64,7 +64,7 @@ Both files are **emitted artefacts**. Edit the source; never the JSON or `.d.ts`
64
64
 
65
65
  The fields `ormConfig` accepts: `contract` (path string — `.prisma` or `.ts`), `output` (optional override for where `contract.json` lands), `db` (`{ connection?: string }`), `extensions` (array of control descriptors), `migrations` (`{ dir?: string }`). Without `output`, the path for `contract.json` is derived from `contract` (e.g. `./src/prisma/contract.prisma` → `./src/prisma/contract.json`). Keep `import 'dotenv/config'` when the config reads `process.env`.
66
66
  - **Emit pipeline.** `prisma contract emit --config <path>?` reads `prisma.config.ts`, calls the provider the façade picked, validates the resulting Contract, then atomically writes `contract.json` + `contract.d.ts` colocated with the source.
67
- - **Extension namespaces.** Extensions contribute namespaced constructors (`pgvector.Vector(length: 1536)`, `postgis.Geometry(...)`) and helper presets. Install them by adding the descriptor to **two** places — both fields are named `extensions`, but the two surfaces consume two different descriptor types and shapes:
67
+ - **Extension namespaces.** Extensions contribute namespaced constructors (`pgvector.Vector(length: 1536)`, `postgis.Geometry(...)`) and type aliases. Install them by adding the descriptor to **two** places — both fields are named `extensions`, but the two surfaces consume two different descriptor types and shapes:
68
68
  - **In the config (façade and core):** `extensions: [pgvector]` — array of *control* descriptors imported from `@internal/extension-<name>/control`.
69
69
  - **In the TS builder's `defineContract` (only when authoring `contract.ts`):** `extensions: { pgvector }` — record of *pack* descriptors imported from `@internal/extension-<name>/pack`.
70
70
  - **Contract space.** Every package that emits a contract owns its own *contract space* — a `prisma.config.ts` at package root, a contract source, the colocated emitted artefacts, and a `migrations/` directory. **There are two intentional on-disk layouts**, picked by whether the contract space is the consuming application or a contract-space package (an extension, an internal aggregate-root package, etc.):
@@ -156,17 +156,17 @@ model User {
156
156
  }
157
157
  ```
158
158
 
159
- An alias is expanded into each field that uses it: the column stores the alias's codec and type params, and the contract stores no alias. An alias may carry `@default`, `@onCreate` and `@onUpdate`, which every field typed by it takes: `UpdatedAt = TimestampString(3) @onCreate(now()) @onUpdate(now())`. It may not carry `@id` or `@unique`; write those on the field. A field may add attributes its alias does not set (`updatedAt UpdatedAt @default(now())`), but repeating one the alias sets is `PSL_DUPLICATE_ATTRIBUTE`. An alias may not name another alias. The targets contribute `temporal.CreatedAt` (generated on create) and `temporal.UpdatedAt` (on create and on update), written bare: `createdAt temporal.CreatedAt`. On Postgres they are `TimestamptzTemporal` columns, with `temporal.CreatedAtString` / `UpdatedAtString` and `CreatedAtJsDate` / `UpdatedAtJsDate` variants; on SQLite `DateTime`; on Mongo `Date`. They take no arguments; for a precision, write the type and attributes, as in `TimestamptzTemporal(3) @onCreate(now())`.
159
+ An alias is expanded into each field that uses it: the column stores the alias's codec and type params, and the contract stores no alias. An alias may carry `@default`, `@onCreate` and `@onUpdate`, which every field typed by it takes: `UpdatedAt = TimestampString(3) @onCreate(now()) @onUpdate(now())`. It may not carry `@id` or `@unique`; write those on the field. A field may add attributes its alias does not set (`updatedAt UpdatedAt @default(now())`), but repeating one the alias sets is `PSL_DUPLICATE_ATTRIBUTE`. An alias may not name another alias. The targets contribute `temporal.CreatedAt` (generated on create) and `temporal.UpdatedAt` (on create and on update), written bare: `createdAt temporal.CreatedAt`. On Postgres they are `TimestamptzTemporal` columns, with `temporal.CreatedAtString` / `UpdatedAtString` and `CreatedAtJsDate` / `UpdatedAtJsDate` variants; on SQLite `DateTime`; on Mongo `Date`. They take no arguments; for a precision, write the type and attributes, as in `TimestamptzTemporal(3) @onCreate(now())`. The SQL targets also contribute an alias for the column of each identifier format the client generates: `sql.UuidString`, `sql.Ulid`, `sql.Nanoid`, `sql.Cuid2` and `sql.Ksuid`, which Postgres also names at the top level, as `Ulid`. Each stores `Char(n)` of its format's length and carries no generator, so the key writes `id Ulid @id @onCreate(ulid())` and a foreign key writes `authorId Ulid`. On Postgres, a UUID is better stored in the native column: `id Uuid @id @onCreate(uuid(7))`.
160
160
 
161
161
  Values the client generates are written `@onCreate(fn())` and `@onUpdate(fn())`: `id String @id @onCreate(uuid(7))`, `slug String @onCreate(nanoid(12))`, `updatedAt DateTime @onCreate(now()) @onUpdate(now())`. `@default(...)` is a database default only (`now()`, `autoincrement()`, a literal, or `` sql`...` ``); `@default(uuid())` is refused with `PSL_GENERATOR_IN_DEFAULT`. In the TS builder, write `.onCreate(gen.uuid(7))` and `.onUpdate(gen.now())`. Column defaults and generators can sit on one field: `@default(now()) @onCreate(now())`.
162
162
 
163
- In the TS builder, an alias is a constant passed as the field, because field builders are immutable: `const Slug = field.column(type.VarChar(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()` and `type.temporal.UpdatedAt()`, used as `field.column(type.temporal.UpdatedAt())`. A definition has no `types` key (`CONTRACT.TYPES_KEY_REMOVED`), and `field.namedType(...)` takes only an enum handle.
163
+ In the TS builder, an alias is a constant passed as the field, because field builders are immutable: `const Slug = field.column(type.VarChar(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.
164
164
 
165
165
  Note: scalar lists (e.g. `String[]`) are gated on the target's `sql.scalarList` capability — PostgreSQL declares it, 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 does not, and 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 `valueObjects` in the domain and stores them as `jsonb` columns. See *Workflow — Value objects* below.
166
166
 
167
167
  ## Workflow — Edit a model / field / relation (TS builder)
168
168
 
169
- The concept: same model, different authoring surface. The façade re-exports `defineContract`, `field`, `model`, `rel`, plus the `family`/`target` packs as default exports of `@internal/postgres/family` and `@internal/postgres/target`. Use the callback overload (`defineContract({...}, ({ field, model, rel, type }) => ({...}))`) to get the higher-level helpers (`field.text()`, `field.id.uuidv7String()`, `field.temporal.createdAt()`, `type.sql.String(35)`).
169
+ The concept: same model, different authoring surface. The façade re-exports `defineContract`, `field`, `model`, `rel`, plus the `family`/`target` packs as default exports of `@internal/postgres/family` and `@internal/postgres/target`. Use the callback overload (`defineContract({...}, ({ field, model, rel, type, gen }) => ({...}))`) to get the type constructors, type aliases and generator calls (`field.column(type.String())`, `field.column(type.Uuid()).id().onCreate(gen.uuid(7))`, `field.column(type.temporal.CreatedAt())`, `type.sql.String(35)`).
170
170
 
171
171
  ```typescript
172
172
  import sqlFamily from '@internal/postgres/family';
@@ -178,13 +178,13 @@ export const contract = defineContract(
178
178
  family: sqlFamily,
179
179
  target: postgresPack,
180
180
  },
181
- ({ field, model }) => ({
181
+ ({ field, model, gen, type }) => ({
182
182
  models: {
183
183
  User: model('User', {
184
184
  fields: {
185
- id: field.id.uuidv7String(),
186
- email: field.text().unique(),
187
- createdAt: field.temporal.createdAt(),
185
+ id: field.column(type.Uuid()).id().onCreate(gen.uuid(7)),
186
+ email: field.column(type.String()).unique(),
187
+ createdAt: field.column(type.temporal.CreatedAt()),
188
188
  },
189
189
  }).sql({ table: 'app_user' }),
190
190
  },
@@ -192,13 +192,13 @@ export const contract = defineContract(
192
192
  );
193
193
  ```
194
194
 
195
- Then `pnpm prisma contract emit`. On Postgres, the `field` that `@prisma/orm-postgres/contract-builder` exports has the same `field.<scalar>()` helpers as the callback's, without the helpers an extension adds (such as pgvector's); for those, use the callback's `field`. On other targets the `field.<scalar>()` helpers are only available inside the callback overload; outside the callback only `field.column(...)`, `field.generated(...)`, `field.namedType(...)` exist.
195
+ Then `pnpm prisma contract emit`. On Postgres, `@prisma/orm-postgres/contract-builder` exports `field`, `type` and `gen`, the same helpers the callback receives, without the ones an extension adds (such as pgvector's `type.pgvector.Vector`); for those, use the callback's helpers. On other targets `type` and `gen` are only available inside the callback overload.
196
196
 
197
197
  For Mongo, swap every `@internal/postgres/*` import for `@internal/mongo/*`. The Mongo builder also exposes `index` and `valueObject`.
198
198
 
199
199
  Mongo scalar types, as PSL name / TS builder / application type: `String` / `field.string()` / `string`; `Int32` / `field.int32()` / `number`; `Int64` / `field.int64()` / `bigint`; `Double` / `field.double()` / `number`; `Decimal128` / `field.decimal128()` / decimal text as a `string`; `Bool` / `field.bool()` / `boolean`; `Date` / `field.date()` / `Date`; `ObjectId` / `field.objectId()` / `string`; `Binary` / `field.binary()` / `Uint8Array`; `Json` / `field.json()` / `JsonValue`; `Bson` / `field.bson()` / `BsonValue`. `Json` holds a JSON value only, validated as the JSON-representable BSON types; `Bson` holds any BSON value, unconstrained by the validator. The full table, with codec ids and storage types, is [Scalar types](https://github.com/prisma/orm/blob/main/docs/reference/scalar-types.md).
200
200
 
201
- Mongo timestamps the ORM fills: in PSL, write `createdAt Date @onCreate(now())` (set on create) or `updatedAt Date @onCreate(now()) @onUpdate(now())` (set on create and on every update with a non-empty payload), or type the field `temporal.CreatedAt` or `temporal.UpdatedAt`, or with the presets `temporal.createdAt()`, `temporal.updatedAt()` or `temporal.timestamp(onCreate: now, onUpdate: now)`; in TS, use `field.date().onCreate(gen.now()).onUpdate(gen.now())`, or `field.temporal.createdAt()` and the rest inside the callback overload. They store a BSON date read back as `Date`, one value per ORM operation, and an explicit value in the write wins. The fields are optional on create. A preset field cannot be optional (`?`), a list, `@id`, or a field of a composite type.
201
+ Mongo timestamps the ORM fills: in PSL, write `createdAt Date @onCreate(now())` (set on create) or `updatedAt Date @onCreate(now()) @onUpdate(now())` (set on create and on every update with a non-empty payload), or type the field `temporal.CreatedAt` or `temporal.UpdatedAt`; in TS, use `field.date().onCreate(gen.now())` or `field.date().onCreate(gen.now()).onUpdate(gen.now())`. They store a BSON date read back as `Date`, one value per ORM operation, and an explicit value in the write wins. The fields are optional on create. A field with a generated value cannot be optional (`?`), a list, `@id`, or a field of a composite type.
202
202
 
203
203
  ## Workflow — Add an extension-typed scalar (pgvector)
204
204
 
@@ -505,7 +505,7 @@ Infer captures indexes at full fidelity — expression, partial (`where:`), uniq
505
505
 
506
506
  1. **Forgetting to re-emit after an edit.** `contract.json` and `contract.d.ts` go stale; downstream typecheck and `migration plan` see the old shape. Re-emit, or install the Vite plugin (`references/build.md`).
507
507
  2. **Editing the emitted artefacts.** `contract.json` and `contract.d.ts` are emitted; edits there round-trip away on the next emit. Edit the source.
508
- 3. **Wrong factory/import path for the TS builder.** `defineContract`, `field`, `model`, `rel` come from `@internal/postgres/contract-builder` (or `@internal/mongo/contract-builder`). On Postgres the imported `field` has the target's presets (`field.text()`, `field.temporal.timestamptz()`, `field.uuidString()`, …) but not an extension's; elsewhere, outside the callback overload, the available field constructors are `field.column(...)`, `field.generated(...)`, `field.namedType(...)`.
508
+ 3. **Wrong factory/import path for the TS builder.** `defineContract`, `field`, `model`, `rel` come from `@internal/postgres/contract-builder` (or `@internal/mongo/contract-builder`). On Postgres the facade also exports `type` and `gen` (`field.column(type.TimestamptzTemporal())`, `.onCreate(gen.uuid())`) without an extension's helpers; elsewhere, outside the callback overload, the available field constructors are `field.column(...)` and `field.namedType(...)`.
509
509
  4. **Reaching into internal packages from user code.** User-authored files (`prisma.config.ts`, `contract.ts`, `db.ts`, control clients) import only from `@internal/<target>/<subpath>` and `@internal/extension-<name>/<subpath>`. Imports from `@internal/cli/*`, `@internal/family-*`, `@internal/target-*`, `@internal/adapter-*`, `@internal/driver-*`, or `@internal/sql-contract-*` are framework-internal — the façade composes them for you. If a façade subpath you need is missing for your target, see *What Prisma 8 doesn't do yet* and route to `references/feedback.md`. The canonical worked examples are `examples/multi-extension-monorepo/app/prisma.config.ts` and `examples/prisma-8-postgis-demo/prisma.config.ts`.
510
510
  5. **Confusing the config `extensions` with the TS builder's `extensions`.** Same packs, two surfaces, one field name but two shapes: `ormConfig({ extensions: [pgvector] })` (array of *control* descriptors from `@internal/extension-<name>/control`) versus `defineContract({ extensions: { pgvector } })` (record of *pack* descriptors from `@internal/extension-<name>/pack`).
511
511
  6. **Writing a flat `prisma.config.ts`.** `export default defineConfig({ contract, extensions })` from the target config alone is the pre-rc.4 shape and fails with `CONFIG.VERSION_MARKER_MISSING`. Wrap it: `definePrismaConfig({ orm: ormConfig({...}) })`.
@@ -103,14 +103,15 @@ 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.PATH_UNREACHABLE` / `MIGRATION.MARKER_MISMATCH` | `db migrate`; `db migrate --show` raises `MARKER_MISMATCH` too | For `PATH_UNREACHABLE`, run `db migrate --show --db $URL` to inspect the path. Then run `migration plan --from <from> --to <target>`, or `migration list` to audit the graph — see `references/migration-review.md`. |
106
+ | `MIGRATION.MARKER_MISMATCH` | `db migrate`, `db migrate --show`, a Composer deploy | The database's marker is not in the migration graph, usually because a migration it applied was planned again or deleted. `why` names the last graph contract it applied and the missing migrations. Follow `references/migrations.md` § *A database whose marker is not in the migration graph*. Never reset or drop the database. |
107
+ | `MIGRATION.PATH_UNREACHABLE` | `db migrate`, a Composer deploy | The marker is in the graph but no migration reaches the target from it. Run `migration plan --from <marker> --to <target>`, then `db migrate`; `migration list` audits the graph. |
107
108
  | `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*. |
108
109
  | `MIGRATION.MISSING_INVARIANTS` | `migration status` `warn` diagnostic (exit 0) | The live marker reached the destination hash structurally but doesn't carry all invariants the target ref requires. Run `db migrate --to <name> --db $URL` to take a path that covers the missing invariants. See `references/migration-review.md`. |
109
110
  | `MIGRATION.MARKER_NOT_IN_HISTORY` / `CONTRACT.UNREADABLE` | `migration status` `warn` diagnostics (exit 0) | Read `severity` *and* `code`. Up-to-date / pending / no-marker states are not codes — read `spaces[].currentContract` and `migrations[].status` in the `--json` document. `references/migration-review.md` covers the marker-out-of-history flow. |
110
111
  | `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`. |
111
112
  | `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`. |
112
113
  | `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. |
113
- | `RUNTIME.TEMPORAL_UNAVAILABLE` | Runtime, first read or write touching a Temporal-backed column (`DateTemporal`, `TimestampTemporal(p)`, `TimestampInstant(p)`, `TimestamptzTemporal(p)`, `TimeTemporal(p)`, and `Date`, `DateTime` and `Time`) or a `temporal.updatedAt()` clock | No global `Temporal`. Node.js 26.8.2 and later ship `globalThis.Temporal`; 26.8.1 and earlier — including every 22 and 24 — do not. Either `import 'temporal-polyfill/full/global'` before the first query, or author the column as `DateString` / `TimestampString(p)` / `TimestamptzString(p)` / `TimeString(p)` to read ISO 8601 text. |
114
+ | `RUNTIME.TEMPORAL_UNAVAILABLE` | Runtime, first read or write touching a Temporal-backed column (`DateTemporal`, `TimestampTemporal(p)`, `TimestampInstant(p)`, `TimestamptzTemporal(p)`, `TimeTemporal(p)`, and `Date`, `DateTime` and `Time`) or a `temporal.UpdatedAt` clock | No global `Temporal`. Node.js 26.8.2 and later ship `globalThis.Temporal`; 26.8.1 and earlier — including every 22 and 24 — do not. Either `import 'temporal-polyfill/full/global'` before the first query, or author the column as `DateString` / `TimestampString(p)` / `TimestamptzString(p)` / `TimeString(p)` to read ISO 8601 text. |
114
115
  | `ORM.RELATION_MUTATION_UNSUPPORTED` | ORM nested `create` / `connect` on an N:M relation whose junction has required payload columns | Write the junction table directly or use the SQL builder (`meta.junction`). |
115
116
  | `RUNTIME.ABORTED` (`details.phase` = `encode\|decode\|stream\|beforeEncode\|onRow`) | Runtime, when an `AbortSignal` fires mid-execute | Cancellation, not a bug; surface to the caller. |
116
117
  | `SqlQueryError` (no dotted code) | Raw-SQL paths surfacing a driver error | Inspect `sqlState` + `constraint` + `table` + `column`. Postgres `23505` = unique violation, `23503` = foreign-key violation, etc. Fix the data or the schema. |
@@ -12,7 +12,7 @@ The skill teaches *the system's mental model* — what a ref is, what a marker i
12
12
  - User asks *"what migrations will run when I merge this?"* or *"what's about to run on deploy?"*.
13
13
  - User hit a concurrent-migration conflict (`main` advanced while their branch was open).
14
14
  - User wants to wire up a `staging` / `production` ref so CI can deploy against it.
15
- - User wants to run a migration against an environment that isn't the local dev DB.
15
+ - User wants to run a migration against a deployed environment.
16
16
  - User asks about CI integration for migrations.
17
17
 
18
18
  ## When Not to Use
@@ -79,9 +79,9 @@ These codes surface on `migration plan`, `migration ref set`, and `db migrate`
79
79
 
80
80
  | Code | When | Meaning | Next move |
81
81
  |---|---|---|---|
82
- | `MIGRATION.HASH_NOT_IN_GRAPH` | `migration plan` (non-empty graph) or `migration ref set` | Resolved hash is not a node in the on-disk migration graph — typical when the default `db` ref points past the graph tip after dev-only `db update` cycles. | `migration plan --from <reachable-ref>` (e.g. `--from production`); or realign the ref with `migration ref set db <graph-node-hash>`. |
82
+ | `MIGRATION.HASH_NOT_IN_GRAPH` | `migration plan` (non-empty graph) or `migration ref set` | Resolved hash is not a node in the on-disk migration graph — typical when the default `db` ref points past the graph tip after `db update` cycles. | `migration plan --from <reachable-ref>` (e.g. `--from production`); or realign the ref with `migration ref set db <graph-node-hash>`. |
83
83
  | `MIGRATION.SNAPSHOT_MISSING` | `migration plan` | A named ref has no pointer file (`<name>.json`), and the hash being resolved isn't a node in the migration graph either. | `migration ref set <name> <hash>` to create the ref, `db update --advance-ref <name>` to advance it, or pass a hash that is a graph node. |
84
- | `MIGRATION.MARKER_MISMATCH` | `db migrate` (pre-DDL, before the runner), `db migrate --show` | Live DB marker hash is not a graph node — drift the offline planner cannot see. | `migration plan --from <graph-tip>` if the marker is canonical; `migration ref set db <marker-hash>` if the on-disk graph is canonical; investigate out-of-band applies. |
84
+ | `MIGRATION.MARKER_MISMATCH` | `db migrate` (pre-DDL, before the runner), `db migrate --show` | Live DB marker hash is not a graph node. Usually a migration the database applied was planned again or deleted. | Follow the error's next actions, and `references/migrations.md` § *A database whose marker is not in the migration graph*. Never reset the database. |
85
85
  | `MIGRATION.PATH_UNREACHABLE` | `db migrate` (path resolution) | No migration path from the current marker to the resolved target in the on-disk graph. | Read the improved `fix` payload — it names `fromHash` / `targetHash` and suggests `migration plan --from <from> --to <target>`; run `migration list` to inspect the graph. |
86
86
 
87
87
  ## Workflow — *"What's about to run on deploy?"*
@@ -20,6 +20,7 @@ Once the contract changes, you choose how the change reaches the database. This
20
20
  - User wants to run pending migrations against a local DB.
21
21
  - User hit `MIGRATION.HASH_MISMATCH`, `MIGRATION.UNFILLED_PLACEHOLDER`, or a partially-applied migration.
22
22
  - User mentions: *migrate, migration, db push, db update, `prisma migrate dev`, `prisma migrate deploy`, drift, hash mismatch, data backfill*.
23
+ - A deploy or `db migrate` fails with `MIGRATION.MARKER_MISMATCH` (older Composer releases: "no authored path"), or someone proposes resetting a database → *A database whose marker is not in the migration graph* below. For `MIGRATION.PATH_UNREACHABLE`, where the marker is in the graph but no migration reaches the target, plan from the marker to the target instead (`references/debug.md`).
23
24
 
24
25
  ## When Not to Use
25
26
 
@@ -30,7 +31,7 @@ Once the contract changes, you choose how the change reaches the database. This
30
31
 
31
32
  ## Key Concepts
32
33
 
33
- - **`db update` (quick path).** Reads the emitted contract, diffs against the live DB, applies the change. Optional `--dry-run` prints the plan without executing. Before an apply it asks what each operation that would lose data means, answered by `--delete <subject>` or `--rename <subject>:<new name>`, and whether each operation that would change who can read or write a model's data may run, answered by `--allow <Model>` (see *Answer the data-loss questions* below). **Writes no migration directory.** Operations needing data transforms are not handled by this path — `db update` excludes the `data` operation class entirely and short-circuits where a data transform would be required. It refuses `--convert` and `--backfill` (`MIGRATION.STATEMENT_NEEDS_MIGRATION_FILE`) and prints the `migration plan` command to run instead. Use only against a database that has no shared history with anyone else (your local dev DB).
34
+ - **`db update` (quick path).** Reads the emitted contract, diffs against the live DB, applies the change. Optional `--dry-run` prints the plan without executing. Before an apply it asks what each operation that would lose data means, answered by `--delete <subject>` or `--rename <subject>:<new name>`, and whether each operation that would change who can read or write a model's data may run, answered by `--allow <Model>` (see *Answer the data-loss questions* below). **Writes no migration directory.** Operations needing data transforms are not handled by this path — `db update` excludes the `data` operation class entirely and short-circuits where a data transform would be required. It refuses `--convert` and `--backfill` (`MIGRATION.STATEMENT_NEEDS_MIGRATION_FILE`) and prints the `migration plan` command to run instead. Use it on a database whose migration history does not need to be kept (a local, development, staging or preview database), shared or not. Never use it on a database that changes only through migrations, such as production: it leaves no migration behind.
34
35
  - **`migration plan` (formal path).** Reads the emitted contract, diffs it against a resolved origin — explicit `--from`, else the `db` ref, else the empty database; there is no "head of the graph" to chain from (see `references/migration-model.md`) — and writes a new migration package under `migrations/app/<YYYYMMDDTHHMM>_<snake_slug>/`. A plan that would lose data is written only once `--delete`, `--rename` or, for a type change, `--convert` says what each such operation means. The package's `migration.ts` contains `placeholder(...)` calls only where `--convert` or `--backfill` asked for a slot (see *Type changes and new required fields*).
35
36
  - **The `app/` segment in migration paths is the consuming application's contract-space id.** Every migration *you* author lives under `migrations/app/`. Extensions your contract depends on get their own sibling directories (`migrations/<extension-space-id>/`) — those are managed by the extension package and you don't write into them. The `app/` segment lands automatically the first time you run `migration plan` / `db init` against an app-level config.
36
37
  - **Migration package files** (inside each `migrations/app/<dir>/`):
@@ -85,9 +86,10 @@ Treat the rendered import lines as framework-managed on both targets:
85
86
 
86
87
  | Situation | Path | Why |
87
88
  |---|---|---|
88
- | Local dev, schema in flux | `db update` | Fast, interactive, no migration files. |
89
- | Shared branch with other developers | `migration plan` + `db migrate` | Replayable, reviewable, content-hashed. |
90
- | Anything reaching production | `migration plan` + `db migrate` | Production must run a reviewed, hashed migration. |
89
+ | Moving a database whose history does not need to be kept (local, development, staging, preview) to the contract | `db update` | Fast, no migration files. Works whether or not the database is shared. |
90
+ | A change other developers or environments will receive | `migration plan` + `db migrate` | Replayable, reviewable, content-hashed. |
91
+ | A database that changes only through migrations, such as production | `migration plan` + `db migrate` | It must run a reviewed, hashed migration. |
92
+ | A deploy says there is no migration path, or `MIGRATION.MARKER_MISMATCH` | See *A database whose marker is not in the migration graph* | Never reset the database. |
91
93
  | Adding a column that needs a backfill | `migration plan --backfill Model.field` (writes `placeholder`), edit `migration.ts`, self-emit, then `db migrate` | `db update` does not author data transforms; the formal path does. Without `--backfill`, existing rows get a temporary value. |
92
94
  | Changing a field's type so values may not survive | `migration plan --convert Model.field`, fill `using`, self-emit, `db migrate` | Or `--delete Model.field` to let the database cast; the cast may cut or round values (Postgres cuts a longer text to a shorter `VarChar`), and a value it cannot cast fails the apply. |
93
95
  | Recovering from drift (DB diverged from contract) | `db sign` after manual fix, *or* `migration plan` if PN can plan the fix | Depends on which side is right. See *Recover from drift* below. |
@@ -139,7 +141,7 @@ If the `db` ref's pointer is itself missing and the hash isn't a graph node eith
139
141
 
140
142
  **After plain `db migrate`.** `db migrate` does not implicitly advance the `db` ref (production-shaped commands stay explicit). The live marker advances while the ref may lag. Refresh with `db update` (no-op on DB when already current) or `db migrate --advance-ref db` in the same invocation.
141
143
 
142
- **When to switch paths.** Use `db update` while the schema is in flux on a solo dev database. Switch to `migration plan` + `db migrate` when the change needs a reviewable, replayable migration — typically before opening a PR or touching any shared environment. The `db` ref bridges the two: it captures dev iteration state on disk so the first formal plan knows where you left off.
144
+ **When to switch paths.** Use `db update` while the schema is in flux, on a database whose migration history does not need to be kept (a local, development, staging or preview database). Switch to `migration plan` + `db migrate` when the change needs a reviewable, replayable migration — typically before opening a PR, and always for a database that changes only through migrations, such as production. The `db` ref bridges the two: it captures dev iteration state on disk so the first formal plan knows where you left off.
143
145
 
144
146
  **Graph-node rule (plan time).** Any hash used as a `from` end — explicit `--from`, default `db` ref, or ref name — must already be a node in the on-disk migration graph once the graph is non-empty. The auto-baseline two-bundle emission is the one exception: it applies only on an **empty** graph with a non-null ref-resolved `from` and an available store entry. If the ref's pointer is missing and the hash isn't a graph node either, plan refuses with `MIGRATION.SNAPSHOT_MISSING` instead.
145
147
 
@@ -458,11 +460,49 @@ The concept: `db sign` rewrites the marker to the current contract hash and move
458
460
  pnpm prisma db sign --db $DATABASE_URL
459
461
  ```
460
462
 
463
+ ## Workflow — A database whose marker is not in the migration graph
464
+
465
+ **The symptom.** `db migrate` or a deploy fails with `MIGRATION.MARKER_MISMATCH`: the database's marker names a contract that no migration in `migrations/` starts or ends at. (Composer releases older than this skill print it as `MIGRATION_PATH_NOT_FOUND`, "no authored path from the database's current schema".)
466
+
467
+ **The usual cause.** The database applied a migration that was later planned again or deleted. The common case is a branch deployed to a shared environment, then rebased: each new plan of its migration has a new target hash, and the version the database applied is gone. The error's `why` names the last contract in the graph the database applied (`meta.lastGraphHash`) and the applied migrations that are no longer on disk (`meta.missingMigrations`).
468
+
469
+ **Never reset or drop the database.** It can always be moved. Pick the recovery by what kind of database it is.
470
+
471
+ When the error names an extension's contract space (`meta.spaceId` is not `app`), that space's migrations come with the extension package: install a version of the extension whose migrations include the database's contract (`prisma migration list --space <space>` lists them), or ask its maintainers. The recoveries below are for the application space.
472
+
473
+ ### When the database's history does not need to be kept (local, development, staging, preview)
474
+
475
+ Reconcile it to the target with `db update`:
476
+
477
+ 1. `prisma db update --db $DATABASE_URL --to <target> --dry-run`, and read every operation, above all every drop.
478
+ 2. `db update` does not run data transforms or seed steps. When the error has no `meta.lastGraphHash`, the ledger cannot say which migrations it would skip: stop and ask a person. Otherwise read the data transforms of the migrations on disk between `meta.lastGraphHash` and the target (`prisma migration list`, then each one's `migration.ts`). The migrations in `meta.missingMigrations` already ran on this database, so never repeat them; read them, in ledger order (`prisma migration log`) from the git commits that held them, only to learn what the database already holds, since a migration on disk may be a new plan of one of them. If a missing migration's source cannot be recovered, stop and ask a person. For each on-disk transform whose data matters and whose work the database does not already hold:
479
+ - if it moves data into a new column or table, create that column or table by hand and copy the data with SQL, the way the transform would;
480
+ - if it inserts rows the application needs, insert them by hand.
481
+
482
+ Run the dry run again to confirm the drops that remain lose nothing you need.
483
+ 3. `prisma db update --db $DATABASE_URL --to <target>`, answering the data-loss questions with `--delete` or `--rename` (see *Answer the data-loss questions*).
484
+ 4. Deploy again. The deploy finds the database at its target.
485
+
486
+ ### When the database changes only through migrations (production)
487
+
488
+ Author migrations that bring it back onto the graph, and deploy them. The marker's contract is `<marker hash>`; the last graph contract is `meta.lastGraphHash`. When the error has no `lastGraphHash`, the ledger shows no contract the database applied that is still in the graph, or could not be read: check with `prisma migration log`, and if no applied contract is in the graph, stop and ask a person.
489
+
490
+ `migration plan --to` accepts only contracts already in the graph, so the database's contract goes through the contract source:
491
+
492
+ 1. Commit or copy aside any uncommitted edits to the contract source; step 4 restores it from `HEAD`. Then put the contract the database is at into the contract source. Prefer the contract source as it was when the deleted migration was planned: find the commit with `git log --all --oneline -- migrations/snapshots/<marker hash>` and check out the contract source file from it. If git no longer has it, infer it from the database into a separate file, `prisma contract infer --db $DATABASE_URL --output ./inferred.prisma` (without `--output` it overwrites the contract source), then copy that file over the contract source.
493
+ 2. `prisma contract emit`, and check that the emitted storage hash is `<marker hash>`. If it is not, stop and ask a person.
494
+ 3. Plan a migration from the last graph contract to the database's contract: `prisma migration plan --from <lastGraphHash> --name rejoin_<database>`. Nothing will run it against this database; it only puts the database's contract in the graph. A fresh database could still run it, so copy the data transforms of every migration in `meta.missingMigrations` into it, in ledger order (`prisma migration log`), from the git commits that held them, and review them.
495
+ 4. Restore the contract source (`git checkout HEAD -- <contract source>`; without `HEAD` git restores the version step 1 staged), run `prisma contract emit`, then plan from the database's contract to the target: `prisma migration plan --from <marker hash> --name <slug>`. A plan that loses data needs `--delete` or `--rename` (see *Answer the data-loss questions*). Review it like any migration, and add data transforms for any data the deleted migration's replacement would have moved.
496
+ 5. Check how a fresh database reaches the target: `prisma migration status --from @empty --to <target>` lists the migrations it would run. Path finding takes the shortest route, so if these two migrations make a shorter route from the last graph contract to the target than the main line, a new database would take it. When they do, ask a person how to proceed.
497
+ 6. Commit both migrations and deploy.
498
+
499
+ Do not `db sign` the database to a contract you inferred: that rewrites its marker without a migration.
500
+
461
501
  ## Workflow — Recover from drift
462
502
 
463
503
  The concept: drift means `db verify` reports the live DB schema doesn't match what the marker says it should be. Two valid moves, picked by which side is correct:
464
504
 
465
- - **The contract is right; the DB is wrong** → run a migration. Either `db update` (quick path, dev DB only) or `migration plan` + `db migrate` (everywhere else).
505
+ - **The contract is right; the DB is wrong** → run a migration. Either `db update`, on a database whose migration history does not need to be kept (a local, development, staging or preview database), or `migration plan` + `db migrate`, which every database accepts and a database that changes only through migrations, such as production requires.
466
506
  - **The DB is right; the contract or marker is wrong** → edit the contract to match the DB (see `references/contract.md`), emit, then `db sign` to refresh the marker. The sign also moves the `db` ref to the signed hash; when the migration graph is non-empty and that hash is not a graph node, the next default `migration plan` refuses with `MIGRATION.HASH_NOT_IN_GRAPH` (see *The forgot-the-flag pitfall* above for the recovery).
467
507
 
468
508
  The diagnostic that reveals which side is right:
@@ -528,7 +568,7 @@ In a terminal the command asks each question in turn; type `delete`, `allow`, or
528
568
 
529
569
  ## Common Pitfalls
530
570
 
531
- 1. **Using `db update` against shared or production databases.** Never. The change leaves no migration history. Use `migration plan` + `db migrate`.
571
+ 1. **Using `db update` on a database that changes only through migrations, such as production.** The change leaves no migration history. Use `migration plan` + `db migrate`. A shared development or staging database is fine.
532
572
  2. **Skipping a data transform.** Leaving `placeholder(...)` in `migration.ts` makes the next `db migrate` throw `MIGRATION.UNFILLED_PLACEHOLDER`. Fill every placeholder slot and self-emit.
533
573
  3. **Editing `ops.json` directly.** It's the canonical artifact, not the authoring source. Edit `migration.ts`, then self-emit.
534
574
  4. **Forgetting to self-emit after editing `migration.ts`.** The next `db migrate` either uses the stale `ops.json` (if you only added comments) or fails with `MIGRATION.HASH_MISMATCH` (if you changed operations). Always self-emit.
@@ -540,7 +580,7 @@ In a terminal the command asks each question in turn; type `delete`, `allow`, or
540
580
  9. **Planning with no `db` ref and no `--from` in a project that already has migrations.** The origin falls through to the empty database, which would make the plan a full-create migration; `migration plan` refuses with `MIGRATION.PLAN_ORIGIN_UNKNOWN` rather than writing it. Pick the exit that matches your intent — the error lists them, and `references/migration-model.md` § *The trap* explains which to choose.
541
581
  10. **Hand-authoring `migration.ts` from a blank file, or rewriting the rendered import line.** Migration files are framework-rendered — let `prisma migration plan` (or `migration new`) render the package, then edit only the holes the framework leaves for you. On Postgres leave the rendered `@internal/postgres/migration` (or `@internal/sqlite/migration`) import path alone; on Mongo leave `@prisma/orm-mongo/target/migration` as rendered. Add symbols to the existing import line rather than introducing new import paths.
542
582
  12. **Replaying migrations onto a database that is already ahead.** `db migrate` on a database with no marker runs every migration, skipping operations already applied. When the database is already past a migration (it has `x int8` where the migration adds `x int4`), the run stops at that migration's precheck with `MIGRATION.PRECHECK_FAILED`. Adopt such a database with `prisma db sign` (after `contract infer` if needed), not by replaying history.
543
- 13. **Running Prisma 7 `migrate` commands against Prisma 8.** Each one answers `CLI.COMMAND_MOVED` with its Prisma 8 command: `migrate dev` is `contract emit`, `migration plan --name <name>`, then `db migrate --advance-ref db`; `migrate deploy` is `db migrate`; `migrate reset` is also `db migrate`, but Prisma 8 never drops a database or deletes its data, so first drop and recreate the disposable database with its own tools; `migrate status` is `migration status`; `migrate diff` is `db update --dry-run`, or `migration plan` to write a migration package; `migrate resolve` is `db sign <migration>`, which moves the database marker to that migration after checking its schema, but leaves `migration status` without an applied mark. While Prisma 7 still owns the migrations, run every one of them except `migrate diff`, whose replacement only reads, with Prisma 7's CLI instead.
583
+ 13. **Running Prisma 7 `migrate` commands against Prisma 8.** Each one answers `CLI.COMMAND_MOVED` with its Prisma 8 command: `migrate dev` is `contract emit`, `migration plan --name <name>`, then `db migrate --advance-ref db`; `migrate deploy` is `db migrate`; `migrate reset` has no equivalent, because Prisma 8 has no reset: `db update` brings the database to the contract instead, asking before it loses data, but it keeps existing rows and runs no seed steps or data transforms (a database that changes only through migrations is moved with `db migrate`); `migrate status` is `migration status`; `migrate diff` is `db update --dry-run`, or `migration plan` to write a migration package; `migrate resolve` is `db sign <migration>`, which moves the database marker to that migration after checking its schema, but leaves `migration status` without an applied mark. While Prisma 7 still owns the migrations, run every one of them except `migrate diff`, whose replacement only reads, with Prisma 7's CLI instead.
544
584
 
545
585
  ## What Prisma 8 doesn't do yet
546
586
 
@@ -569,7 +609,7 @@ The CLI collects anonymous usage data by default. To opt out, set `PRISMA_DISABL
569
609
  ## Checklist
570
610
 
571
611
  - [ ] Contract emitted (`contract.json` + `contract.d.ts` current).
572
- - [ ] Chose the right path: `db update` (local dev) vs `migration plan` + `db migrate` (anything shared).
612
+ - [ ] Chose the right path: `db update` (a database whose history does not need to be kept) vs `migration plan` + `db migrate` (a change others will receive, or a database that changes only through migrations).
573
613
  - [ ] For `migration plan`: confirmed the output's `from:` line names the intended origin — not `(baseline)` over an existing graph (`references/migration-model.md`).
574
614
  - [ ] For `migration plan`: ran `migration show <dir>` to review before `db migrate`.
575
615
  - [ ] Filled every `placeholder(...)` in `migration.ts` (if any), built against `endContract`.
@@ -577,6 +617,6 @@ The CLI collects anonymous usage data by default. To opt out, set `PRISMA_DISABL
577
617
  - [ ] Self-emitted (`node <package dir>/migration.ts`) after editing the TS.
578
618
  - [ ] Ran `db migrate` (or `db update`) and saw it complete.
579
619
  - [ ] Used `db verify` only when diagnosing drift — not as a routine post-apply step.
580
- - [ ] Did NOT use `db update` against a shared or production database.
620
+ - [ ] Did NOT use `db update` on a database that changes only through migrations, such as production, and did NOT reset or drop any database to fix a migration problem.
581
621
  - [ ] Did NOT edit `ops.json` directly.
582
622
  - [ ] Answered each data-loss question deliberately: `--rename` for a rename, `--delete` only for data that may go, `--allow` only for an access change that is meant.
@@ -416,13 +416,13 @@ await deleteMatching(Post.byAuthor(userId)).toArray();
416
416
 
417
417
  A piece of a query used in several places is a function. Do not build a filter object and spread it into each query; write a function and pass it to `.where(...)`, `.orderBy(...)` or `.with(...)`. A **row fragment** is a function of the model accessor, and `.where(...)` and `.orderBy(...)` take it. A **query fragment** (a **fragment** for short) is a function from a collection to a collection, and `.with(...)` runs it. A **scope** is a fragment that only imposes conditions on the query, such as `createdSince` below, and is also run with `.with(...)`. When the condition is a function of one row and needs no declared fields, pass a row fragment to `.where(...)`. When the same condition should apply to every model that has some fields, write a scope: it declares the fields, checks them at run time, and returns the collection with the `Filtered` fact. `.with(...)` also runs what `.where(...)` cannot express, such as a shared `select` and `include`, an order, a limit or offset, or a variant.
418
418
 
419
- **The same filter on several models.** Define a scope with `db.orm.fragment(fields, body)`; the method is named `fragment` because it cannot know whether the body only filters. Declare each field the fragment needs with the same builder the schema uses, from the `field` that `@prisma/orm-postgres/contract-builder` exports, adding `.optional()` for a field that may be null. The body sees only those fields:
419
+ **The same filter on several models.** Define a scope with `db.orm.fragment(fields, body)`; the method is named `fragment` because it cannot know whether the body only filters. Declare each field the fragment needs with the same builder the schema uses, from the `field` and `type` that `@prisma/orm-postgres/contract-builder` exports, adding `.optional()` for a field that may be null. The body sees only those fields:
420
420
 
421
421
  ```typescript
422
- import { field } from '@prisma/orm-postgres/contract-builder';
422
+ import { field, type } from '@prisma/orm-postgres/contract-builder';
423
423
 
424
424
  const createdSince = (since: Temporal.Instant) =>
425
- db.orm.fragment({ createdAt: field.temporal.timestamptz() }, (rows) =>
425
+ db.orm.fragment({ createdAt: field.column(type.TimestamptzTemporal()) }, (rows) =>
426
426
  rows.where((r) => r.createdAt.gte(since)),
427
427
  );
428
428
 
@@ -430,7 +430,7 @@ await db.orm.public.User.with(createdSince(since)).all();
430
430
  await db.orm.public.Post.with(createdSince(since)).deleteAll();
431
431
  ```
432
432
 
433
- Pick the builder whose codec matches the field's codec in `contract.d.ts`: a PSL `DateTime` is `field.temporal.timestamptz()` (`pg/timestamptz-temporal@1`), a `String` is `field.text()` (`pg/text@1`), a `Uuid` is `field.uuidNative()` (`pg/uuid@1`). `field.column(columnType)` is the explicit form. A package that offers a fragment and does not import the facade writes `{ codecId: 'pg/text@1', nullable: false }`, with a codec of the contract. For a list field such as `String[]`, add `.many()` to the builder or `many: { elementNullable: false }` to the object; for a `String?[]`, whose elements may be null, add `.many({ elementsNullable: true })` or `many: { elementNullable: true }`. Without it the declaration does not match a list field, and with it the element nullability must match too. A list of value objects such as `Address[]` is stored as one `jsonb` value and is still a list: `field.column(jsonbColumn).many()`. The body may call `where`, `orderBy`, `limit` and `offset`. The result keeps the collection's class and records the filter, so `update` and `delete` are allowed after a fragment that filters. `updateAll`, `deleteAll` and their `AndCount` forms change every matching row and throw `ORM.ARGUMENT_INVALID` when the chain has a `limit`, `offset`, `cursor`, `distinct` or `distinctOn`, so do not put a limit in a fragment that will be followed by one of them. `update` and `delete` change the one row `first()` returns, so the order, offset, cursor, `distinct` and `distinctOn` choose it, and after `limit(0)` they change nothing and return `null`; `update` with a relation callback throws on an order, a limit, an offset, a cursor, `distinct` or `distinctOn`, because it finds its row by the filter alone. A model without the field, or with the field under another codec or nullability, is a compile error, and a run-time `ORM.FIELD_UNKNOWN`. A custom collection class carries no namespace in its type, so at compile time it matches only a field that every model of that name has, with the same codec and nullability, and its real namespace is checked at run time. The codec, the nullability, whether the field is a list and the nullability of its elements are compared; the column type's parameters are not, so `field.uuidString()` (`char(36)`) also matches a `char(10)` field.
433
+ Pick the builder whose codec matches the field's codec in `contract.d.ts`: a PSL `DateTime` is `field.column(type.DateTime())` (`pg/timestamptz-temporal@1`), a `String` is `field.column(type.String())` (`pg/text@1`), a `Uuid` is `field.column(type.Uuid())` (`pg/uuid@1`). `field.column(columnType)` is the explicit form. A package that offers a fragment and does not import the facade writes `{ codecId: 'pg/text@1', nullable: false }`, with a codec of the contract. For a list field such as `String[]`, add `.many()` to the builder or `many: { elementNullable: false }` to the object; for a `String?[]`, whose elements may be null, add `.many({ elementsNullable: true })` or `many: { elementNullable: true }`. Without it the declaration does not match a list field, and with it the element nullability must match too. A list of value objects such as `Address[]` is stored as one `jsonb` value and is still a list: `field.column(jsonbColumn).many()`. The body may call `where`, `orderBy`, `limit` and `offset`. The result keeps the collection's class and records the filter, so `update` and `delete` are allowed after a fragment that filters. `updateAll`, `deleteAll` and their `AndCount` forms change every matching row and throw `ORM.ARGUMENT_INVALID` when the chain has a `limit`, `offset`, `cursor`, `distinct` or `distinctOn`, so do not put a limit in a fragment that will be followed by one of them. `update` and `delete` change the one row `first()` returns, so the order, offset, cursor, `distinct` and `distinctOn` choose it, and after `limit(0)` they change nothing and return `null`; `update` with a relation callback throws on an order, a limit, an offset, a cursor, `distinct` or `distinctOn`, because it finds its row by the filter alone. A model without the field, or with the field under another codec or nullability, is a compile error, and a run-time `ORM.FIELD_UNKNOWN`. A custom collection class carries no namespace in its type, so at compile time it matches only a field that every model of that name has, with the same codec and nullability, and its real namespace is checked at run time. The codec, the nullability, whether the field is a list and the nullability of its elements are compared; the column type's parameters are not, so `field.column(type.Char(36))` (`char(36)`) also matches a `char(10)` field.
434
434
 
435
435
  For a filter used inside a larger `where`, a plain function of the row works too. Type the field with `CodecField<Contract, CodecId, Nullable>`, the type of any field with that codec:
436
436
 
@@ -261,7 +261,7 @@ A reference table — not a script to recite at the user. Commands surface in th
261
261
  |---|---|---|
262
262
  | Apply the current contract to the DB the first time | `prisma db init` | this skill |
263
263
  | Re-emit `contract.json` + `contract.d.ts` after editing the contract source | `prisma contract emit` | `references/contract.md` |
264
- | Quick dev-only schema sync (no migration history kept) | `prisma db update` | `references/migrations.md` |
264
+ | Move a database whose history does not need to be kept to the contract (no migration written) | `prisma db update` | `references/migrations.md` |
265
265
  | Plan a migration from a contract diff | `prisma migration plan --name <slug>` | `references/migrations.md` |
266
266
  | Apply pending migrations | `prisma db migrate` | `references/migrations.md` |
267
267
  | Inspect the live database | `prisma db schema` | `references/debug.md` |
@@ -290,7 +290,7 @@ Switch authoring later by re-running `prisma orm init` in the same directory. Th
290
290
  ## What Prisma 8 doesn't do yet
291
291
 
292
292
  - **Migration from another ORM.** Prisma 8 doesn't migrate your schema *from* Drizzle / Sequelize / TypeORM / Kysely / Knex / a raw driver. A Prisma 6 MongoDB schema and a Prisma 7 Postgres schema are the exception: they can be the contract source as they are (`prisma6Schema` / `prisma7Schema`, see `references/contract.md`). For the others: install the matching `@internal/migrate-from-<orm>-skill` if one exists for your source, or treat the source as a brownfield database and `contract infer` from it. If you need a guided migration flow built-in, file a feature request via the `references/feedback.md` skill.
293
- - **`prisma db push`-style production sync.** `db update` is the quick development path; for production, use migrations (`migration plan` + `db migrate`). PN deliberately does not offer a "push-to-prod-without-a-migration" surface — see `references/migrations.md`.
293
+ - **`prisma db push`-style production sync.** `db update` is for databases whose migration history does not need to be kept (local, development, staging, preview); for production, use migrations (`migration plan` + `db migrate`). PN deliberately does not offer a "push-to-prod-without-a-migration" surface — see `references/migrations.md`.
294
294
  - **Studio / GUI database browser.** Use `prisma db schema` for a CLI tree-style summary of the live DB. If you need an interactive UI, file a feature request via the `references/feedback.md` skill.
295
295
 
296
296
  ## Reference Files