@prisma/orm-toolchain 8.0.0-rc.24-dev.43 → 8.0.0-rc.24-dev.44

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 (91) hide show
  1. package/dist/{aggregate-D7dLfF9a.mjs → aggregate-B2D5REGs.mjs} +9 -9
  2. package/dist/{aggregate-D7dLfF9a.mjs.map → aggregate-B2D5REGs.mjs.map} +1 -1
  3. package/dist/{aggregate-BMh4SLep.d.mts → aggregate-CvDNKQbR.d.mts} +5 -5
  4. package/dist/{aggregate-BMh4SLep.d.mts.map → aggregate-CvDNKQbR.d.mts.map} +1 -1
  5. package/dist/{caught-errors-D8Hn_D5h-C4BJDZ5y.mjs → caught-errors-DZXnK8Ls-zVmM4nr3.mjs} +577 -49
  6. package/dist/caught-errors-DZXnK8Ls-zVmM4nr3.mjs.map +1 -0
  7. package/dist/cli-telemetry.mjs +1 -1
  8. package/dist/cli.d.mts +1 -1
  9. package/dist/cli.mjs +189 -70
  10. package/dist/cli.mjs.map +1 -1
  11. package/dist/cli__control-api.d.mts +12 -59
  12. package/dist/cli__control-api.d.mts.map +1 -1
  13. package/dist/cli__control-api.mjs +2 -2
  14. package/dist/cli__control-api__testing.d.mts +1 -1
  15. package/dist/cli__migration-cli.mjs +4 -4
  16. package/dist/cli__migration-cli.mjs.map +1 -1
  17. package/dist/config-loader.mjs +1 -1
  18. package/dist/contract-snapshot-store-D-s2aKZY.d.mts +2 -0
  19. package/dist/{contract-snapshot-store-DRAG5XXy-DOvf98Np.d.mts → contract-snapshot-store-DRAG5XXy-ChW4hBLb.d.mts} +2 -2
  20. package/dist/{contract-snapshot-store-DRAG5XXy-DOvf98Np.d.mts.map → contract-snapshot-store-DRAG5XXy-ChW4hBLb.d.mts.map} +1 -1
  21. package/dist/{contract-snapshot-store-Ds7lE7vL-Dn444yIq.mjs → contract-snapshot-store-Dl6v-Uxr-CwhnMsgc.mjs} +4 -4
  22. package/dist/{contract-snapshot-store-Ds7lE7vL-Dn444yIq.mjs.map → contract-snapshot-store-Dl6v-Uxr-CwhnMsgc.mjs.map} +1 -1
  23. package/dist/{db-sign-DLIR5swa-CMgFrBoH.d.mts → db-sign-BQMw6RX9-Stp7Gjj7.d.mts} +187 -18
  24. package/dist/db-sign-BQMw6RX9-Stp7Gjj7.d.mts.map +1 -0
  25. package/dist/{domain-type-generation-BGcbGgHJ-Cdw5RNaZ.mjs → domain-type-generation-BGcbGgHJ-SB6n89eE.mjs} +3 -3
  26. package/dist/{domain-type-generation-BGcbGgHJ-Cdw5RNaZ.mjs.map → domain-type-generation-BGcbGgHJ-SB6n89eE.mjs.map} +1 -1
  27. package/dist/emitter.mjs +2 -2
  28. package/dist/emitter__domain-type-generation.mjs +1 -1
  29. package/dist/{errors-BMq40nYH-Cg8PBect.mjs → errors-BlaB9AFz-CZDOC0mV.mjs} +8 -10
  30. package/dist/{errors-BMq40nYH-Cg8PBect.mjs.map → errors-BlaB9AFz-CZDOC0mV.mjs.map} +1 -1
  31. package/dist/{exports-BiXPktAF.mjs → exports-B0yFVod3.mjs} +3 -3
  32. package/dist/{exports-BiXPktAF.mjs.map → exports-B0yFVod3.mjs.map} +1 -1
  33. package/dist/{exports-CCuYD8dO-yw1GizAT.mjs → exports-CCuYD8dO-fFXwpizm.mjs} +3 -3
  34. package/dist/{exports-CCuYD8dO-yw1GizAT.mjs.map → exports-CCuYD8dO-fFXwpizm.mjs.map} +1 -1
  35. package/dist/{exports-CZ6dPu-O.mjs → exports-DNFYCa6U.mjs} +3 -3
  36. package/dist/{exports-CZ6dPu-O.mjs.map → exports-DNFYCa6U.mjs.map} +1 -1
  37. package/dist/{graph-membership-D7m41lWA-B68g1CRS.mjs → graph-membership-ClCmhVjf-8XCns4rf.mjs} +3 -3
  38. package/dist/{graph-membership-D7m41lWA-B68g1CRS.mjs.map → graph-membership-ClCmhVjf-8XCns4rf.mjs.map} +1 -1
  39. package/dist/hash-DcBt3lpO.d.mts +1 -0
  40. package/dist/{hash-DclMqd7S-WBvXJ_4C.d.mts → hash-DclMqd7S-Dddl_NeA.d.mts} +2 -2
  41. package/dist/{hash-DclMqd7S-WBvXJ_4C.d.mts.map → hash-DclMqd7S-Dddl_NeA.d.mts.map} +1 -1
  42. package/dist/{invariants-DxCj82g2-DhGkStla.mjs → invariants-c9W7-6DY-CzSdi8Vp.mjs} +3 -3
  43. package/dist/{invariants-DxCj82g2-DhGkStla.mjs.map → invariants-c9W7-6DY-CzSdi8Vp.mjs.map} +1 -1
  44. package/dist/io-BalYebmm.d.mts +1 -0
  45. package/dist/{io-D51jgF31-RTnIqw4C.mjs → io-DUsSXBRO-BqRNb69U.mjs} +5 -5
  46. package/dist/{io-D51jgF31-RTnIqw4C.mjs.map → io-DUsSXBRO-BqRNb69U.mjs.map} +1 -1
  47. package/dist/{io-DpAplMzQ-oLyfXvz-.d.mts → io-DpAplMzQ-ZTJi-tTr.d.mts} +2 -2
  48. package/dist/{io-DpAplMzQ-oLyfXvz-.d.mts.map → io-DpAplMzQ-ZTJi-tTr.d.mts.map} +1 -1
  49. package/dist/{migration-DTmtOJ0n.mjs → migration-C1l4_CWi.mjs} +3 -3
  50. package/dist/{migration-DTmtOJ0n.mjs.map → migration-C1l4_CWi.mjs.map} +1 -1
  51. package/dist/{migration-graph-BoiiZAaU-DLht12k7.mjs → migration-graph-DBJAol1y-DX61Ss3X.mjs} +19 -3
  52. package/dist/{migration-graph-BoiiZAaU-DLht12k7.mjs.map → migration-graph-DBJAol1y-DX61Ss3X.mjs.map} +1 -1
  53. package/dist/{migration-graph-D8IuOkZb-pSI7-k4_.d.mts → migration-graph-DCIdjMtC-CAs3pm1A.d.mts} +10 -3
  54. package/dist/{migration-graph-D8IuOkZb-pSI7-k4_.d.mts.map → migration-graph-DCIdjMtC-CAs3pm1A.d.mts.map} +1 -1
  55. package/dist/{migration-graph-Dra4CcyN.d.mts → migration-graph-GiSYbAc8.d.mts} +2 -2
  56. package/dist/{migration-graph-Dra4CcyN.d.mts.map → migration-graph-GiSYbAc8.d.mts.map} +1 -1
  57. package/dist/migration-tools.d.mts +14 -14
  58. package/dist/migration-tools.mjs +13 -13
  59. package/dist/migration-tools__aggregate.d.mts +1 -1
  60. package/dist/migration-tools__aggregate.mjs +1 -1
  61. package/dist/migration-tools__contract-snapshot-store.d.mts +3 -3
  62. package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
  63. package/dist/migration-tools__errors.mjs +1 -1
  64. package/dist/migration-tools__hash.d.mts +2 -2
  65. package/dist/migration-tools__invariants.mjs +1 -1
  66. package/dist/migration-tools__io.d.mts +2 -2
  67. package/dist/migration-tools__io.mjs +1 -1
  68. package/dist/migration-tools__migration-graph.d.mts +3 -3
  69. package/dist/migration-tools__migration-graph.mjs +3 -3
  70. package/dist/migration-tools__migration.mjs +1 -1
  71. package/dist/migration-tools__ref-resolution.mjs +1 -1
  72. package/dist/migration-tools__refs.mjs +1 -1
  73. package/dist/migration-tools__spaces.mjs +2 -2
  74. package/dist/{ref-BrtKINun-CRtoeAmD.mjs → ref-C7TozKnq-C4UYYbRT.mjs} +362 -160
  75. package/dist/ref-C7TozKnq-C4UYYbRT.mjs.map +1 -0
  76. package/dist/{ref-resolution-C0xsiRig.mjs → ref-resolution-533MGMov.mjs} +2 -2
  77. package/dist/{ref-resolution-C0xsiRig.mjs.map → ref-resolution-533MGMov.mjs.map} +1 -1
  78. package/dist/{refs-t_JbIjGo-BVCqKpXd.mjs → refs-BE6yEgSV-CbpqGnbl.mjs} +3 -3
  79. package/dist/{refs-t_JbIjGo-BVCqKpXd.mjs.map → refs-BE6yEgSV-CbpqGnbl.mjs.map} +1 -1
  80. package/dist/{spaces-qTjiPqw0.mjs → spaces-Cj_GYpmM.mjs} +7 -7
  81. package/dist/{spaces-qTjiPqw0.mjs.map → spaces-Cj_GYpmM.mjs.map} +1 -1
  82. package/dist/{verify-contract-spaces-BZV67Pqk-DhswS52A.mjs → verify-contract-spaces-DvU9lE0Y-Y1WwEsPA.mjs} +4 -4
  83. package/dist/{verify-contract-spaces-BZV67Pqk-DhswS52A.mjs.map → verify-contract-spaces-DvU9lE0Y-Y1WwEsPA.mjs.map} +1 -1
  84. package/dist/vite-plugin-contract-emit.mjs +3 -3
  85. package/package.json +11 -11
  86. package/dist/caught-errors-D8Hn_D5h-C4BJDZ5y.mjs.map +0 -1
  87. package/dist/contract-snapshot-store-CtlOZtzJ.d.mts +0 -2
  88. package/dist/db-sign-DLIR5swa-CMgFrBoH.d.mts.map +0 -1
  89. package/dist/hash-CwWGlFWV.d.mts +0 -1
  90. package/dist/io-CpR7fgmB.d.mts +0 -1
  91. package/dist/ref-BrtKINun-CRtoeAmD.mjs.map +0 -1
