@prisma/orm-mysql 8.0.0-rc.23-dev.13 → 8.0.0-rc.24-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/dist/{mysql-CnLEkVDo-BAfRi9KG.d.mts → mysql-BFn2oufX-BCZx2s2u.d.mts} +12 -4
  2. package/dist/mysql-BFn2oufX-BCZx2s2u.d.mts.map +1 -0
  3. package/dist/{mysql-static-B6N5R6uW-CVXRbAtD.mjs → mysql-static-B7wJV95a-RfQM3jNq.mjs} +4 -4
  4. package/dist/mysql-static-B7wJV95a-RfQM3jNq.mjs.map +1 -0
  5. package/dist/runtime.d.mts +3 -2
  6. package/dist/runtime.d.mts.map +1 -1
  7. package/dist/runtime.mjs +31 -5
  8. package/dist/runtime.mjs.map +1 -1
  9. package/dist/static.d.mts +1 -1
  10. package/dist/static.mjs +1 -1
  11. package/package.json +8 -8
  12. package/skills/prisma-8/SKILL.md +1 -1
  13. package/skills/prisma-8/references/contract.md +3 -1
  14. package/skills/prisma-8/references/migrations.md +5 -3
  15. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/instructions.md +319 -0
  16. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/scripts/mongo-convenience-date-time-types/rewrite-mongo-date-types.ts +220 -0
  17. package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/scripts/mongo-type-helpers/rewrite-mongo-field-types.ts +621 -0
  18. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/instructions.md +304 -0
  19. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/scripts/mongo-convenience-date-time-types/rewrite-mongo-date-types.ts +220 -0
  20. package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.23-to-8.0.0-rc.24/scripts/mongo-type-helpers/rewrite-mongo-field-types.ts +621 -0
  21. package/dist/mysql-CnLEkVDo-BAfRi9KG.d.mts.map +0 -1
  22. package/dist/mysql-static-B6N5R6uW-CVXRbAtD.mjs.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { MysqlIsolationLevel } from "@prisma/orm-target-mysql/target/runtime";
1
2
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
2
3
  import { ExecutionContext, Runtime, SqlExecutionOptions, SqlExecutionStackWithDriver, SqlRuntimeExtensionDescriptor, ToSqlMember, TransactionContext } from "@prisma/orm-family-sql/runtime";
3
4
  import { NamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
@@ -7,7 +8,7 @@ import { Contract } from "@prisma/orm-framework/contract/types";
7
8
  import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
8
9
  import { Db, RawLane } from "@prisma/orm-family-sql/builder/types";
9
10
  import { RuntimeScope } from "@prisma/orm-family-sql/relational-core/types";
10
- //#region ../../../3-targets/mysql/1-mysql/9-facade/dist/mysql-CnLEkVDo.d.mts
11
+ //#region ../../../3-targets/mysql/1-mysql/9-facade/dist/mysql-BFn2oufX.d.mts
11
12
  //#region src/static/mysql-static.d.ts
12
13
  type UnboundSql$1<TContract extends Contract<SqlStorage>> = Db<TContract>[typeof UNBOUND_NAMESPACE_ID];
13
14
  type UnboundEnums<TContract extends Contract<SqlStorage>> = NamespacedEnums<TContract>[typeof UNBOUND_NAMESPACE_ID];
@@ -32,6 +33,12 @@ declare function mysqlStatic<TContract extends Contract<SqlStorage>>(options: {
32
33
  readonly extensions?: readonly SqlRuntimeExtensionDescriptor<MysqlTargetId>[];
33
34
  }): MysqlStaticContext<TContract>;
34
35
  //#endregion
36
+ //#region src/runtime/mysql-options.d.ts
37
+ interface MysqlTransactionOptions {
38
+ readonly isolationLevel?: MysqlIsolationLevel | undefined;
39
+ readonly timeout?: number | null | undefined;
40
+ }
41
+ //#endregion
35
42
  //#region src/runtime/mysql.d.ts
36
43
  type MysqlTargetId = 'mysql';
37
44
  type OrmClient<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses> = ReturnType<typeof orm<TContract, TCollections>>;
@@ -56,7 +63,7 @@ interface MysqlClient<TContract extends Contract<SqlStorage>, TCollections exten
56
63
  readonly url: string;
57
64
  }): Promise<Runtime>;
58
65
  runtime(): Runtime;
59
- transaction<R>(fn: (tx: MysqlTransactionContext<TContract, TCollections>) => PromiseLike<R>): Promise<R>;
66
+ transaction<R>(fn: (tx: MysqlTransactionContext<TContract, TCollections>) => PromiseLike<R>, options?: MysqlTransactionOptions): Promise<R>;
60
67
  close(): Promise<void>;
61
68
  [Symbol.asyncDispose](): Promise<void>;
62
69
  }
@@ -66,6 +73,7 @@ interface MysqlOptionsBase extends SqlExecutionOptions<MysqlTargetId> {
66
73
  */
67
74
  readonly stream?: boolean;
68
75
  readonly poolOptions?: MysqlPoolOptions;
76
+ readonly transactionOptions?: MysqlTransactionOptions | undefined;
69
77
  }