package/dist/cli.mjs CHANGED
@@ -1,16 +1,17 @@
1
- import { a as expandContractInputs, c as globContractInputMatching, d as loadConfigFiles, g as requireConfigSections, h as ormConfigSection, i as evaluateConfigModule, r as buildLoadedConfig } from "./exports-CZ6dPu-O.mjs";
1
+ import { a as expandContractInputs, c as globContractInputMatching, d as loadConfigFiles, g as requireConfigSections, h as ormConfigSection, i as evaluateConfigModule, r as buildLoadedConfig } from "./exports-DNFYCa6U.mjs";
2
2
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
3
- import { b as errorInvalidRefName, t as MigrationToolsError } from "./errors-BMq40nYH-Cg8PBect.mjs";
4
- import { i as hasContractSnapshot, t as contractSnapshotDir } from "./contract-snapshot-store-Ds7lE7vL-Dn444yIq.mjs";
5
- import { s as readMigrationsDir } from "./io-D51jgF31-RTnIqw4C.mjs";
6
- import { l as spaceMigrationDirectory, u as spaceRefsDirectory } from "./verify-contract-spaces-BZV67Pqk-DhswS52A.mjs";
7
- import { A as errorFileNotFound, C as errorContractArgConflict, Ct as shellQuoted, D as errorConvertAndDelete, E as errorContractValidationFailed, F as errorMarkerMissing, J as errorRuntime, L as errorMigrationPackageNotFound, M as errorHashMismatch, O as errorDatabaseConnectionRequired, P as errorLegendHumanOnly, S as errorConsentUnused, St as selfEmitCommand, Tt as targetSupportsMigrations, Y as errorSignRefsNotWritten, _ as displayPath, _t as requireLiveDatabase, a as appRefsDirFor, at as errorTargetMismatch, c as cliCommand, d as closeQuietly, dt as migrationsDirFor, g as dbUpdateRerun, gt as redactUrlCredentials, ht as readContractEnvelope, i as appMigrationsDirFor, it as errorTargetMigrationNotSupported, j as errorFromCaught, k as errorDriverRequired, lt as maskConnectionUrl, mt as printedPlanCommand, n as CliStructuredError$1$1, o as baseDirFor, p as contractPathFor, q as errorRefTargetEmpty, s as chooseAction, tt as errorStatementNeedsMigrationFile, u as cliInvocation, vt as rerunFlags, w as errorContractConfigMissing, wt as statementFlag, x as errorConfigValidation$1, xt as runCommandAction, y as errorAdvanceRefArgConflict, z as errorNoMigrations } from "./caught-errors-D8Hn_D5h-C4BJDZ5y.mjs";
8
- import { r as getEmittedArtifactPaths } from "./exports-CCuYD8dO-yw1GizAT.mjs";
9
- import { r as isInSpaceHistory } from "./graph-membership-D7m41lWA-B68g1CRS.mjs";
10
- import { i as readRef, n as advanceRef, u as validateRefName } from "./refs-t_JbIjGo-BVCqKpXd.mjs";
11
- import { a as contractHashAtMarker } from "./aggregate-D7dLfF9a.mjs";
12
- import { o as isLiveMarkerRef } from "./ref-resolution-C0xsiRig.mjs";
13
- import { $ as planEverySpace, A as executeMigrationNewCommand, B as labelsText, C as errorPermitPolicyChangeNeedsRef, Ct as statusForMigrationHash, Dt as writeAdvancedRef, Et as withWarningFindings, F as executeRefSetCommand, G as loadContractSource, H as liveMarkerUse, I as findPackageByDirPath, J as looksLikePath, K as loadContractSourceWithStack, L as formatSourceDiagnostic, N as executeRefDeleteCommand, P as executeRefListCommand, Q as migrationSpaceListEntriesFromAggregate, R as hasMigrationPath, S as enumerateCheckSpaces, St as sourceWarningDiagnostic, Tt as validateLoadedContract, U as loadAggregateIntegrityViolations, V as listRefsByContractHash, W as loadContractRawSafely, Y as mapContractAtError, Z as matchConsents, _ as databasePoliciesInForce, a as advanceRefSafely, at as refusePackageCorruptionOnAggregate, bt as skippedOperationsText, ct as requireDatabaseForLiveMarkerUse, d as buildRefAdvancementFields, dt as resolveContractRefToSnapshot, et as preflightRefAdvancement, f as checkSingleTarget, g as createControlClient, gt as retryCommandFor, h as convertAndDelete, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as refuseMissingInvariantPath, j as executeMigrationPlanCommand, k as executeMigrateShowPlan, l as buildMigrationSpaceGraphEntries, lt as resolveAppTargetPath, m as contractValidationMeta, n as NO_REF_ADVANCEMENT, nt as refuseContractSpaceIntegrity, ot as refuseUnknownInvariants, p as computeRefAdvancementName, pt as resolveMigrationRef, q as loadContractSpaceAggregateForCli, r as RECORDED_CONTRACT_REF_FORMS, s as appliedHashesFromLedger, st as renamedAndDeleted, t as ALL_CONTRACT_REF_FORMS, tt as readMigrationRefs, u as buildReadAggregate, ut as resolveContractRef$1, v as declaredSettingsText, vt as runMigrationCheck, w as executeContractEmit, wt as toDeclaredExtensionsFromRaw, xt as snapshotVerifierFor, y as deriveStatusEdgeAnnotations, yt as runMigrationList, z as isStatementVerb } from "./ref-BrtKINun-CRtoeAmD.mjs";
3
+ import { b as errorInvalidRefName, t as MigrationToolsError } from "./errors-BlaB9AFz-CZDOC0mV.mjs";
4
+ import { r as isInSpaceHistory } from "./graph-membership-ClCmhVjf-8XCns4rf.mjs";
5
+ import { s as reconstructGraph } from "./migration-graph-DBJAol1y-DX61Ss3X.mjs";
6
+ import { i as hasContractSnapshot, t as contractSnapshotDir } from "./contract-snapshot-store-Dl6v-Uxr-CwhnMsgc.mjs";
7
+ import { s as readMigrationsDir } from "./io-DUsSXBRO-BqRNb69U.mjs";
8
+ import { a as readRefs, i as readRef, n as advanceRef, u as validateRefName } from "./refs-BE6yEgSV-CbpqGnbl.mjs";
9
+ import { l as spaceMigrationDirectory, u as spaceRefsDirectory } from "./verify-contract-spaces-DvU9lE0Y-Y1WwEsPA.mjs";
10
+ import { a as contractHashAtMarker } from "./aggregate-B2D5REGs.mjs";
11
+ import { $ as errorSignRefsNotWritten, A as errorContractValidationFailed, At as redactUrlCredentials, C as errorAdvanceRefArgConflict, D as errorContractArgConflict, Dt as printedWayToTarget, E as errorConsentUnused, Et as printedPlan, F as errorFromCaught, Ft as runCommandAction, I as errorHashMismatch, It as selfEmitCommand, Lt as shellQuoted, M as errorDatabaseConnectionRequired, Mt as rerunFlags, N as errorDriverRequired, O as errorContractConfigMissing, Ot as quotedPlan, P as errorFileNotFound, Q as errorRuntime, R as errorLegendHumanOnly, Rt as statementFlag, St as migrationsDirFor, T as errorConfigValidation$1, U as errorNoMigrations, V as errorMigrationPackageNotFound, Z as errorRefTargetEmpty, _ as databasePositionOf, _t as migrationPlanChoice, a as appMigrationsDirFor, at as errorStatementNeedsMigrationFile, b as dbUpdateRerun, c as baseDirFor, ct as errorTargetMigrationNotSupported, f as cliInvocation, ft as hasMigrationPath, gt as migrationPlanArguments, h as contractPathFor, j as errorConvertAndDelete, jt as requireLiveDatabase, kt as readContractEnvelope, l as chooseAction, lt as errorTargetMismatch, mt as maskConnectionUrl, o as appRefsDirFor, p as closeQuietly, r as CliStructuredError$1$1, u as cliCommand, vt as migrationPlanForDatabase, x as displayPath, xt as migrationPlanTo, z as errorMarkerMissing, zt as targetSupportsMigrations } from "./caught-errors-DZXnK8Ls-zVmM4nr3.mjs";
12
+ import { r as getEmittedArtifactPaths } from "./exports-CCuYD8dO-fFXwpizm.mjs";
13
+ import { o as isLiveMarkerRef } from "./ref-resolution-533MGMov.mjs";
14
+ import { $ as preflightRefAdvancement, A as executeMigrationNewCommand, B as listRefsByContractHash, C as errorPermitPolicyChangeNeedsRef, Ct as toDeclaredExtensionsFromRaw, Et as writeAdvancedRef, F as executeRefSetCommand, G as loadContractSourceWithStack, H as loadAggregateIntegrityViolations, I as findPackageByDirPath, J as mapContractAtError, K as loadContractSpaceAggregateForCli, L as formatSourceDiagnostic, N as executeRefDeleteCommand, P as executeRefListCommand, Q as planEverySpace, R as isStatementVerb, S as enumerateCheckSpaces, St as statusForMigrationHash, Tt as withWarningFindings, U as loadContractRawSafely, V as liveMarkerUse, W as loadContractSource, X as matchConsents, Z as migrationSpaceListEntriesFromAggregate, _ as databasePoliciesInForce, _t as runMigrationCheck, a as advanceRefSafely, at as refuseUnknownInvariants, bt as snapshotVerifierFor, ct as resolveAppTargetPath, d as buildRefAdvancementFields, et as readMigrationRefs, f as checkSingleTarget, ft as resolveMigrationRef, g as createControlClient, h as convertAndDelete, ht as retryCommandFor, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as refusePackageCorruptionOnAggregate, j as executeMigrationPlanCommand, k as executeMigrateShowPlan, l as buildMigrationSpaceGraphEntries, lt as resolveContractRef$1, m as contractValidationMeta, n as NO_REF_ADVANCEMENT, ot as renamedAndDeleted, p as computeRefAdvancementName, q as looksLikePath, r as RECORDED_CONTRACT_REF_FORMS, rt as refuseMissingInvariantPath, s as appliedHashesFromLedger, st as requireDatabaseForLiveMarkerUse, t as ALL_CONTRACT_REF_FORMS, tt as refuseContractSpaceIntegrity, u as buildReadAggregate, ut as resolveContractRefToSnapshot, v as declaredSettingsText, vt as runMigrationList, w as executeContractEmit, wt as validateLoadedContract, xt as sourceWarningDiagnostic, y as deriveStatusEdgeAnnotations, yt as skippedOperationsText, z as labelsText } from "./ref-C7TozKnq-C4UYYbRT.mjs";
14
15
  import { a as PRISMA7_QUICK_REFERENCE_STEP, i as PRISMA7_LOOP_STEP, n as InitOutputSchema, o as buildNextSteps, r as NEXT_STEPS_BEFORE_SCAFFOLD, t as DB_SIGN_STEP } from "./output-BV7p64ql-nFpstc7l.mjs";
15
16
  import { a as resolveGating, i as readUserConfig, r as ensureInstallationId, s as runTelemetry, u as userConfigPath } from "./exports-DwuO4y2c.mjs";
16
17
  import { createRequire } from "node:module";
@@ -21,10 +22,10 @@ import { InternalError, isInternalError } from "@prisma/orm-framework/utils/inte
21
22
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
22
23
  import { DOCS_BASE, docsUrlFor, isStructuredError, isStructuredErrorCode } from "@prisma/orm-framework/utils/structured-error";
23
24
  import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve } from "pathe";
24
- import { errorMarkerPoliciesCorrupt } from "@prisma/orm-framework/errors/execution";
25
- import { mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
26
25
  import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
26
+ import { mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
27
27
  import { type } from "arktype";
28
+ import { errorMarkerPoliciesCorrupt } from "@prisma/orm-framework/errors/execution";
28
29
  import { existsSync, fstatSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
29
30
  import { fileURLToPath, pathToFileURL } from "node:url";
30
31
  import { createCli, defineCommand, defineCommandFamily, defineServerCommand, flag, noDataLines, positional, telemetryCommandGroup } from "@prisma/cli-engine";
@@ -42,8 +43,8 @@ import stringWidth from "string-width";
42
43
  import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
43
44
  import { isCI } from "ci-info";
44
45
  import { build } from "esbuild";
45
- //#region ../../../1-framework/3-tooling/cli/dist/cli-DLmoumqa.mjs
46
- var version = "8.0.0-rc.24-dev.43";
46
+ //#region ../../../1-framework/3-tooling/cli/dist/cli-D0IHPTEs.mjs
47
+ var version = "8.0.0-rc.24-dev.44";
47
48
  const ESCAPES = {
48
49
  "\\": "\\\\",
49
50
  " ": "\\t",
@@ -954,16 +955,31 @@ function previewBlocks$2(preview) {
954
955
  lines: statements
955
956
  }];
956
957
  }
957
- /** The new required fields whose existing rows get a temporary value, and how to choose the value. */
958
- function temporaryValueBlocks$1(result, invocation, databaseStorageHash) {
958
+ /**
959
+ * The new required fields whose existing rows get a temporary value, and how to choose the value:
960
+ * before the run, with `migrationPlan` instead; after it, by updating
961
+ * the rows, since the database already has the new contract.
962
+ */
963
+ function temporaryValueBlocks$1(result, invocation, migrationPlan) {
964
+ const choose = (field) => {
965
+ if (result.mode === "apply") return " To choose another value, update those rows.";
966
+ if (migrationPlan === void 0) return "";
967
+ const plan = printedWayToTarget(invocation, migrationPlan, [statementFlag({
968
+ verb: "backfill",
969
+ text: field
970
+ })]);
971
+ switch (plan.kind) {
972
+ case "on-disk": return ` ${plan.reason}. To fill the rows as they do, apply them with \`${plan.apply}\` instead.`;
973
+ case "none":
974
+ case "at-target": return ` No migration can be planned to choose it. ${plan.reason}.`;
975
+ default: return ` To choose the value instead, plan a migration with ${quotedPlan(plan)}, ${plan.afterPlan}.`;
976
+ }
977
+ };
959
978
  const get = result.mode === "plan" ? "would get" : "got";
960
979
  return (result.temporaryValues ?? []).map(({ field, value }) => ({
961
980
  kind: "summary",
962
981
  status: "warn",
963
- text: `Field "${field}" ${get} the temporary value ${value} where existing data has none. To choose the value, plan a migration with ${printedPlanCommand(invocation, databaseStorageHash, [statementFlag({
964
- verb: "backfill",
965
- text: field
966
- })])} instead.`
982
+ text: `Field "${field}" ${get} the temporary value ${value} where existing data has none.${choose(field)}`
967
983
  }));
968
984
  }
969
985
  function planSummaryText(result) {
@@ -1035,7 +1051,7 @@ function questionBlocks(result) {
1035
1051
  }]
1036
1052
  }];
1037
1053
  }