70
78
  type MysqlOptions<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> = MysqlOptionsBase & {
71
79
  readonly contract: TContract;
@@ -91,5 +99,5 @@ type MysqlOptions<TContract extends Contract<SqlStorage>, TCollections extends C
91
99
  */
92
100
  declare function mysql<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses>(options: MysqlOptions<TContract, TCollections>): MysqlClient<TContract, TCollections>;
93
101
  //#endregion
94
- export { MysqlQueryMembers as a, MysqlTargetId as c, mysqlStatic as d, MysqlOrm as i, MysqlTransactionContext as l, MysqlOptions as n, MysqlStaticContext as o, MysqlOptionsBase as r, MysqlStaticMembers as s, MysqlClient as t, mysql as u };
95
- //# sourceMappingURL=mysql-CnLEkVDo-BAfRi9KG.d.mts.map
102
+ export { MysqlQueryMembers as a, MysqlTargetId as c, mysql as d, mysqlStatic as f, MysqlOrm as i, MysqlTransactionContext as l, MysqlOptions as n, MysqlStaticContext as o, MysqlOptionsBase as r, MysqlStaticMembers as s, MysqlClient as t, MysqlTransactionOptions as u };
103
+ //# sourceMappingURL=mysql-BFn2oufX-BCZx2s2u.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql-BFn2oufX-BCZx2s2u.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-mysql/9-facade/dist/mysql-BFn2oufX.d.mts"],"mappings":";;;;;;;;;;;;KAWK,aAAa,kBAAkB,SAAS,eAAe,GAAG,kBAAkB;KAC5E,aAAa,kBAAkB,SAAS,eAAe,gBAAgB,kBAAkB;UACpF,mBAAmB,kBAAkB,SAAS,qBAAqB;WAClE,SAAS,iBAAiB;WAC1B,UAAU;WACV,OAAO,aAAa;WACpB,KAAK,aAAa;WAClB,KAAK,QAAQ;;;;;;;;;;;iBAWP,YAAY,kBAAkB,SAAS,aAAa;WAC1D,UAAU;WACV,sBAAsB,8BAA8B;IAC3D,mBAAmB;;;UAGb;WACC,iBAAiB;WACjB;;;;KAIN;KACA,UAAU,kBAAkB,SAAS,aAAa,qBAAqB,qBAAqB,kBAAkB,IAAI,WAAW;KAC7H,WAAW,kBAAkB,SAAS,eAAe,GAAG,kBAAkB;KAC1E,WAAW,kBAAkB,SAAS,aAAa,qBAAqB,qBAAqB,UAAU,WAAW,qBAAqB;;KAEvI,SAAS,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,gDAAgD,WAAW,WAAW,gBAAgB,WAAW,WAAW,gBAAgB,WAAW,WAAW,gBAAgB,qBAAqB;;UAE5Q,kBAAkB,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,cAAc,YAAY,cAAc;WACvK,KAAK,WAAW;WAChB,KAAK,SAAS,WAAW;WACzB,KAAK,QAAQ;;UAEd,wBAAwB,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,oBAAoB,kBAAkB,WAAW;WACtL,OAAO,mBAAmB;;UAE3B,mBAAmB,kBAAkB,SAAS,qBAAqB,mBAAmB;WACrF,OAAO,4BAA4B;;UAEpC,YAAY,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,kBAAkB,WAAW,eAAe,mBAAmB;EACjM,QAAQ;aACG;MACP,QAAQ;EACZ,WAAW;EACX,YAAY,GAAG,KAAK,IAAI,wBAAwB,WAAW,kBAAkB,YAAY,IAAI,UAAU,0BAA0B,QAAQ;EACzI,SAAS;GACR,OAAO,iBAAiB;;UAEjB,yBAAyB,oBAAoB;;;;WAI5C;WACA,cAAc;WACd,qBAAqB;;KAE3B,aAAa,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,uBAAuB;WAC/G,UAAU;WACV,cAAc;WACd;;;;;;;;;;;;;;;;;;;iBAmBM,MAAM,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,qBAAqB,SAAS,aAAa,WAAW,gBAAgB,YAAY,WAAW"}
@@ -1,14 +1,14 @@
1
+ import mysqlTarget, { MysqlContractSerializer } from "@prisma/orm-target-mysql/target/runtime";
1
2
  import mysqlAdapter from "@prisma/orm-target-mysql/adapter/runtime";
2
3
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
3
4
  import { createRawLane, sql } from "@prisma/orm-family-sql/builder/runtime";
4
5
  import { createExecutionContext, createSqlExecutionStack, createToSql } from "@prisma/orm-family-sql/runtime";
5
- import mysqlTarget, { MysqlContractSerializer } from "@prisma/orm-target-mysql/target/runtime";
6
6
  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/mysql/1-mysql/9-facade/dist/mysql-static-B6N5R6uW.mjs
11
- var version = "8.0.0-rc.23-dev.13";
10
+ //#region ../../../3-targets/mysql/1-mysql/9-facade/dist/mysql-static-B7wJV95a.mjs
11
+ var version = "8.0.0-rc.24-dev.1";
12
12
  const serializer = new MysqlContractSerializer();
13
13
  const validator = `${mysqlTarget.targetId}@${version}`;
14
14
  /**
@@ -80,4 +80,4 @@ function mysqlStatic(options) {
80
80
  //#endregion
81
81
  export { validateMysqlContract as i, contractFromJson as n, mysqlStatic as r, buildMysqlStaticContext as t };
82
82
 
83
- //# sourceMappingURL=mysql-static-B6N5R6uW-CVXRbAtD.mjs.map
83
+ //# sourceMappingURL=mysql-static-B7wJV95a-RfQM3jNq.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql-static-B7wJV95a-RfQM3jNq.mjs","names":[],"sources":["../../../../3-targets/mysql/1-mysql/9-facade/dist/mysql-static-B7wJV95a.mjs"],"sourcesContent":["import mysqlTarget, { MysqlContractSerializer } from \"@internal/target-mysql/runtime\";\nimport mysqlAdapter from \"@internal/adapter-mysql/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 { 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.24-dev.1\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new MysqlContractSerializer();\nconst validator = `${mysqlTarget.targetId}@${version}`;\n/**\n* Validates an emitted MySQL `contract.json` and returns it as the contract type the application\n* names, ready to pass to `mysql({ contract })` and `mysqlStatic({ 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 validateMysqlContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\n//#region src/static/mysql-static.ts\nfunction buildMysqlStaticContext(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 mysql 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 mysql 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 MySQL client without a driver: `sql`, `raw`, `enums` and `toSql`. Use\n* it where loading the MySQL driver is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = mysqlStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction mysqlStatic(options) {\n\tconst contract = validateMysqlContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: mysqlTarget,\n\t\tadapter: mysqlAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildMysqlStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack);\n}\n//#endregion\nexport { validateMysqlContract as i, mysqlStatic as n, contractFromJson as r, buildMysqlStaticContext as t };\n\n//# sourceMappingURL=mysql-static-B7wJV95a.mjs.map"],"mappings":";;;;;;;;;;AAUA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,wBAAwB;AAC/C,MAAM,YAAY,GAAG,YAAY,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiB7C,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,sBAAsB,UAAU;CACxC,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H;AAGA,SAAS,wBAAwB,UAAU,SAAS,OAAO;CAC1D,MAAM,EAAE,oBAAoB,MAAM;CAClC,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,+DAA+D;CAC3F,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,+DAA+D;CACpF,OAAO;EACN;EACA;EACA;EACA,KAAK;EACL;EACA,OAAO,YAAY,OAAO,QAAQ;CACnC;AACD;;;;;;;;;;AAUA,SAAS,YAAY,SAAS;CAC7B,MAAM,WAAW,sBAAsB,QAAQ,QAAQ;CACvD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,wBAAwB,UAAU,uBAAuB;EAC/D;EACA;CACD,CAAC,GAAG,KAAK;AACV"}
@@ -1,4 +1,5 @@
1
- import { a as MysqlQueryMembers, c as MysqlTargetId, i as MysqlOrm, l as MysqlTransactionContext, n as MysqlOptions, r as MysqlOptionsBase, s as MysqlStaticMembers, t as MysqlClient, u as mysql } from "./mysql-CnLEkVDo-BAfRi9KG.mjs";
1
+ import { a as MysqlQueryMembers, c as MysqlTargetId, d as mysql, i as MysqlOrm, l as MysqlTransactionContext, n as MysqlOptions, r as MysqlOptionsBase, s as MysqlStaticMembers, t as MysqlClient, u as MysqlTransactionOptions } from "./mysql-BFn2oufX-BCZx2s2u.mjs";
2
+ import { mysqlIsolationLevels as IsolationLevel } from "@prisma/orm-target-mysql/target/runtime";
2
3
  import { Runtime, SqlRuntimeBase } from "@prisma/orm-family-sql/runtime";
3
4
  import { MysqlPoolOptions } from "@prisma/orm-target-mysql/driver/runtime";
4
5
  import { Contract } from "@prisma/orm-framework/contract/types";
@@ -20,5 +21,5 @@ type MysqlBindingInput = {
20
21
  interface MysqlRuntime extends Runtime {}
21
22
  declare class MysqlRuntimeImpl<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> extends SqlRuntimeBase<TContract> {}
22
23
  //#endregion
23
- export { type MysqlBindingInput, type MysqlClient, type MysqlOptions, type MysqlOptionsBase, type MysqlOrm, type MysqlPoolOptions, type MysqlQueryMembers, type MysqlRuntime, MysqlRuntimeImpl, type MysqlStaticMembers, type MysqlTargetId, type MysqlTransactionContext, mysql as default };
24
+ export { IsolationLevel, type MysqlBindingInput, type MysqlClient, type MysqlOptions, type MysqlOptionsBase, type MysqlOrm, type MysqlPoolOptions, type MysqlQueryMembers, type MysqlRuntime, MysqlRuntimeImpl, type MysqlStaticMembers, type MysqlTargetId, type MysqlTransactionContext, type MysqlTransactionOptions, mysql as default };
24
25
  //# sourceMappingURL=runtime.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-mysql/9-facade/dist/runtime.d.mts"],"mappings":";;;;;;;KAMK;WACM;;;;;;;;;;;UAWD,qBAAqB;cACjB,iBAAiB,kBAAkB,SAAS,cAAc,SAAS,qBAAqB,eAAe"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-mysql/9-facade/dist/runtime.d.mts"],"mappings":";;;;;;;;KAOK;WACM;;;;;;;;;;;UAWD,qBAAqB;cACjB,iBAAiB,kBAAkB,SAAS,cAAc,SAAS,qBAAqB,eAAe"}
package/dist/runtime.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import { t as mysqlClientError } from "./errors-CaxSN_x--iqIjSE5F.mjs";
2
- import { i as validateMysqlContract, t as buildMysqlStaticContext } from "./mysql-static-B6N5R6uW-CVXRbAtD.mjs";
2
+ import { i as validateMysqlContract, t as buildMysqlStaticContext } from "./mysql-static-B7wJV95a-RfQM3jNq.mjs";
3
3
  import { structuredError } from "@prisma/orm-framework/utils/structured-error";
4
4
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
5
+ import mysqlTarget, { mysqlIsolationLevelSchema, mysqlIsolationLevels as IsolationLevel } from "@prisma/orm-target-mysql/target/runtime";
5
6
  import mysqlAdapter from "@prisma/orm-target-mysql/adapter/runtime";
6
7
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
7
8
  import { createRawLane, sql } from "@prisma/orm-family-sql/builder/runtime";
8
9
  import { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, delegatingRuntime, toRuntimeOptions, withTransaction, withTransactionMembers } from "@prisma/orm-family-sql/runtime";
9
- import mysqlTarget from "@prisma/orm-target-mysql/target/runtime";
10
10
  import { assertDefined } from "@prisma/orm-framework/utils/assertions";
11
11
  import { blindCast } from "@prisma/orm-framework/utils/casts";
12
12
  import mysqlDriver from "@prisma/orm-target-mysql/driver/runtime";
@@ -45,6 +45,24 @@ function resolveMysqlBinding(input) {
45
45
  function resolveOptionalMysqlBinding(options) {
46
46
  return options.url === void 0 ? void 0 : resolveMysqlBinding({ url: options.url });
47
47
  }
48
+ const transactionOptionsSchema = type({
49
+ "isolationLevel?": mysqlIsolationLevelSchema.or("undefined"),
50
+ "timeout?": "1 <= number.integer <= 2147483647 | null | undefined"
51
+ }).onUndeclaredKey("reject");
52
+ function validateTransactionOptions(options) {
53
+ if (options === void 0) return void 0;
54
+ const result = transactionOptionsSchema(options);
55
+ if (result instanceof type.errors) throw mysqlClientError("RUNTIME.ARGUMENT_INVALID", "Invalid transaction options", {
56
+ why: result.summary,
57
+ fix: "Pass an isolationLevel of ReadUncommitted, ReadCommitted, RepeatableRead, or Serializable, or leave it unset. Timeout must be an integer from 1 to 2147483647 milliseconds; null disables it.",
58
+ meta: {
59
+ extension: "mysql",
60
+ argument: "transactionOptions",
61
+ received: options
62
+ }
63
+ });
64
+ return result;
65
+ }
48
66
  const streamOptionSchema = type("boolean | undefined");
49
67
  /** Checks `stream` when the factory is called, as the Postgres facade checks `cursor`. */
50
68
  function validateStreamOption(stream) {
@@ -122,6 +140,7 @@ function buildMysqlTransactionMembers(options, txCtx) {
122
140
  */
123
141
  function mysql(options) {
124
142
  const stream = validateStreamOption(options.stream);
143
+ const transactionOptions = validateTransactionOptions(options.transactionOptions);
125
144
  const contract = validateMysqlContract(options.contract);
126
145
  let binding = resolveOptionalMysqlBinding(options);
127
146
  const stack = createSqlExecutionStack({
@@ -183,7 +202,8 @@ function mysql(options) {
183
202
  const orm$1 = mysqlOrm(orm({
184
203
  context,
185
204
  ...ifDefined("collections", options.collections),
186
- runtime: workRuntime
205
+ runtime: workRuntime,
206
+ implicitTransactionOptions: { isolationLevel: "ReadCommitted" }
187
207
  }));
188
208
  function prepare(declaration, callback) {
189
209
  return prepareQuery(workRuntime, declaration, callback);
@@ -229,7 +249,10 @@ function mysql(options) {
229
249
  return getRuntime();
230
250
  },
231
251
  prepare,
232
- transaction(fn) {
252
+ async transaction(fn, localOptions) {
253
+ const local = validateTransactionOptions(localOptions);
254
+ const isolationLevel = local?.isolationLevel !== void 0 ? local.isolationLevel : transactionOptions?.isolationLevel;
255
+ const timeout = local?.timeout !== void 0 ? local.timeout : transactionOptions?.timeout;
233
256
  return withTransaction(workRuntime, (txCtx) => {
234
257
  return fn(withTransactionMembers(txCtx, buildMysqlTransactionMembers({
235
258
  context,
@@ -239,6 +262,9 @@ function mysql(options) {
239
262
  toSql,
240
263
  prepareRuntime: workRuntime
241
264
  }, txCtx)));
265
+ }, {
266
+ isolationLevel,
267
+ timeout
242
268
  });
243
269
  },
244
270
  close() {
@@ -256,6 +282,6 @@ function mysql(options) {
256
282
  };
257
283
  }
258
284
  //#endregion
259
- export { MysqlRuntimeImpl, mysql as default };
285
+ export { IsolationLevel, MysqlRuntimeImpl, mysql as default };
260
286
 
261
287
  //# sourceMappingURL=runtime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/mysql/1-mysql/9-facade/dist/runtime.mjs"],"sourcesContent":["import { t as mysqlClientError } from \"./errors-CaxSN_x-.mjs\";\nimport { i as validateMysqlContract, t as buildMysqlStaticContext } from \"./mysql-static-B6N5R6uW.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport mysqlAdapter from \"@internal/adapter-mysql/runtime\";\nimport mysqlDriver from \"@internal/driver-mysql/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, toRuntimeOptions, withTransaction, withTransactionMembers } from \"@internal/sql-runtime\";\nimport mysqlTarget from \"@internal/target-mysql/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { type } from \"arktype\";\n//#region src/runtime/binding.ts\nfunction invalidUrl(message, meta) {\n\treturn structuredError(\"RUNTIME.BINDING_INVALID\", message, { meta: {\n\t\textension: \"mysql\",\n\t\t...meta\n\t} });\n}\n/** Checks `url` as the Postgres facade checks its own: a non-empty URL that parses, with the `mysql://` scheme. No part of the URL goes into the error. */\nfunction validateMysqlUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw invalidUrl(\"MySQL URL must be a non-empty string\", { reason: \"empty url\" });\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch {\n\t\tthrow invalidUrl(\"MySQL URL must be a valid URL\", { reason: \"unparseable url\" });\n\t}\n\tif (parsed.protocol !== \"mysql:\") throw invalidUrl(\"MySQL URL must use mysql://\", {\n\t\treason: \"wrong scheme\",\n\t\treceived: parsed.protocol\n\t});\n\treturn trimmed;\n}\nfunction resolveMysqlBinding(input) {\n\treturn {\n\t\tkind: \"url\",\n\t\turl: validateMysqlUrl(input.url)\n\t};\n}\nfunction resolveOptionalMysqlBinding(options) {\n\treturn options.url === void 0 ? void 0 : resolveMysqlBinding({ url: options.url });\n}\n//#endregion\n//#region src/runtime/mysql-options.ts\nconst streamOptionSchema = type(\"boolean | undefined\");\n/** Checks `stream` when the factory is called, as the Postgres facade checks `cursor`. */\nfunction validateStreamOption(stream) {\n\tconst result = streamOptionSchema(stream);\n\tif (result instanceof type.errors) throw mysqlClientError(\"RUNTIME.ARGUMENT_INVALID\", \"Invalid stream option\", {\n\t\twhy: result.summary,\n\t\tfix: \"Pass stream: true to stream rows as they arrive, or leave stream unset to read each whole result first.\",\n\t\tmeta: {\n\t\t\textension: \"mysql\",\n\t\t\thelper: \"mysql\",\n\t\t\targument: \"stream\",\n\t\t\treceived: stream\n\t\t}\n\t});\n\treturn result ?? false;\n}\n//#endregion\n//#region src/runtime/mysql-runtime.ts\nvar MysqlRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/mysql.ts\nfunction mysqlOrm(orm) {\n\tconst namespace = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(namespace, \"the unbound namespace always exists on a mysql 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 MySQL 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 buildMysqlTransactionMembers(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 mysql builder output\");\n\treturn {\n\t\tsql: blindCast(sqlNamespace),\n\t\torm: mysqlOrm(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 MySQL 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-mysql/static';\n* import mysql from '@prisma/orm-mysql/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 = mysql({ contract, url: process.env.DATABASE_URL });\n* ```\n*/\nfunction mysql(options) {\n\tconst stream = validateStreamOption(options.stream);\n\tconst contract = validateMysqlContract(options.contract);\n\tlet binding = resolveOptionalMysqlBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: mysqlTarget,\n\t\tadapter: mysqlAdapter,\n\t\tdriver: mysqlDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: mysqlDriver\n\t});\n\tconst { sql, raw: rawSqlTag, enums, toSql } = buildMysqlStaticContext(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 closedError = () => mysqlClientError(\"DRIVER.NOT_CONNECTED\", \"MySQL client is closed\", { meta: { extension: \"mysql\" } });\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"MySQL 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 closedError();\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 driver = stack.driver.create({\n\t\t\tstream,\n\t\t\t...ifDefined(\"poolOptions\", options.poolOptions)\n\t\t});\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new MysqlRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter,\n\t\t\tdriver,\n\t\t\t...toRuntimeOptions(options),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst workRuntime = delegatingRuntime(getRuntime);\n\tconst orm$1 = mysqlOrm(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 closedError();\n\t\t\tif (driverConnected || connectPromise) {\n\t\t\t\tif (bindingInput !== void 0) throw mysqlClientError(\"DRIVER.ALREADY_CONNECTED\", \"MySQL client is already bound\", {\n\t\t\t\t\twhy: \"connect() was given options after the client was bound to a database.\",\n\t\t\t\t\tfix: \"Call connect() without options, or create a new client for another database.\",\n\t\t\t\t\tmeta: { extension: \"mysql\" }\n\t\t\t\t});\n\t\t\t\tconst runtime = getRuntime();\n\t\t\t\tawait connectPromise;\n\t\t\t\tif (closed) throw closedError();\n\t\t\t\treturn runtime;\n\t\t\t}\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveMysqlBinding(bindingInput);\n\t\t\tif (binding === void 0) throw mysqlClientError(\"RUNTIME.BINDING_MISSING\", \"MySQL binding not configured. Pass url to mysql(...) or call db.connect({ url }).\", { meta: { extension: \"mysql\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\tif (closed) throw closedError();\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, buildMysqlTransactionMembers({\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 { MysqlRuntimeImpl, mysql as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAS,WAAW,SAAS,MAAM;CAClC,OAAO,gBAAgB,2BAA2B,SAAS,EAAE,MAAM;EAClE,WAAW;EACX,GAAG;CACJ,EAAE,CAAC;AACJ;;AAEA,SAAS,iBAAiB,KAAK;CAC9B,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,WAAW,wCAAwC,EAAE,QAAQ,YAAY,CAAC;CAC1G,IAAI;CACJ,IAAI;EACH,SAAS,IAAI,IAAI,OAAO;CACzB,QAAQ;EACP,MAAM,WAAW,iCAAiC,EAAE,QAAQ,kBAAkB,CAAC;CAChF;CACA,IAAI,OAAO,aAAa,UAAU,MAAM,WAAW,+BAA+B;EACjF,QAAQ;EACR,UAAU,OAAO;CAClB,CAAC;CACD,OAAO;AACR;AACA,SAAS,oBAAoB,OAAO;CACnC,OAAO;EACN,MAAM;EACN,KAAK,iBAAiB,MAAM,GAAG;CAChC;AACD;AACA,SAAS,4BAA4B,SAAS;CAC7C,OAAO,QAAQ,QAAQ,KAAK,IAAI,KAAK,IAAI,oBAAoB,EAAE,KAAK,QAAQ,IAAI,CAAC;AAClF;AAGA,MAAM,qBAAqB,KAAK,qBAAqB;;AAErD,SAAS,qB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ACjB,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"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/mysql/1-mysql/9-facade/dist/runtime.mjs"],"sourcesContent":["import { t as mysqlClientError } from \"./errors-CaxSN_x-.mjs\";\nimport { i as validateMysqlContract, t as buildMysqlStaticContext } from \"./mysql-static-B7wJV95a.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport mysqlTarget, { mysqlIsolationLevelSchema, mysqlIsolationLevels as IsolationLevel } from \"@internal/target-mysql/runtime\";\nimport mysqlAdapter from \"@internal/adapter-mysql/runtime\";\nimport mysqlDriver from \"@internal/driver-mysql/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, toRuntimeOptions, withTransaction, withTransactionMembers } from \"@internal/sql-runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { type } from \"arktype\";\n//#region src/runtime/binding.ts\nfunction invalidUrl(message, meta) {\n\treturn structuredError(\"RUNTIME.BINDING_INVALID\", message, { meta: {\n\t\textension: \"mysql\",\n\t\t...meta\n\t} });\n}\n/** Checks `url` as the Postgres facade checks its own: a non-empty URL that parses, with the `mysql://` scheme. No part of the URL goes into the error. */\nfunction validateMysqlUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw invalidUrl(\"MySQL URL must be a non-empty string\", { reason: \"empty url\" });\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch {\n\t\tthrow invalidUrl(\"MySQL URL must be a valid URL\", { reason: \"unparseable url\" });\n\t}\n\tif (parsed.protocol !== \"mysql:\") throw invalidUrl(\"MySQL URL must use mysql://\", {\n\t\treason: \"wrong scheme\",\n\t\treceived: parsed.protocol\n\t});\n\treturn trimmed;\n}\nfunction resolveMysqlBinding(input) {\n\treturn {\n\t\tkind: \"url\",\n\t\turl: validateMysqlUrl(input.url)\n\t};\n}\nfunction resolveOptionalMysqlBinding(options) {\n\treturn options.url === void 0 ? void 0 : resolveMysqlBinding({ url: options.url });\n}\n//#endregion\n//#region src/runtime/mysql-options.ts\nconst transactionOptionsSchema = type({\n\t\"isolationLevel?\": mysqlIsolationLevelSchema.or(\"undefined\"),\n\t\"timeout?\": \"1 <= number.integer <= 2147483647 | null | undefined\"\n}).onUndeclaredKey(\"reject\");\nfunction validateTransactionOptions(options) {\n\tif (options === void 0) return void 0;\n\tconst result = transactionOptionsSchema(options);\n\tif (result instanceof type.errors) throw mysqlClientError(\"RUNTIME.ARGUMENT_INVALID\", \"Invalid transaction options\", {\n\t\twhy: result.summary,\n\t\tfix: \"Pass an isolationLevel of ReadUncommitted, ReadCommitted, RepeatableRead, or Serializable, or leave it unset. Timeout must be an integer from 1 to 2147483647 milliseconds; null disables it.\",\n\t\tmeta: {\n\t\t\textension: \"mysql\",\n\t\t\targument: \"transactionOptions\",\n\t\t\treceived: options\n\t\t}\n\t});\n\treturn result;\n}\nconst streamOptionSchema = type(\"boolean | undefined\");\n/** Checks `stream` when the factory is called, as the Postgres facade checks `cursor`. */\nfunction validateStreamOption(stream) {\n\tconst result = streamOptionSchema(stream);\n\tif (result instanceof type.errors) throw mysqlClientError(\"RUNTIME.ARGUMENT_INVALID\", \"Invalid stream option\", {\n\t\twhy: result.summary,\n\t\tfix: \"Pass stream: true to stream rows as they arrive, or leave stream unset to read each whole result first.\",\n\t\tmeta: {\n\t\t\textension: \"mysql\",\n\t\t\thelper: \"mysql\",\n\t\t\targument: \"stream\",\n\t\t\treceived: stream\n\t\t}\n\t});\n\treturn result ?? false;\n}\n//#endregion\n//#region src/runtime/mysql-runtime.ts\nvar MysqlRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/mysql.ts\nfunction mysqlOrm(orm) {\n\tconst namespace = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(namespace, \"the unbound namespace always exists on a mysql 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 MySQL 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 buildMysqlTransactionMembers(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 mysql builder output\");\n\treturn {\n\t\tsql: blindCast(sqlNamespace),\n\t\torm: mysqlOrm(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 MySQL 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-mysql/static';\n* import mysql from '@prisma/orm-mysql/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 = mysql({ contract, url: process.env.DATABASE_URL });\n* ```\n*/\nfunction mysql(options) {\n\tconst stream = validateStreamOption(options.stream);\n\tconst transactionOptions = validateTransactionOptions(options.transactionOptions);\n\tconst contract = validateMysqlContract(options.contract);\n\tlet binding = resolveOptionalMysqlBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: mysqlTarget,\n\t\tadapter: mysqlAdapter,\n\t\tdriver: mysqlDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: mysqlDriver\n\t});\n\tconst { sql, raw: rawSqlTag, enums, toSql } = buildMysqlStaticContext(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 closedError = () => mysqlClientError(\"DRIVER.NOT_CONNECTED\", \"MySQL client is closed\", { meta: { extension: \"mysql\" } });\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"MySQL 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 closedError();\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 driver = stack.driver.create({\n\t\t\tstream,\n\t\t\t...ifDefined(\"poolOptions\", options.poolOptions)\n\t\t});\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new MysqlRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter,\n\t\t\tdriver,\n\t\t\t...toRuntimeOptions(options),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst workRuntime = delegatingRuntime(getRuntime);\n\tconst orm$1 = mysqlOrm(orm({\n\t\tcontext,\n\t\t...ifDefined(\"collections\", options.collections),\n\t\truntime: workRuntime,\n\t\timplicitTransactionOptions: { isolationLevel: \"ReadCommitted\" }\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 closedError();\n\t\t\tif (driverConnected || connectPromise) {\n\t\t\t\tif (bindingInput !== void 0) throw mysqlClientError(\"DRIVER.ALREADY_CONNECTED\", \"MySQL client is already bound\", {\n\t\t\t\t\twhy: \"connect() was given options after the client was bound to a database.\",\n\t\t\t\t\tfix: \"Call connect() without options, or create a new client for another database.\",\n\t\t\t\t\tmeta: { extension: \"mysql\" }\n\t\t\t\t});\n\t\t\t\tconst runtime = getRuntime();\n\t\t\t\tawait connectPromise;\n\t\t\t\tif (closed) throw closedError();\n\t\t\t\treturn runtime;\n\t\t\t}\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveMysqlBinding(bindingInput);\n\t\t\tif (binding === void 0) throw mysqlClientError(\"RUNTIME.BINDING_MISSING\", \"MySQL binding not configured. Pass url to mysql(...) or call db.connect({ url }).\", { meta: { extension: \"mysql\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\tif (closed) throw closedError();\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\tasync transaction(fn, localOptions) {\n\t\t\tconst local = validateTransactionOptions(localOptions);\n\t\t\tconst isolationLevel = local?.isolationLevel !== void 0 ? local.isolationLevel : transactionOptions?.isolationLevel;\n\t\t\tconst timeout = local?.timeout !== void 0 ? local.timeout : transactionOptions?.timeout;\n\t\t\treturn withTransaction(workRuntime, (txCtx) => {\n\t\t\t\treturn fn(withTransactionMembers(txCtx, buildMysqlTransactionMembers({\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\t\tisolationLevel,\n\t\t\t\ttimeout\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 { IsolationLevel, MysqlRuntimeImpl, mysql as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAS,WAAW,SAAS,MAAM;CAClC,OAAO,gBAAgB,2BAA2B,SAAS,EAAE,MAAM;EAClE,WAAW;EACX,GAAG;CACJ,EAAE,CAAC;AACJ;;AAEA,SAAS,iBAAiB,KAAK;CAC9B,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,WAAW,wCAAwC,EAAE,QAAQ,YAAY,CAAC;CAC1G,IAAI;CACJ,IAAI;EACH,SAAS,IAAI,IAAI,OAAO;CACzB,QAAQ;EACP,MAAM,WAAW,iCAAiC,EAAE,QAAQ,kBAAkB,CAAC;CAChF;CACA,IAAI,OAAO,aAAa,UAAU,MAAM,WAAW,+BAA+B;EACjF,QAAQ;EACR,UAAU,OAAO;CAClB,CAAC;CACD,OAAO;AACR;AACA,SAAS,oBAAoB,OAAO;CACnC,OAAO;EACN,MAAM;EACN,KAAK,iBAAiB,MAAM,GAAG;CAChC;AACD;AACA,SAAS,4BAA4B,SAAS;CAC7C,OAAO,QAAQ,QAAQ,KAAK,IAAI,KAAK,IAAI,oBAAoB,EAAE,KAAK,QAAQ,IAAI,CAAC;AAClF;AAGA,MAAM,2BAA2B,KAAK;CACrC,mBAAmB,0BAA0B,GAAG,WAAW;CAC3D,YAAY;AACb,CAAC,CAAC,CAAC,gBAAgB,QAAQ;AAC3B,SAAS,2BAA2B,SAAS;CAC5C,IAAI,YAAY,KAAK,GAAG,OAAO,KAAK;CACpC,MAAM,SAAS,yBAAyB,OAAO;CAC/C,IAAI,kBAAkB,KAAK,QAAQ,MAAM,iBAAiB,4BAA4B,+BAA+B;EACpH,KAAK,OAAO;EACZ,KAAK;EACL,MAAM;GACL,WAAW;GACX,UAAU;GACV,UAAU;EACX;CACD,CAAC;CACD,OAAO;AACR;AAC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M,QAAQ,2BAA2B,YAAY;GACrD,MAAM,iBAAiB,OAAO,mBAAmB,KAAK,IAAI,MAAM,iBAAiB,oBAAoB;GACrG,MAAM,UAAU,OAAO,YAAY,KAAK,IAAI,MAAM,UAAU,oBAAoB;GAChF,OAAO,gBAAgB,cAAc,UAAU;IAC9C,OAAO,GAAG,uBAAuB,OAAO,6BAA6B;KACpE;KACA,aAAa,QAAQ;KACrB,iBAAiB,MAAM,QAAQ;KAC/B;KACA;KACA,gBAAgB;IACjB,GAAG,KAAK,CAAC,CAAC;GACX,GAAG;IACF;IACA;GACD,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"}
package/dist/static.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { d as mysqlStatic, o as MysqlStaticContext } from "./mysql-CnLEkVDo-BAfRi9KG.mjs";
1
+ import { f as mysqlStatic, o as MysqlStaticContext } from "./mysql-BFn2oufX-BCZx2s2u.mjs";
2
2
  import { Contract } from "@prisma/orm-framework/contract/types";
3
3
  import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
4
4
  //#region ../../../3-targets/mysql/1-mysql/9-facade/dist/static.d.mts
package/dist/static.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as contractFromJson, r as mysqlStatic } from "./mysql-static-B6N5R6uW-CVXRbAtD.mjs";
1
+ import { n as contractFromJson, r as mysqlStatic } from "./mysql-static-B7wJV95a-RfQM3jNq.mjs";
2
2
  export { contractFromJson, mysqlStatic as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-mysql",
3
- "version": "8.0.0-rc.23-dev.13",
3
+ "version": "8.0.0-rc.24-dev.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -10,18 +10,18 @@
10
10
  "skills"
11
11
  ],
12
12
  "dependencies": {
13
- "@prisma/orm-family-sql": "8.0.0-rc.23-dev.13",
14
- "@prisma/orm-framework": "8.0.0-rc.23-dev.13",
15
- "@prisma/orm-target-mysql": "8.0.0-rc.23-dev.13",
16
- "@prisma/orm-toolchain": "8.0.0-rc.23-dev.13",
13
+ "@prisma/orm-family-sql": "8.0.0-rc.24-dev.1",
14
+ "@prisma/orm-framework": "8.0.0-rc.24-dev.1",
15
+ "@prisma/orm-target-mysql": "8.0.0-rc.24-dev.1",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.24-dev.1",
17
17
  "arktype": "^2.2.2",
18
18
  "pathe": "^2.0.3",
19
19
  "temporal-spec": "1.0.1"
20
20
  },
21
21
  "devDependencies": {
22
- "@internal/mysql": "8.0.0-rc.23-dev.13",
23
- "@repo/tsconfig": "8.0.0-rc.23-dev.13",
24
- "@repo/tsdown": "8.0.0-rc.23-dev.13",
22
+ "@internal/mysql": "8.0.0-rc.24-dev.1",
23
+ "@repo/tsconfig": "8.0.0-rc.24-dev.1",
24
+ "@repo/tsdown": "8.0.0-rc.24-dev.1",
25
25
  "tsdown": "0.22.14",
26
26
  "typescript": "5.9.3"
27
27
  },
@@ -15,7 +15,7 @@ description: >-
15
15
  ORM 7 or earlier (schema.prisma + @prisma/client).
16
16
  metadata:
17
17
  library: '@prisma/orm-mysql'
18
- library_version: '8.0.0-rc.23-dev.13'
18
+ library_version: '8.0.0-rc.24-dev.1'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -96,12 +96,13 @@ If `contract:` ends in `.prisma`, the source is PSL; if it ends in `.ts`, the so
96
96
 
97
97
  ## Workflow — Edit a model / field / relation (PSL)
98
98
 
99
- The concept: PSL models lower to tables (or collections, on Mongo); fields lower to columns; `@relation(...)` declares the FK side. Add the relation only on the owning side — the framework derives the back-reference automatically.
99
+ The concept: PSL models lower to tables (or collections, on Mongo); fields lower to columns; `@relation(...)` declares the FK side. The other model gets a relation, and something to `include` from, only when it declares the back-reference itself with no `fields`/`references`: a list field (`posts Post[]`), or an optional singular field for a one-to-one (`profile Profile?`). A singular back-reference needs the FK fields to be unique (`@unique`, or `@@unique([...])` on the FK side); otherwise emit fails with `PSL_NON_UNIQUE_BACKRELATION`.
100
100
 
101
101
  ```prisma
102
102
  model User {
103
103
  id Int @id @default(autoincrement())
104
104
  email String @unique
105
+ posts Post[]
105
106
  }
106
107
 
107
108
  model Post {
@@ -525,6 +526,7 @@ Infer captures indexes at full fidelity — expression, partial (`where:`), uniq
525
526
  - **Lifecycle callbacks** (`beforeSave`, `afterCreate`, etc.). Not supported. Use middleware (`references/runtime.md`) or app code. The maintainers decided it stays out of the core; an extension may provide it (prisma/orm ADR 293).
526
527
  - **Soft delete / `paranoid: true`.** No built-in soft-delete column. Add a nullable `deletedAt DateTime?` and filter explicitly in queries (or in middleware). The maintainers decided it stays out of the core; an extension may provide it (prisma/orm ADR 293).
527
528
  - **Scopes / default filters.** No ActiveRecord-style scopes. Compose query helpers yourself. To request scopes, file via `references/feedback.md`.
529
+ - **Derived back-references.** A model has a relation back only when it declares the field itself (`posts Post[]`); nothing adds it for you, and it is optional. The maintainers decided this (prisma/orm ADR 319). `prisma contract infer` writes both sides when it reads an existing database.
528
530
  - **Implicit Prisma-ORM many-to-many.** List navigation on both sides without an explicit join model is rejected. Author the join model explicitly. To request implicit M2M, file via `references/feedback.md`.
529
531
 
530
532
  ## Reference
@@ -380,11 +380,13 @@ Self-emit the same way: `node <package dir>/migration.ts`.
380
380
 
381
381
  ## Type changes and new required fields
382
382
 
383
- Postgres and SQLite. `migration plan` cannot see rows, so these rules are about what you state, not what the table holds.
383
+ Postgres and SQLite first; MongoDB below. `migration plan` cannot see rows, so these rules are about what you state, not what the table holds.
384
384
 
385
385
  - **A type change that can lose values is a question.** Answer it with `--convert User.age` (the plan has a slot for the conversion: `using: placeholder('User.age:convert')` in `this.alterColumnType(...)` on Postgres, the column's copy expression in `this.recreateTable(...)` on SQLite; write SQL over the column, such as `'"age"::integer'`, self-emit, `db migrate`) or `--delete User.age` (the database's own cast runs; it is listed as `accept lossy type change of field "User.age"`). The cast may cut or round values: on Postgres a longer text is cut to a shorter `VarChar` and a number rounded to fewer digits. A value the cast cannot convert fails the apply, changes nothing, and the error names `--convert`. On SQLite the rebuild checks after its copy that every value took the new type: each column listed in `retypedColumns` is checked, as the conversion when it has a copy expression in `copyExpressions` and as SQLite's own cast when it has none, and a column with a copy expression that is not listed is checked as a conversion too. A hand-written rebuild that converts needs only its copy expression. A widening such as `int4` to `int8` asks nothing.
386
386
  - **A new required field** gets a temporary value in the existing rows (`''`, `0`, `false`, …) with no question and no placeholder; the output names the field and the value. On SQLite the rebuild writes it in `temporaryValues: { name: sql`''` }`, apart from the conversions in `copyExpressions`. `--backfill User.name` writes a data transform to fill instead: add nullable, fill (`check` and `run` slots on Postgres, `run` on SQLite), then make it required. A new unique, primary-key or foreign-key field, or one whose values come from a value set, gets no temporary value: on a table with rows, use `--backfill`.
387
387
  - **An optional field made required** is tightened directly. If rows hold NULL, the apply fails and counts them (`3 rows of "Item" hold NULL in "note", so it cannot become required.`); set the values and re-run, or plan with `--backfill`.
388
+ - **On MongoDB** the same questions are asked about the documents. A validator change (`collMod(..., { ..., checkDocuments: true })`) checks the documents as its own precheck, after the plan's rewrites, and stops while one does not fit; operations that ran before it stay applied, and a re-run skips them. To apply a validator over documents that do not fit, set `checkDocuments: false` on its `collMod` in `migration.ts`. `--delete User.age` casts with `$convert` (`castField`), only where the result keeps what the values mean: `String` to `Boolean` or `DateTime` to `Int` offer `--convert` only; a cast that keeps every value, such as `Int` to `Int64`, asks nothing. `--convert User.age` and `--backfill User.plan` write `dataTransform('User.age', { check, run })` with the filter written and the update as `placeholder('User.age:update')`, which you replace with an update document (`{ $set: { … } }`) or an aggregation pipeline (`[{ $set: { age: { $toInt: '$age' } } }]`); the `run` uses `rawUpdateMany(..., { bypassDocumentValidation: true })`, and a hand-written one must skip validation too. A new required field gets a temporary value (`fillField`), unless it has a unique index or its type has none, such as a date. On a collection with documents, such a field stops the apply: a unique one at its index build, where the documents that lack it all hold `null`, and any other at the validator change's document check. Both errors name `--backfill`, so use it. A field that gains an enum or changes type inside a value object is not a statement: the plan warns, and you add a `dataTransform` before the validator change.
389
+ - **Adopting a Prisma 6 MongoDB database.** A Prisma 6 database has no validator, and the first Prisma 8 plan adds one, which checks the documents first. If documents do not fit, the apply stops and names what the change touches, one `_id`, and the `mongosh` query that finds the rest. The error says why the document it shows does not fit, such as a field the new validator does not name. Fix those documents and run the command again; a plain update works, since the collection has no validator yet. Or, under `db migrate`, apply the validator over them: set `checkDocuments: false` on that `collMod` in `migration.ts`, run the file with `node`, and run `db migrate` again; they then fail their next update until they fit.
388
390
  - **Following failure advice under `db migrate`:** the migration is already written, so the error says to copy any code you wrote in its `migration.ts`, delete its directory, and run the printed `migration plan --from <hash> --name <name> …` command, which keeps the migration's name, together with the other statements you planned it with. Paths in the advice are relative to the directory the command ran from, and the commands it prints repeat the `--config` it was given, so each runs as printed from there.
389
391
 
390
392
  ## Workflow — Author a migration by hand
@@ -591,14 +593,14 @@ In a terminal the command asks each question in turn; type `delete`, `allow`, or
591
593
  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.
592
594
  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.
593
595
  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.
594
- 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.
596
+ 13. **Running Prisma 7 `migrate` commands against Prisma 8.** Each one answers `CLI.V7_COMMAND` 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, install Prisma 7's CLI with `npm install --save-dev @prisma/prisma7@7` and run every one of them except `migrate diff`, whose replacement only reads, as `prisma7 migrate <command>` instead; `migrate resolve` runs as `prisma7 migrate resolve --applied <migration>`.
595
597
 
596
598
  ## What Prisma 8 doesn't do yet
597
599
 
598
600
  - **Runtime-apply migrations.** Prisma 8 doesn't apply pending migrations from your app's startup code (the "Drizzle pattern" for serverless / edge). Workaround: run `prisma db migrate` from your deploy pipeline before the app starts. If you need runtime-apply built-in, file a feature request via the `references/feedback.md` skill.
599
601
  - **Seeds-as-first-class.** Prisma 8 doesn't ship a `prisma db seed` equivalent. Workaround: write a TypeScript script that imports your `db` instance and runs your setup queries; invoke it from `package.json`'s scripts. If you need first-class seeding, file a feature request via the `references/feedback.md` skill.
600
602
  - **Migration squashing.** Prisma 8 doesn't squash older migrations into a baseline. They accumulate; for very large histories, manual baseline-and-truncate is the path. If you need built-in squashing, file a feature request via the `references/feedback.md` skill.
601
- - **Renames beyond models, fields, namespaces, enum values and value object fields.** `--rename` covers models and fields on Postgres, SQLite and MongoDB. On Postgres it also moves a model to another namespace and renames a namespace (not on MongoDB or SQLite). On Postgres and SQLite it also renames enum values, fields of value objects and variants. It does not rename value objects, fields of value objects, enum values or variants with a new discriminator value on MongoDB, or native Postgres enum values. MongoDB also refuses `--convert` of a variant and `--backfill` of a value object field. On MongoDB it also refuses `_id`, a field whose stored name contains `.` or starts with `$`, and a time-series collection; each refusal (`MIGRATION.PLANNING_FAILED`) says what to do instead. If you need one of these, file a feature request via the `references/feedback.md` skill.
603
+ - **Renames beyond models, fields, namespaces, enum values and value object fields.** `--rename` covers models and fields on Postgres, SQLite and MongoDB. On Postgres it also moves a model to another namespace and renames a namespace (not on MongoDB or SQLite). On Postgres and SQLite it also renames enum values, fields of value objects and variants. It does not rename value objects, fields of value objects, enum values or variants with a new discriminator value on MongoDB, or native Postgres enum values. MongoDB also refuses `--convert` of a variant and `--backfill` of a value object field. On MongoDB it also refuses `_id`, a field whose stored name contains `.` or starts with `$`, and a time-series collection; each refusal (`MIGRATION.PLANNING_FAILED`) says what to do instead. MongoDB itself accepts such a stored name, but an update reads `.` as a path into embedded documents and `$` as an operator, so the plan cannot rewrite the field: a type change of it is refused the same way, and a removal or a new required value is not written, so the validator change's document check stops the apply while documents do not fit. If you need one of these, file a feature request via the `references/feedback.md` skill.
602
604
 
603
605
  ## Graph and history commands
604
606