1038
- function planBlocks$1(result, invocation, databaseStorageHash) {
1054
+ function planBlocks$1(result, invocation, migrationPlan) {
1039
1055
  const planned = result.plannedAdvanceRef;
1040
1056
  return [
1041
1057
  {
@@ -1045,7 +1061,7 @@ function planBlocks$1(result, invocation, databaseStorageHash) {
1045
1061
  },
1046
1062
  ...plannerWarningBlocks(result),
1047
1063
  ...operationBlocks$2(result),
1048
- ...temporaryValueBlocks$1(result, invocation, databaseStorageHash),
1064
+ ...temporaryValueBlocks$1(result, invocation, migrationPlan),
1049
1065
  ...appliedStatementBlocks(result.appliedStatements ?? []),
1050
1066
  ...questionBlocks(result),
1051
1067
  {
@@ -1121,7 +1137,7 @@ function permittedStatementBlocks(result) {
1121
1137
  }] : [];
1122
1138
  });
1123
1139
  }
1124
- function applyBlocks(result, invocation, databaseStorageHash) {
1140
+ function applyBlocks(result, invocation, migrationPlan) {
1125
1141
  const advanced = result.advancedRef;
1126
1142
  return [
1127
1143
  {
@@ -1131,7 +1147,7 @@ function applyBlocks(result, invocation, databaseStorageHash) {
1131
1147
  },
1132
1148
  ...plannerWarningBlocks(result),
1133
1149
  ...operationBlocks$2(result),
1134
- ...temporaryValueBlocks$1(result, invocation, databaseStorageHash),
1150
+ ...temporaryValueBlocks$1(result, invocation, migrationPlan),
1135
1151
  ...appliedStatementBlocks(result.appliedStatements ?? []),
1136
1152
  ...permittedStatementBlocks(result),
1137
1153
  ...fallbackMarkerBlocks(result),
@@ -1147,11 +1163,11 @@ function applyBlocks(result, invocation, databaseStorageHash) {
1147
1163
  }
1148
1164
  /**
1149
1165
  * What a `db init` / `db update` result looks like in human mode. Printed commands repeat
1150
- * `invocation`, and a printed `migration plan` starts from `databaseStorageHash`, the contract the
1151
- * database was at before the run, when a migration on disk ends at it.
1166
+ * `invocation`, and a printed `migration plan` is `migrationPlan`, which `db init`
1167
+ * does not give.
1152
1168
  */
1153
- function migrationResultBlocks(result, invocation, databaseStorageHash) {
1154
- return result.mode === "plan" ? planBlocks$1(result, invocation, databaseStorageHash) : applyBlocks(result, invocation, databaseStorageHash);
1169
+ function migrationResultBlocks(result, invocation, migrationPlan) {
1170
+ return result.mode === "plan" ? planBlocks$1(result, invocation, migrationPlan) : applyBlocks(result, invocation, migrationPlan);
1155
1171
  }
1156
1172
  /** Where the user goes next, as typed actions rather than trailing prose. */
1157
1173
  function migrationResultNextActions(result, invocation, applyCommand) {
@@ -2389,7 +2405,7 @@ function updatePresentations(inputs) {
2389
2405
  value: "dry run"
2390
2406
  }] : []
2391
2407
  ]
2392
- }, ...migrationResultBlocks(document, inputs.invocation, inputs.databaseStorageHash)],
2408
+ }, ...migrationResultBlocks(document, inputs.invocation, inputs.migrationPlan)],
2393
2409
  json: () => document,
2394
2410
  next: () => migrationResultNextActions(document, inputs.invocation, dbUpdateRerun(inputs.invocation, inputs.statements.map(statementFlag)))
2395
2411
  };
@@ -2540,15 +2556,33 @@ function createDbUpdateCommand(createClient) {
2540
2556
  text
2541
2557
  })));
2542
2558
  const cannotBeVariantConverts = fieldStatements.filter(({ verb, text }) => verb === "backfill" || text.split(".").length === 3);
2559
+ let destination;
2560
+ if (args.flags.to !== void 0) {
2561
+ const resolved = await resolveContractRefToSnapshot({
2562
+ config: ctx.config,
2563
+ migrationsDir: migrationsDirFor(ctx.config),
2564
+ refInput: args.flags.to,
2565
+ argument: "--to",
2566
+ fallbackToEmitted: false
2567
+ });
2568
+ if (!resolved.ok) return notOk$1(normalizeError(resolved.failure));
2569
+ destination = resolved.value;
2570
+ }
2543
2571
  if (cannotBeVariantConverts.length > 0) {
2544
- const databaseStorageHash = await databaseContractIfReachable({
2572
+ const migrationPlan = await migrationPlanIfReachable({
2545
2573
  config: ctx.config,
2546
2574
  cwd: ctx.cwd,
2547
2575
  db: args.flags.db,
2548
2576
  commandName: "db update",
2549
2577
  createClient
2550
- });
2551
- return notOk$1(normalizeError(errorStatementNeedsMigrationFile(given, cannotBeVariantConverts, cliInvocation(ctx, args.flags.db), databaseStorageHash)));
2578
+ }, destination);
2579
+ return notOk$1(normalizeError(errorStatementNeedsMigrationFile(given, cannotBeVariantConverts, {
2580
+ ...cliInvocation(ctx, args.flags.db),
2581
+ rerunArgs: rerunFlags({
2582
+ ...args.flags,
2583
+ noAdvanceRef: void 0
2584
+ })
2585
+ }, migrationPlan)));
2552
2586
  }
2553
2587
  const planned = [...ctx.statements.take("rename").map(({ text }) => ({
2554
2588
  verb: "rename",
@@ -2561,18 +2595,6 @@ function createDbUpdateCommand(createClient) {
2561
2595
  verb: "allow",
2562
2596
  text
2563
2597
  }))] : [];
2564
- let destination;
2565
- if (args.flags.to !== void 0) {
2566
- const resolved = await resolveContractRefToSnapshot({
2567
- config: ctx.config,
2568
- migrationsDir: migrationsDirFor(ctx.config),
2569
- refInput: args.flags.to,
2570
- argument: "--to",
2571
- fallbackToEmitted: false
2572
- });
2573
- if (!resolved.ok) return notOk$1(normalizeError(resolved.failure));
2574
- destination = resolved.value;
2575
- }
2576
2598
  if (args.flags.permitPolicyChange === true && destination?.ref === void 0) return notOk$1(normalizeError(errorPermitPolicyChangeNeedsRef({
2577
2599
  command: "db update",
2578
2600
  to: args.flags.to
@@ -2621,7 +2643,7 @@ function createDbUpdateCommand(createClient) {
2621
2643
  }
2622
2644
  const mode = args.flags.dryRun ? "plan" : "apply";
2623
2645
  let document;
2624
- let databaseStorageHash;
2646
+ let migrationPlan;
2625
2647
  try {
2626
2648
  await client.connect(dbConnection);
2627
2649
  const plannerWarnings = plannerWarningsCollector(ctx.report);
@@ -2646,6 +2668,7 @@ function createDbUpdateCommand(createClient) {
2646
2668
  }),
2647
2669
  statementArgs
2648
2670
  },
2671
+ ...ifDefined("emittedContractHash", storageHashOf(prepared.value.contractJson)),
2649
2672
  onPlannerWarnings: plannerWarnings.onPlannerWarnings,
2650
2673
  onProgress: controlProgressReporter(ctx.report)
2651
2674
  });
@@ -2663,7 +2686,7 @@ function createDbUpdateCommand(createClient) {
2663
2686
  hash: advancementHash
2664
2687
  });
2665
2688
  if (!advanced.ok) return notOk$1(normalizeError(advanced.failure));
2666
- databaseStorageHash = result.value.databaseStorageHash;
2689
+ migrationPlan = result.value.migrationPlan;
2667
2690
  document = updateDocument({
2668
2691
  value: result.value,
2669
2692
  targetId: ctx.config.target.targetId,
@@ -2697,7 +2720,7 @@ function createDbUpdateCommand(createClient) {
2697
2720
  noAdvanceRef: void 0
2698
2721
  })
2699
2722
  },
2700
- databaseStorageHash,
2723
+ migrationPlan,
2701
2724
  contractPath: prepared.value.contractDisplayPath,
2702
2725
  database: prepared.value.database,
2703
2726
  to: args.flags.to,
@@ -2709,28 +2732,80 @@ function createDbUpdateCommand(createClient) {
2709
2732
  }
2710
2733
  const dbUpdateCommand = createDbUpdateCommand(createControlClient);
2711
2734
  /**
2712
- * The storage hash of the contract the database is at, when the database already exists and can be
2713
- * reached and a migration of the application space ends at that contract, so that `migration plan
2714
- * --from` resolves it. Anything else gives undefined: this only adds `--from` to a refusal, and it
2715
- * never creates a database to read the marker.
2735
+ * The `migration plan` that takes the database where `db update` goes: to `destination`, the
2736
+ * contract `--to` named, or else the emitted contract. The migrations and refs are read offline;
2737
+ * when the database cannot be read, the user chooses where the plan starts, told why.
2716
2738
  */
2717
- async function databaseContractIfReachable(inputs) {
2739
+ async function migrationPlanIfReachable(inputs, destination) {
2740
+ const end = destination === void 0 ? { kind: "emitted" } : destination.ref !== void 0 ? {
2741
+ kind: "ref",
2742
+ name: destination.ref.name
2743
+ } : {
2744
+ kind: "contract",
2745
+ hash: destination.hash
2746
+ };
2718
2747
  const prepared = await prepareMigrationRun(inputs);
2719
- if (!prepared.ok) return void 0;
2748
+ if (!prepared.ok) return {
2749
+ from: migrationPlanChoice(void 0, "The CLI could not prepare a connection to the database from the config"),
2750
+ to: migrationPlanTo(NO_MIGRATIONS, end)
2751
+ };
2720
2752
  const { client, dbConnection, migrationsDir } = prepared.value;
2721
- const read = async () => {
2753
+ const emittedHash = storageHashOf(prepared.value.contractJson);
2754
+ const space = await readPlanSpace(migrationsDir, emittedHash).catch(() => void 0);
2755
+ const readMarker = async () => {
2722
2756
  await client.connect(dbConnection, {
2723
2757
  existingDatabaseOnly: true,
2724
2758
  connectTimeoutMs: MARKER_READ_TIMEOUT_MS
2725
2759
  });
2726
- const marker = await client.readMarker();
2727
- if (marker === null) return void 0;
2728
- const { packages } = await readMigrationsDir(join(migrationsDir, APP_SPACE_ID), { migrationsDir });
2729
- return packages.some(({ metadata }) => metadata.to === marker.storageHash) ? marker.storageHash : void 0;
2760
+ return {
2761
+ kind: "read",
2762
+ marker: await client.readMarker()
2763
+ };
2764
+ };
2765
+ const read = await settledWithin(readMarker().catch((error) => ({
2766
+ kind: "failed",
2767
+ cause: causeText(error)
2768
+ })).finally(() => closeQuietly(client)), MARKER_READ_TIMEOUT_MS);
2769
+ const position = read === void 0 ? {
2770
+ kind: "unknown",
2771
+ reason: `The CLI could not read the database within ${MARKER_READ_TIMEOUT_MS / 1e3} seconds to find the contract it is at`
2772
+ } : read.kind === "failed" ? {
2773
+ kind: "unknown",
2774
+ reason: `The CLI could not read the database: ${read.cause}`
2775
+ } : databasePositionOf(read.marker?.storageHash);
2776
+ if (space !== void 0) return read?.kind === "read" ? migrationPlanForDatabase(space, read.marker, end) : migrationPlanArguments(space, position, end);
2777
+ return {
2778
+ from: migrationPlanChoice(void 0, position.kind === "unknown" ? position.reason : "The CLI could not read the migrations"),
2779
+ to: migrationPlanTo({
2780
+ ...NO_MIGRATIONS,
2781
+ ...ifDefined("emittedHash", emittedHash)
2782
+ }, end)
2783
+ };
2784
+ }
2785
+ /** A space read as having no migrations and no refs, for when the migrations cannot be read. */
2786
+ const NO_MIGRATIONS = {
2787
+ graph: reconstructGraph([]),
2788
+ refs: {}
2789
+ };
2790
+ function storageHashOf(contractJson) {
2791
+ const storage = contractJson["storage"];
2792
+ if (typeof storage !== "object" || storage === null) return void 0;
2793
+ const hash = "storageHash" in storage ? storage.storageHash : void 0;
2794
+ return typeof hash === "string" ? hash : void 0;
2795
+ }
2796
+ function causeText(error) {
2797
+ return error instanceof Error ? error.message : String(error);
2798
+ }
2799
+ async function readPlanSpace(migrationsDir, emittedHash) {
2800
+ const appDir = spaceMigrationDirectory(migrationsDir, APP_SPACE_ID);
2801
+ const { packages } = await readMigrationsDir(appDir, { migrationsDir });
2802
+ return {
2803
+ graph: reconstructGraph(packages),
2804
+ refs: await readRefs(spaceRefsDirectory(appDir)),
2805
+ ...ifDefined("emittedHash", emittedHash)
2730
2806
  };
2731
- return settledWithin(read().catch(() => void 0).finally(() => closeQuietly(client)), MARKER_READ_TIMEOUT_MS);
2732
2807
  }
2733
- /** How long the refusal waits for the marker before it refuses without `--from`. */
2808
+ /** How long the refusal waits for the database before it leaves the plan's origin to the user. */
2734
2809
  const MARKER_READ_TIMEOUT_MS = 3e3;
2735
2810
  function settledWithin(promise, ms) {
2736
2811
  return new Promise((resolve) => {
@@ -7655,7 +7730,7 @@ const lspCommand = defineServerCommand({
7655
7730
  } },
7656
7731
  handler: async (args, io) => {
7657
7732
  const exitCode = await withoutClientProcessIdInArgv(async () => {
7658
- const { startServer } = await import("./exports-BiXPktAF.mjs");
7733
+ const { startServer } = await import("./exports-B0yFVod3.mjs");
7659
7734
  return startServer({
7660
7735
  stdin: io.stdin,
7661
7736
  stdout: io.stdout,
@@ -10354,7 +10429,8 @@ function createMigrateCommand(createClient, writeRefPointer = advanceRef) {
10354
10429
  migrationsDir,
10355
10430
  invocation: {
10356
10431
  ...cliInvocation(ctx, args.flags.db),
10357
- rerunArgs: rerunFlags(args.flags)
10432
+ rerunArgs: rerunFlags(args.flags),
10433
+ ...ifDefined("targetRef", target.refName)
10358
10434
  },
10359
10435
  onProgress: controlProgressReporter(ctx.report),
10360
10436
  ...ifDefined("target", migrateTargetOf(target)),
@@ -11186,6 +11262,7 @@ function createMigrationNewCommand(createClient) {
11186
11262
  const scaffolded = await executeMigrationNewCommand({
11187
11263
  config: ctx.config,
11188
11264
  cwd: ctx.cwd,
11265
+ ...ifDefined("configPath", ctx.configPath),
11189
11266
  ...ifDefined("name", args.flags.name),
11190
11267
  ...ifDefined("from", args.flags.from),
11191
11268
  client: createClient({
@@ -11918,13 +11995,41 @@ function describeOrigin(origin) {
11918
11995
  if (origin.kind === "offline") return `the --from contract (${shortDisplayHash(origin.hash)})`;
11919
11996
  return origin.marker !== void 0 ? `the database state (${shortDisplayHash(origin.marker.storageHash)})` : "the database state";
11920
11997
  }
11998
+ /** Where `migration status` aims, as `migration plan` would end there: a ref, or a contract by its hash. */
11999
+ function statusPlanEnd(refName, targetHash) {
12000
+ return refName === void 0 ? {
12001
+ kind: "contract",
12002
+ hash: targetHash
12003
+ } : {
12004
+ kind: "ref",
12005
+ name: refName
12006
+ };
12007
+ }
12008
+ /** The summary with no migrations: the `migration plan` that writes the first, or why none can. */
12009
+ function firstPlanText(plan) {
12010
+ if (plan === void 0) return "No migrations found";
12011
+ switch (plan.kind) {
12012
+ case "runs": return `No migrations found. Run \`${plan.command}\` to author the first.`;
12013
+ case "fill": return `No migrations found. Run \`${plan.command}\` to author the first. ${plan.fill}.`;
12014
+ case "none": return `No migrations found, and no migration plan can author the first. ${plan.reason}.`;
12015
+ }
12016
+ }
12017
+ /** How the summary says to author the missing path, or why no `migration plan` can. */
12018
+ function authorText(target) {
12019
+ const { plan } = target;
12020
+ switch (plan.kind) {
12021
+ case "runs": return `Run \`${plan.command}\` to author one`;
12022
+ case "fill": return `Run \`${plan.command}\` to author one. ${plan.fill}`;
12023
+ case "none": return `No migration plan can author one. ${plan.reason}. Inspect the graph with \`${target.listCommand}\``;
12024
+ }
12025
+ }
11921
12026
  function buildNoPathSummary(args) {
11922
12027
  const markerPart = describeOrigin(args.origin);
11923
12028
  const targetShort = shortDisplayHash(args.targetHash);
11924
12029
  const { target } = args;
11925
12030
  if (target.kind === "extension") return `No migration path from ${markerPart} to the head of extension space \`${target.spaceId}\` (${targetShort}).`;
11926
- if (!target.explicitTarget) return `No migration path from ${markerPart} to the application's contract (${targetShort}). Run \`{bin} migration plan --name <name>\` to author one.`;
11927
- return `No migration path from ${markerPart} to ${target.refName !== void 0 ? `the target (${targetShort} via \`${target.refName}\`)` : `the target (${targetShort})`}. Run \`{bin} migration plan --name <name>\` to author one, or pass \`--to <contract>\` to pick a reachable target.`;
12031
+ if (!target.explicitTarget) return `No migration path from ${markerPart} to the application's contract (${targetShort}). ${authorText(target)}.`;
12032
+ return `No migration path from ${markerPart} to ${target.refName !== void 0 ? `the target (${targetShort} via \`${target.refName}\`)` : `the target (${targetShort})`}. ${authorText(target)}, or pass \`--to <contract>\` to pick a reachable target.`;
11928
12033
  }
11929
12034
  function buildStatusHeadline(args) {
11930
12035
  if (args.markerDiverged && args.markerHash !== void 0) return `Database marker ${shortDisplayHash(args.markerHash)} is not in the on-disk migration graph`;
@@ -12084,6 +12189,7 @@ const migrationStatusCommand = defineOrmCommand({
12084
12189
  if (corruption) return notOk$1(normalizeError(corruption));
12085
12190
  }
12086
12191
  const appGraph = aggregate.app.graph();
12192
+ const invocation = cliInvocation(ctx, void 0);
12087
12193
  const refContext = {
12088
12194
  graph: appGraph,
12089
12195
  refs,
@@ -12145,6 +12251,7 @@ const migrationStatusCommand = defineOrmCommand({
12145
12251
  const emptySpaces = [];
12146
12252
  let divergedMarker;
12147
12253
  let noPath;
12254
+ let firstPlan;
12148
12255
  let headlineTargetHash = activeRefHash ?? contractHash;
12149
12256
  let totalPending = 0;
12150
12257
  let reportedUnreadablePolicies = false;
@@ -12165,6 +12272,11 @@ const migrationStatusCommand = defineOrmCommand({
12165
12272
  const space = aggregate.space(entry.space);
12166
12273
  if (space === void 0) continue;
12167
12274
  const graph = space.graph();
12275
+ const planSpace = {
12276
+ graph,
12277
+ refs: space.refs,
12278
+ emittedHash: contractHash
12279
+ };
12168
12280
  const spaceContractHash = space.contract().storage.storageHash;
12169
12281
  const isAppSpace = entry.space === aggregate.app.spaceId;
12170
12282
  const targetHash = isAppSpace ? activeRefHash ?? spaceContractHash : spaceContractHash;
@@ -12177,6 +12289,11 @@ const migrationStatusCommand = defineOrmCommand({
12177
12289
  hash: fromOverrideHash
12178
12290
  } : void 0;
12179
12291
  const originHash = originHashOf(origin);
12292
+ const appPlan = () => printedPlan(invocation, migrationPlanArguments(planSpace, origin === void 0 ? {
12293
+ kind: "unknown",
12294
+ reason: "migration status read no database to find where it is"
12295
+ } : databasePositionOf(origin.kind === "offline" ? origin.hash : origin.marker?.storageHash), statusPlanEnd(activeRefName, targetHash)), ["--name", "<name>"]);
12296
+ if (isAppSpace && originHash !== targetHash && graph.nodes.size === 0) firstPlan = appPlan();
12180
12297
  const markerRead = origin?.kind === "database" || isAppSpace && liveTarget;
12181
12298
  const readMarker = origin?.kind === "database" ? origin.marker : markerRead ? appMarker : void 0;
12182
12299
  const markerDiverged = readMarker !== void 0 && !isInSpaceHistory(readMarker.storageHash, {
@@ -12196,7 +12313,9 @@ const migrationStatusCommand = defineOrmCommand({
12196
12313
  target: isAppSpace ? {
12197
12314
  kind: "app",
12198
12315
  explicitTarget: to !== void 0,
12199
- refName: activeRefName
12316
+ refName: activeRefName,
12317
+ plan: appPlan(),
12318
+ listCommand: cliCommand(invocation, "migration list")
12200
12319
  } : {
12201
12320
  kind: "extension",
12202
12321
  spaceId: entry.space
@@ -12274,7 +12393,7 @@ const migrationStatusCommand = defineOrmCommand({
12274
12393
  showHeading: showSpaceHeadings
12275
12394
  };
12276
12395
  });
12277
- const pathSummary = scopedSpaces.every((entry) => entry.migrations.length === 0) ? "No migrations found" : noPath !== void 0 ? buildNoPathSummary(noPath) : buildStatusHeadline({
12396
+ const pathSummary = scopedSpaces.every((entry) => entry.migrations.length === 0) ? firstPlanText(firstPlan) : noPath !== void 0 ? buildNoPathSummary(noPath) : buildStatusHeadline({
12278
12397
  pendingCount: totalPending,
12279
12398
  targetHash: headlineTargetHash,
12280
12399
  refName: activeRefName,
@@ -12567,10 +12686,10 @@ const ormCommandFamily = defineCommandFamily({
12567
12686
  v7Command("migrate dev", {
12568
12687
  replacement: [
12569
12688
  "{bin} contract emit",
12570
- "{bin} migration plan --name <name>",
12689
+ "{bin} migration status",
12571
12690
  "{bin} db migrate"
12572
12691
  ],
12573
- reason: "Prisma 8 emits the contract, plans the migration and applies it in separate steps: run `contract emit`, then `migration plan --name <name>` (for `--create-only`, stop here), then `db migrate`.",
12692
+ reason: "Prisma 8 emits the contract, plans the migration and applies it in separate steps: run `contract emit`, then `migration status`, which prints the `migration plan` that plans it from where the database is, and run that plan, fill in any placeholders it leaves and run the `node` command it prints (for `--create-only`, stop here), then `db migrate`. When migrations on disk already lead to the new contract, `migration status` prints no plan, and `db migrate` applies them.",
12574
12693
  whileMigrationsStayOnPrisma7: true,
12575
12694
  help: "contract emit"
12576
12695
  }),