@prisma/orm-toolchain 8.0.0-rc.1-dev.46 → 8.0.0-rc.10-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 (123) hide show
  1. package/README.md +1 -5
  2. package/dist/{aggregate-CPZB020V.mjs → aggregate-B4HKshLQ.mjs} +10 -10
  3. package/dist/aggregate-B4HKshLQ.mjs.map +1 -0
  4. package/dist/{aggregate-DLUJLq5Y.d.mts → aggregate-D_eX4zoo.d.mts} +3 -3
  5. package/dist/{aggregate-DLUJLq5Y.d.mts.map → aggregate-D_eX4zoo.d.mts.map} +1 -1
  6. package/dist/cli-telemetry.d.mts +8 -7
  7. package/dist/cli-telemetry.d.mts.map +1 -1
  8. package/dist/cli-telemetry.mjs +22 -24
  9. package/dist/cli-telemetry.mjs.map +1 -1
  10. package/dist/cli.d.mts +2 -6
  11. package/dist/cli.d.mts.map +1 -1
  12. package/dist/cli.mjs +447 -430
  13. package/dist/cli.mjs.map +1 -1
  14. package/dist/cli__control-api.d.mts +20 -11
  15. package/dist/cli__control-api.d.mts.map +1 -1
  16. package/dist/cli__control-api.mjs +1 -1
  17. package/dist/cli__control-api__testing.d.mts +1 -1
  18. package/dist/cli__init-output.mjs +1 -1
  19. package/dist/cli__migration-cli.mjs +6 -6
  20. package/dist/cli__migration-cli.mjs.map +1 -1
  21. package/dist/config-loader.d.mts +1 -1
  22. package/dist/config-loader.mjs +1 -1
  23. package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs → contract-snapshot-store-qGrwlGmt-Cf2NFzRL.mjs} +3 -3
  24. package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs.map → contract-snapshot-store-qGrwlGmt-Cf2NFzRL.mjs.map} +1 -1
  25. package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts → db-verify-Yih5kWtB-B1kv76ec.d.mts} +5 -5
  26. package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts.map → db-verify-Yih5kWtB-B1kv76ec.d.mts.map} +1 -1
  27. package/dist/{domain-type-generation-bpSO3Y0L-jo2C7LlH.mjs → domain-type-generation-CR9ECUau-DOlKbcaE.mjs} +20 -6
  28. package/dist/domain-type-generation-CR9ECUau-DOlKbcaE.mjs.map +1 -0
  29. package/dist/{domain-type-generation-PkAb39ob-Ct8AGqow.d.mts → domain-type-generation-X6-AaL1U-DHEoRf_y.d.mts} +14 -3
  30. package/dist/domain-type-generation-X6-AaL1U-DHEoRf_y.d.mts.map +1 -0
  31. package/dist/emitter.d.mts +2 -2
  32. package/dist/emitter.mjs +2 -2
  33. package/dist/emitter__domain-type-generation.d.mts +2 -2
  34. package/dist/emitter__domain-type-generation.mjs +2 -2
  35. package/dist/{errors-CXbGUWGu-CstQHPh6.mjs → errors-SoLLYLtw-DMxVbVs9.mjs} +9 -9
  36. package/dist/errors-SoLLYLtw-DMxVbVs9.mjs.map +1 -0
  37. package/dist/{exports-BZaG8_w_.mjs → exports-BXXeNWlj.mjs} +25 -47
  38. package/dist/exports-BXXeNWlj.mjs.map +1 -0
  39. package/dist/exports-CE6OD63o-4Qpqr2W7.mjs +398 -0
  40. package/dist/exports-CE6OD63o-4Qpqr2W7.mjs.map +1 -0
  41. package/dist/{exports-8ZUN43ve.mjs → exports-CYa2di3d.mjs} +382 -22
  42. package/dist/exports-CYa2di3d.mjs.map +1 -0
  43. package/dist/{graph-membership-BViWUMpP-C4lYYJdU.mjs → graph-membership-DY1Onbc3-CwBd6wuB.mjs} +3 -3
  44. package/dist/{graph-membership-BViWUMpP-C4lYYJdU.mjs.map → graph-membership-DY1Onbc3-CwBd6wuB.mjs.map} +1 -1
  45. package/dist/{import-roots-CfoYgejL.d.mts → import-roots-ARK1wjzc.d.mts} +3 -3
  46. package/dist/{import-roots-CfoYgejL.d.mts.map → import-roots-ARK1wjzc.d.mts.map} +1 -1
  47. package/dist/{import-roots-CNFBPAT1.mjs → import-roots-BHOrDJbI.mjs} +5 -5
  48. package/dist/import-roots-BHOrDJbI.mjs.map +1 -0
  49. package/dist/{index-Dgwl8Tzs.d.mts → index-D217lbiW.d.mts} +7 -3
  50. package/dist/index-D217lbiW.d.mts.map +1 -0
  51. package/dist/{index-DRs7L6N0.d.mts → index-u5RdrumF.d.mts} +2 -19
  52. package/dist/index-u5RdrumF.d.mts.map +1 -0
  53. package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs → invariants-Cww4bv0v-BEiFxmbX.mjs} +3 -3
  54. package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs.map → invariants-Cww4bv0v-BEiFxmbX.mjs.map} +1 -1
  55. package/dist/{io-635GlNx1-D3zrw2qu.mjs → io-BmWQNxRP-DQqbcPsS.mjs} +5 -5
  56. package/dist/{io-635GlNx1-D3zrw2qu.mjs.map → io-BmWQNxRP-DQqbcPsS.mjs.map} +1 -1
  57. package/dist/{migration-hspPIEeV.mjs → migration-B9w-7dKe.mjs} +4 -4
  58. package/dist/{migration-hspPIEeV.mjs.map → migration-B9w-7dKe.mjs.map} +1 -1
  59. package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs → migration-graph-CW4bMmTz-B5xFtFVB.mjs} +3 -3
  60. package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs.map → migration-graph-CW4bMmTz-B5xFtFVB.mjs.map} +1 -1
  61. package/dist/migration-tools.d.mts +3 -3
  62. package/dist/migration-tools.mjs +12 -12
  63. package/dist/migration-tools__aggregate.d.mts +1 -1
  64. package/dist/migration-tools__aggregate.mjs +1 -1
  65. package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
  66. package/dist/migration-tools__errors.mjs +1 -1
  67. package/dist/migration-tools__invariants.mjs +1 -1
  68. package/dist/migration-tools__io.mjs +1 -1
  69. package/dist/migration-tools__migration-graph.mjs +2 -2
  70. package/dist/migration-tools__migration.mjs +1 -1
  71. package/dist/migration-tools__ref-resolution.d.mts +1 -1
  72. package/dist/migration-tools__ref-resolution.mjs +1 -1
  73. package/dist/migration-tools__refs.mjs +1 -1
  74. package/dist/migration-tools__spaces.d.mts +1 -1
  75. package/dist/migration-tools__spaces.mjs +2 -2
  76. package/dist/{output-CovTDY14-CUoAqLML.mjs → output-D83nTTpC-XlvN30yS.mjs} +4 -4
  77. package/dist/{output-CovTDY14-CUoAqLML.mjs.map → output-D83nTTpC-XlvN30yS.mjs.map} +1 -1
  78. package/dist/publish-surface.d.mts +1 -1
  79. package/dist/publish-surface.mjs +2 -2
  80. package/dist/publish-surface__import-roots.d.mts +1 -1
  81. package/dist/publish-surface__import-roots.mjs +1 -1
  82. package/dist/publish-surface__shells.mjs +1 -1
  83. package/dist/quick-reference-mongo.md +11 -11
  84. package/dist/quick-reference-postgres.md +10 -10
  85. package/dist/readme-mongo.md +6 -6
  86. package/dist/readme-postgres.md +6 -6
  87. package/dist/{ref-h6InR6dO-rGfl18Jv.mjs → ref-DcqFmceq-QaUjgZeM.mjs} +190 -87
  88. package/dist/ref-DcqFmceq-QaUjgZeM.mjs.map +1 -0
  89. package/dist/{ref-resolution-HeNBXW53.mjs → ref-resolution-BWpwb8_b.mjs} +9 -2
  90. package/dist/ref-resolution-BWpwb8_b.mjs.map +1 -0
  91. package/dist/{ref-resolution-COGOSL57.d.mts → ref-resolution-CaHQJXE0.d.mts} +11 -1
  92. package/dist/ref-resolution-CaHQJXE0.d.mts.map +1 -0
  93. package/dist/{refs-WK86uYYp-gM8tvWQP.mjs → refs-BpSpzdYB-BcDelHGt.mjs} +9 -9
  94. package/dist/refs-BpSpzdYB-BcDelHGt.mjs.map +1 -0
  95. package/dist/{shells-C4HbRAr5.mjs → shells-BIdFZwUY.mjs} +1 -6
  96. package/dist/shells-BIdFZwUY.mjs.map +1 -0
  97. package/dist/{spaces-Dj65JrwZ.d.mts → spaces-B20bgxF9.d.mts} +2 -2
  98. package/dist/{spaces-Dj65JrwZ.d.mts.map → spaces-B20bgxF9.d.mts.map} +1 -1
  99. package/dist/{spaces-4qMOAYE9.mjs → spaces-BCZiAZQn.mjs} +7 -7
  100. package/dist/spaces-BCZiAZQn.mjs.map +1 -0
  101. package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs → verify-contract-spaces-CrxvgpwD-D5LLXGci.mjs} +7 -7
  102. package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs.map → verify-contract-spaces-CrxvgpwD-D5LLXGci.mjs.map} +1 -1
  103. package/dist/vite-plugin-contract-emit.d.mts +1 -1
  104. package/dist/vite-plugin-contract-emit.mjs +7 -7
  105. package/dist/vite-plugin-contract-emit.mjs.map +1 -1
  106. package/package.json +16 -16
  107. package/dist/aggregate-CPZB020V.mjs.map +0 -1
  108. package/dist/domain-type-generation-PkAb39ob-Ct8AGqow.d.mts.map +0 -1
  109. package/dist/domain-type-generation-bpSO3Y0L-jo2C7LlH.mjs.map +0 -1
  110. package/dist/errors-CXbGUWGu-CstQHPh6.mjs.map +0 -1
  111. package/dist/exports-8ZUN43ve.mjs.map +0 -1
  112. package/dist/exports-BCLg4CiV-05kuwcb0.mjs +0 -160
  113. package/dist/exports-BCLg4CiV-05kuwcb0.mjs.map +0 -1
  114. package/dist/exports-BZaG8_w_.mjs.map +0 -1
  115. package/dist/import-roots-CNFBPAT1.mjs.map +0 -1
  116. package/dist/index-DRs7L6N0.d.mts.map +0 -1
  117. package/dist/index-Dgwl8Tzs.d.mts.map +0 -1
  118. package/dist/ref-h6InR6dO-rGfl18Jv.mjs.map +0 -1
  119. package/dist/ref-resolution-COGOSL57.d.mts.map +0 -1
  120. package/dist/ref-resolution-HeNBXW53.mjs.map +0 -1
  121. package/dist/refs-WK86uYYp-gM8tvWQP.mjs.map +0 -1
  122. package/dist/shells-C4HbRAr5.mjs.map +0 -1
  123. package/dist/spaces-4qMOAYE9.mjs.map +0 -1
@@ -1,20 +1,21 @@
1
- import { r as getEmittedArtifactPaths, t as emit } from "./exports-BCLg4CiV-05kuwcb0.mjs";
2
- import { O as errorNoInvariantPath, P as errorUnknownInvariant, b as errorInvalidRefName, i as errorContractDeserializationFailed, t as MigrationToolsError } from "./errors-CXbGUWGu-CstQHPh6.mjs";
3
- import { a as snapshotsImportPathFrom, o as writeContractSnapshot, r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs";
1
+ import { r as getEmittedArtifactPaths, t as emit } from "./exports-CE6OD63o-4Qpqr2W7.mjs";
2
+ import { O as errorNoInvariantPath, P as errorUnknownInvariant, b as errorInvalidRefName, i as errorContractDeserializationFailed, t as MigrationToolsError } from "./errors-SoLLYLtw-DMxVbVs9.mjs";
3
+ import { a as snapshotsImportPathFrom, o as writeContractSnapshot, r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-qGrwlGmt-Cf2NFzRL.mjs";
4
4
  import { n as verifyMigrationHash, t as computeMigrationHash } from "./hash-DH8hl5Rq-BpM2t3Nu.mjs";
5
- import { t as deriveProvidedInvariants } from "./invariants-CTHy88OP-CYI2a8IO.mjs";
6
- import { i as materialiseExtensionMigrationPackageIfMissing, r as formatMigrationDirName, u as writeMigrationPackage } from "./io-635GlNx1-D3zrw2qu.mjs";
5
+ import { t as deriveProvidedInvariants } from "./invariants-Cww4bv0v-BEiFxmbX.mjs";
6
+ import { i as materialiseExtensionMigrationPackageIfMissing, r as formatMigrationDirName, u as writeMigrationPackage } from "./io-BmWQNxRP-DQqbcPsS.mjs";
7
7
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
8
- import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-BViWUMpP-C4lYYJdU.mjs";
9
- import { a as findPath, o as findPathWithDecision, r as findLatestMigration } from "./migration-graph-_SJImD5V-BURyY1KM.mjs";
10
- import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, o as refsByContractHash, t as HEAD_REF_NAME, u as validateRefValue } from "./refs-WK86uYYp-gM8tvWQP.mjs";
11
- import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID$1 } from "./verify-contract-spaces-DhJTb0zM-B62maCfE.mjs";
12
- import { d as resolveRecordedPath, f as verifyMigration, l as planMigration, n as buildFabricatedMigrationEdge, r as collectAggregateNamespaces, s as loadContractSpaceAggregate, t as allStorageElementsExternal, u as requireHeadRef } from "./aggregate-CPZB020V.mjs";
13
- import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-4qMOAYE9.mjs";
14
- import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver } from "./import-roots-CNFBPAT1.mjs";
15
- import { n as parseContractRef, r as parseMigrationRef } from "./ref-resolution-HeNBXW53.mjs";
8
+ import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-DY1Onbc3-CwBd6wuB.mjs";
9
+ import { a as findPath, o as findPathWithDecision, r as findLatestMigration } from "./migration-graph-CW4bMmTz-B5xFtFVB.mjs";
10
+ import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, o as refsByContractHash, t as HEAD_REF_NAME, u as validateRefValue } from "./refs-BpSpzdYB-BcDelHGt.mjs";
11
+ import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID$1 } from "./verify-contract-spaces-CrxvgpwD-D5LLXGci.mjs";
12
+ import { d as resolveRecordedPath, f as verifyMigration, l as planMigration, n as buildFabricatedMigrationEdge, r as collectAggregateNamespaces, s as loadContractSpaceAggregate, t as allStorageElementsExternal, u as requireHeadRef } from "./aggregate-B4HKshLQ.mjs";
13
+ import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-BCZiAZQn.mjs";
14
+ import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver } from "./import-roots-BHOrDJbI.mjs";
15
+ import { n as parseContractRef, r as parseMigrationRef } from "./ref-resolution-BWpwb8_b.mjs";
16
16
  import { i as writeMigrationTs } from "./migration-ts-DdVm0rws.mjs";
17
17
  import { createRequire } from "node:module";
18
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
18
19
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
19
20
  import { structuredError } from "@prisma/orm-framework/utils/structured-error";
20
21
  import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
@@ -30,8 +31,8 @@ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
30
31
  import { createHash } from "node:crypto";
31
32
  import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
32
33
  import { abortable } from "@prisma/orm-framework/utils/abortable";
33
- import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
34
- //#region ../../../1-framework/3-tooling/cli/dist/ref-h6InR6dO.mjs
34
+ import { resolve as resolve$1 } from "node:path";
35
+ //#region ../../../1-framework/3-tooling/cli/dist/ref-DcqFmceq.mjs
35
36
  /**
36
37
  * The typed remediation the CLI attaches to its own errors and findings.
37
38
  * Constructors live here rather than in any library the CLI calls: naming a
@@ -85,10 +86,24 @@ function errorContractArgConflict(options) {
85
86
  }
86
87
  });
87
88
  }
89
+ /**
90
+ * A command was told both which ref to advance and not to advance any ref.
91
+ * Same envelope as the positional/flag contract conflict, so a script sees
92
+ * every invocation conflict in one shape.
93
+ */
94
+ function errorAdvanceRefArgConflict(options) {
95
+ const fix = "Pass either --advance-ref <name> or --no-advance-ref, not both.";
96
+ return new ActionableCliError("CLI.ADVANCE_REF_ARG_CONFLICT", "Cannot specify both --advance-ref and --no-advance-ref", {
97
+ why: `--advance-ref names "${options.advanceRef}" while --no-advance-ref asks for no ref to be written; there is no rule for which wins.`,
98
+ fix,
99
+ nextActions: [chooseAction(fix)],
100
+ meta: { advanceRef: options.advanceRef }
101
+ });
102
+ }
88
103
  function errorRefSetHashNotInGraph(resolvedHash, reachableHashes, graphTipHash) {
89
104
  const reachableList = reachableHashes.length > 0 ? reachableHashes.join(", ") : "(none — migration graph is empty)";
90
- const fix = reachableHashes.length > 0 ? graphTipHash !== null ? `Set the ref to a graph-node hash such as ${graphTipHash}, or run \`prisma-cli migration plan\` to extend the graph.` : "Set the ref to a hash that appears in the migration graph." : "Run `prisma-cli migration plan` first.";
91
- const nextActions = reachableHashes.length > 0 ? graphTipHash !== null ? [chooseAction(`Set the ref to a graph-node hash such as ${graphTipHash}`), runCommandAction("Extend the migration graph", "prisma-cli migration plan")] : [chooseAction("Set the ref to a hash that appears in the migration graph")] : [runCommandAction("Plan the first migration", "prisma-cli migration plan")];
105
+ const fix = reachableHashes.length > 0 ? graphTipHash !== null ? `Set the ref to a graph-node hash such as ${graphTipHash}, or run \`{bin} migration plan\` to extend the graph.` : "Set the ref to a hash that appears in the migration graph." : "Run `{bin} migration plan` first.";
106
+ const nextActions = reachableHashes.length > 0 ? graphTipHash !== null ? [chooseAction(`Set the ref to a graph-node hash such as ${graphTipHash}`), runCommandAction("Extend the migration graph", "{bin} migration plan")] : [chooseAction("Set the ref to a hash that appears in the migration graph")] : [runCommandAction("Plan the first migration", "{bin} migration plan")];
92
107
  return new ActionableCliError("MIGRATION.HASH_NOT_IN_GRAPH", `Resolved contract hash is not in the migration graph: ${resolvedHash}`, {
93
108
  why: reachableHashes.length > 0 ? `The migration graph reaches ${reachableList}; resolved ${resolvedHash} isn't a graph node.` : "The migration graph is empty — no hashes reachable.",
94
109
  fix,
@@ -130,7 +145,7 @@ function errorInvalidSpaceId(spaceId) {
130
145
  return new ActionableCliError("MIGRATION.INVALID_SPACE_ID", `Invalid contract space id: ${spaceId}`, {
131
146
  why: "Contract space ids must match [a-z][a-z0-9_-]{0,63} (lowercase, starts with a letter, max 64 characters — the rule applied to every on-disk space directory).",
132
147
  fix: "Pass a space id that matches the directory naming rule, or omit --space to list every space.",
133
- nextActions: [chooseAction("Pass a space id matching [a-z][a-z0-9_-]{0,63}"), runCommandAction("Or list every space", "prisma-cli migration list")],
148
+ nextActions: [chooseAction("Pass a space id matching [a-z][a-z0-9_-]{0,63}"), runCommandAction("Or list every space", "{bin} migration list")],
134
149
  meta: { spaceId }
135
150
  });
136
151
  }
@@ -147,8 +162,8 @@ function errorInvalidSpaceId(spaceId) {
147
162
  */
148
163
  function errorSpaceNotFound(spaceId, availableSpaces) {
149
164
  const availableList = availableSpaces.length > 0 ? availableSpaces.join(", ") : "(none — no contract spaces on disk yet)";
150
- const fix = availableSpaces.length > 0 ? `Pick one of: ${availableList}. Run \`prisma-cli migration list\` (no --space) to see every space's migrations.` : "Author a migration with `prisma-cli migration new` to create the first contract-space directory.";
151
- const nextActions = availableSpaces.length > 0 ? [chooseAction(`Pick one of: ${availableList}`), runCommandAction("See every space's migrations", "prisma-cli migration list")] : [runCommandAction("Author the first migration, which creates the contract-space directory", "prisma-cli migration new")];
165
+ const fix = availableSpaces.length > 0 ? `Pick one of: ${availableList}. Run \`{bin} migration list\` (no --space) to see every space's migrations.` : "Author a migration with `{bin} migration new` to create the first contract-space directory.";
166
+ const nextActions = availableSpaces.length > 0 ? [chooseAction(`Pick one of: ${availableList}`), runCommandAction("See every space's migrations", "{bin} migration list")] : [runCommandAction("Author the first migration, which creates the contract-space directory", "{bin} migration new")];
152
167
  return new ActionableCliError("MIGRATION.SPACE_NOT_FOUND", `Unknown contract space: ${spaceId}`, {
153
168
  why: `No directory named "${spaceId}" exists under the migrations root.`,
154
169
  fix,
@@ -167,15 +182,15 @@ function errorMigrationPackageNotFound(why) {
167
182
  return new ActionableCliError("MIGRATION.PACKAGE_NOT_FOUND", "Migration package not found", {
168
183
  why,
169
184
  fix: "Pass a directory name, hash prefix, or path to an on-disk app-space migration package.",
170
- nextActions: [chooseAction("Pass a directory name, hash prefix, or path to an on-disk app-space migration package"), runCommandAction("List what is on disk", "prisma-cli migration list")]
185
+ nextActions: [chooseAction("Pass a directory name, hash prefix, or path to an on-disk app-space migration package"), runCommandAction("List what is on disk", "{bin} migration list")]
171
186
  });
172
187
  }
173
188
  /** The app space has no migration packages at all, so no target can resolve. */
174
189
  function errorNoMigrations(appMigrationsRelative) {
175
190
  return new ActionableCliError("MIGRATION.NO_MIGRATIONS", "No migrations found", {
176
191
  why: `No migration packages found in ${appMigrationsRelative}`,
177
- fix: "Run `prisma-cli migration plan` to create a migration first.",
178
- nextActions: [runCommandAction("Create the first migration", "prisma-cli migration plan")]
192
+ fix: "Run `{bin} migration plan` to create a migration first.",
193
+ nextActions: [runCommandAction("Create the first migration", "{bin} migration plan")]
179
194
  });
180
195
  }
181
196
  function errorRefSetBundleNotFound(hash) {
@@ -189,7 +204,7 @@ function errorRefSetBundleNotFound(hash) {
189
204
  function errorPlanForgotTheFlag(resolvedHash, reachableRefs, graphTipHash, options) {
190
205
  const reachableList = reachableRefs.length > 0 ? reachableRefs.map((r) => `${r.name} (${r.hash})`).join(", ") : "(none)";
191
206
  const refFix = reachableRefs.length > 0 ? `Run migration plan with ${reachableRefs.map((r) => `--from ${r.name}`).join(" or ")}.` : graphTipHash !== null ? `Run migration plan --from ${graphTipHash}.` : "Commit pending migrations first, then run migration plan.";
192
- const nextActions = reachableRefs.length > 0 ? reachableRefs.map((ref) => runCommandAction(`Plan from ${ref.name}`, `prisma-cli migration plan --from ${ref.name}`)) : graphTipHash !== null ? [runCommandAction("Plan from the graph tip", `prisma-cli migration plan --from ${graphTipHash}`)] : [chooseAction("Commit pending migrations first, then run migration plan")];
207
+ const nextActions = reachableRefs.length > 0 ? reachableRefs.map((ref) => runCommandAction(`Plan from ${ref.name}`, `{bin} migration plan --from ${ref.name}`)) : graphTipHash !== null ? [runCommandAction("Plan from the graph tip", `{bin} migration plan --from ${graphTipHash}`)] : [chooseAction("Commit pending migrations first, then run migration plan")];
193
208
  return new ActionableCliError("MIGRATION.HASH_NOT_IN_GRAPH", `Resolved from-hash is not in the migration graph: ${resolvedHash}`, {
194
209
  why: `The migration graph reaches ${reachableList}; resolved ${resolvedHash} isn't a graph node.`,
195
210
  fix: refFix,
@@ -212,12 +227,12 @@ function errorPlanForgotTheFlag(resolvedHash, reachableRefs, graphTipHash, optio
212
227
  */
213
228
  function errorSnapshotMissing(identifier, options) {
214
229
  const viaRef = options?.viaRef !== false;
215
- const fix = viaRef ? `Create the ref with "prisma-cli ref set ${identifier} <hash>" (or advance it via "prisma-cli db update --advance-ref ${identifier}"), or pass a hash that is a node in the migration graph.` : `No contract source exists for hash "${identifier}" on an empty migration graph. Use --from with a ref name (its contract resolves through the snapshot store), or run db update first.`;
230
+ const fix = viaRef ? `Create the ref with "{bin} migration ref set ${identifier} <hash>" (or advance it via "{bin} db update --advance-ref ${identifier}"), or pass a hash that is a node in the migration graph.` : `No contract source exists for hash "${identifier}" on an empty migration graph. Use --from with a ref name (its contract resolves through the snapshot store), or run db update first.`;
216
231
  const nextActions = viaRef ? [
217
- runCommandAction(`Create the ref "${identifier}"`, `prisma-cli ref set ${identifier} <hash>`),
218
- runCommandAction("Or advance it from the database", `prisma-cli db update --advance-ref ${identifier}`),
232
+ runCommandAction(`Create the ref "${identifier}"`, `{bin} migration ref set ${identifier} <hash>`),
233
+ runCommandAction("Or advance it from the database", `{bin} db update --advance-ref ${identifier}`),
219
234
  chooseAction("Or pass a hash that is a node in the migration graph")
220
- ] : [chooseAction("Pass --from a ref name, whose contract resolves through the snapshot store"), runCommandAction("Or populate the graph first", "prisma-cli db update")];
235
+ ] : [chooseAction("Pass --from a ref name, whose contract resolves through the snapshot store"), runCommandAction("Or populate the graph first", "{bin} db update")];
221
236
  return new ActionableCliError("MIGRATION.SNAPSHOT_MISSING", viaRef ? `Ref "${identifier}" is not resolvable` : `No contract source for from-hash "${identifier}"`, {
222
237
  why: viaRef ? `Ref "${identifier}" has no pointer file, and the hash being resolved is not a node in the migration graph either.` : `Hash "${identifier}" is not a node in the migration graph (the graph is empty), and it does not name a ref either.`,
223
238
  fix,
@@ -229,20 +244,47 @@ function errorSnapshotMissing(identifier, options) {
229
244
  ...ifDefined("cause", options?.cause)
230
245
  });
231
246
  }
247
+ /**
248
+ * Default origin resolution for `migration plan` found nothing (no `--from`,
249
+ * no `db` ref) while migrations already exist on disk. Planning would silently
250
+ * produce an empty-origin migration that ignores the existing history — almost
251
+ * always a mistake — so the command refuses and names the three exits.
252
+ */
253
+ function errorPlanOriginUnknown(reachableRefs, graphTipHash) {
254
+ const fromSuggestion = reachableRefs.length > 0 ? reachableRefs.map((r) => `--from ${r.name}`).join(" or ") : graphTipHash !== null ? `--from ${graphTipHash}` : "--from <contract>";
255
+ const refSetCommand = graphTipHash !== null ? `{bin} migration ref set db ${graphTipHash}` : "{bin} migration ref set db <contract>";
256
+ return new ActionableCliError("MIGRATION.PLAN_ORIGIN_UNKNOWN", "Cannot determine the plan origin: migrations exist but no origin is named", {
257
+ why: "Migrations exist on disk, but there is no `db` ref and no --from was given, so the plan origin would silently fall back to an empty database and the resulting migration would recreate everything the existing migrations already create.",
258
+ fix: [
259
+ `Set the \`db\` ref to the contract your dev database is at (\`${refSetCommand}\`), or advance it via \`{bin} db update\`.`,
260
+ `Or pass the origin explicitly: \`{bin} migration plan ${fromSuggestion}\`.`,
261
+ "Or pass --from @empty to deliberately plan from an empty database."
262
+ ].join("\n"),
263
+ nextActions: [
264
+ runCommandAction("Point the db ref at the origin contract", refSetCommand),
265
+ ...reachableRefs.length > 0 ? reachableRefs.map((ref) => runCommandAction(`Plan from ${ref.name}`, `{bin} migration plan --from ${ref.name}`)) : [runCommandAction("Plan from an explicit origin", `{bin} migration plan ${fromSuggestion}`)],
266
+ runCommandAction("Plan from an empty database deliberately", "{bin} migration plan --from @empty")
267
+ ],
268
+ meta: {
269
+ reachableRefs: reachableRefs.map((r) => r.name),
270
+ ...graphTipHash !== null ? { graphTipHash } : {}
271
+ }
272
+ });
273
+ }
232
274
  function errorMarkerMismatch(markerHash, reachableHashes, graphTip) {
233
275
  const reachableList = reachableHashes.length > 0 ? reachableHashes.join(", ") : "(none — migration graph is empty)";
234
- const planFromFix = graphTip !== null ? `Run \`prisma-cli migration plan --from ${graphTip}\` if the live marker is canonical and the on-disk graph needs catching up.` : "Run `prisma-cli migration plan` if the live marker is canonical and the on-disk graph needs catching up.";
235
- const planCommand = graphTip !== null ? `prisma-cli migration plan --from ${graphTip}` : "prisma-cli migration plan";
276
+ const planFromFix = graphTip !== null ? `Run \`{bin} migration plan --from ${graphTip}\` if the live marker is canonical and the on-disk graph needs catching up.` : "Run `{bin} migration plan` if the live marker is canonical and the on-disk graph needs catching up.";
277
+ const planCommand = graphTip !== null ? `{bin} migration plan --from ${graphTip}` : "{bin} migration plan";
236
278
  return new ActionableCliError("MIGRATION.MARKER_MISMATCH", "Database marker is not reachable in the on-disk migration graph", {
237
279
  why: `DB marker is ${markerHash}, but the on-disk migration graph reaches: ${reachableList}.`,
238
280
  fix: [
239
281
  planFromFix,
240
- `Run \`prisma-cli ref set db ${markerHash}\` if the on-disk graph is canonical and the local \`db\` ref drifted.`,
282
+ `Run \`{bin} migration ref set db ${markerHash}\` if the on-disk graph is canonical and the local \`db\` ref drifted.`,
241
283
  "Investigate whether the database was migrated by an out-of-band process."
242
284
  ].join("\n"),
243
285
  nextActions: [
244
286
  runCommandAction("Catch the on-disk graph up to the live marker", planCommand),
245
- runCommandAction("Point the local db ref at the live marker", `prisma-cli ref set db ${markerHash}`),
287
+ runCommandAction("Point the local db ref at the live marker", `{bin} migration ref set db ${markerHash}`),
246
288
  chooseAction("Investigate whether the database was migrated by an out-of-band process")
247
289
  ],
248
290
  meta: {
@@ -263,13 +305,13 @@ function errorPathUnreachable(failure) {
263
305
  const deadEndsSuffix = Array.isArray(deadEnds) && deadEnds.length > 0 ? ` Dead-ends: ${deadEnds.map(String).join(", ")}.` : "";
264
306
  const neverPlanned = meta["kind"] === "neverPlanned";
265
307
  const planCommand = (() => {
266
- if (neverPlanned) return "prisma-cli migration plan --name <slug>";
267
- if (planFromHash !== null && targetHash !== null) return `prisma-cli migration plan --from ${planFromHash} --to ${targetHash} --name <slug>`;
268
- if (targetHash !== null) return `prisma-cli migration plan --to ${targetHash} --name <slug>`;
269
- if (planFromHash !== null) return `prisma-cli migration plan --from ${planFromHash} --name <slug>`;
270
- return "prisma-cli migration plan";
308
+ if (neverPlanned) return "{bin} migration plan --name <slug>";
309
+ if (planFromHash !== null && targetHash !== null) return `{bin} migration plan --from ${planFromHash} --to ${targetHash} --name <slug>`;
310
+ if (targetHash !== null) return `{bin} migration plan --to ${targetHash} --name <slug>`;
311
+ if (planFromHash !== null) return `{bin} migration plan --from ${planFromHash} --name <slug>`;
312
+ return "{bin} migration plan";
271
313
  })();
272
- const applyCommand = targetHash !== null && !neverPlanned ? `prisma-cli migrate --to ${targetHash}` : "prisma-cli migrate";
314
+ const applyCommand = targetHash !== null && !neverPlanned ? `{bin} db migrate --to ${targetHash}` : "{bin} db migrate";
273
315
  return new ActionableCliError("MIGRATION.PATH_UNREACHABLE", failure.summary, {
274
316
  why: failure.why ?? `Cannot reach target "${targetHash ?? "<unknown>"}" from current marker "${fromHashMeta ?? "<unknown>"}".${deadEndsSuffix}`,
275
317
  fix: [
@@ -278,15 +320,15 @@ function errorPathUnreachable(failure) {
278
320
  ` 2. ${applyCommand}`,
279
321
  `${ROLLBACK_IS_DESTRUCTIVE}.`,
280
322
  `${NARROWER_CASES_NEED_A_HINT}.`,
281
- "Inspect the on-disk graph with `prisma-cli migration list`, or `prisma-cli migration show <bundle>` for any bundle in the path you expected."
323
+ "Inspect the on-disk graph with `{bin} migration list`, or `{bin} migration show <bundle>` for any bundle in the path you expected."
282
324
  ].join("\n"),
283
325
  nextActions: [
284
326
  runCommandAction("Plan the missing edge", planCommand),
285
327
  runCommandAction("Apply it", applyCommand),
286
328
  chooseAction(ROLLBACK_IS_DESTRUCTIVE),
287
329
  chooseAction(NARROWER_CASES_NEED_A_HINT),
288
- runCommandAction("Inspect the on-disk graph", "prisma-cli migration list"),
289
- runCommandAction("Inspect a bundle in the path you expected", "prisma-cli migration show <bundle>")
330
+ runCommandAction("Inspect the on-disk graph", "{bin} migration list"),
331
+ runCommandAction("Inspect a bundle in the path you expected", "{bin} migration show <bundle>")
290
332
  ],
291
333
  meta: { ...meta }
292
334
  });
@@ -565,7 +607,7 @@ async function readContractEnvelope(config) {
565
607
  const json = JSON.parse(content);
566
608
  const { schemaVersion, target, targetFamily, profileHash } = json;
567
609
  const storageHash = json["storage"]?.["storageHash"];
568
- if (typeof storageHash !== "string") throw new CliStructuredError$1("CONTRACT.VALIDATION_FAILED", `Contract at ${relative(process.cwd(), contractPath)} is missing a valid storage.storageHash. Run \`prisma-cli contract emit\` to regenerate.`, { where: { path: contractPath } });
610
+ if (typeof storageHash !== "string") throw new CliStructuredError$1("CONTRACT.VALIDATION_FAILED", `Contract at ${relative(process.cwd(), contractPath)} is missing a valid storage.storageHash. Run \`{bin} contract emit\` to regenerate.`, { where: { path: contractPath } });
569
611
  if (typeof schemaVersion !== "string") throw new CliStructuredError$1("CONTRACT.VALIDATION_FAILED", `Contract at ${relative(process.cwd(), contractPath)} is missing schemaVersion.`, { where: { path: contractPath } });
570
612
  if (typeof target !== "string") throw new CliStructuredError$1("CONTRACT.VALIDATION_FAILED", `Contract at ${relative(process.cwd(), contractPath)} is missing target.`, { where: { path: contractPath } });
571
613
  if (typeof targetFamily !== "string") throw new CliStructuredError$1("CONTRACT.VALIDATION_FAILED", `Contract at ${relative(process.cwd(), contractPath)} is missing targetFamily.`, { where: { path: contractPath } });
@@ -729,14 +771,14 @@ function describeIntegrityViolation(violation) {
729
771
  * target mismatch, then disjointness, then a contract-validation
730
772
  * failure, then any remaining structural integrity violation.
731
773
  */
732
- function mapIntegrityViolations(violations) {
774
+ function mapIntegrityViolations(violations, migrationsDir) {
733
775
  if (violations.length === 0) return null;
734
776
  const layout = violations.filter((v) => v.kind === "orphanSpaceDir" || v.kind === "declaredButUnmigrated");
735
777
  if (layout.length > 0) {
736
778
  const lines = layout.map((v) => `- [${v.kind}] ${v.spaceId}`);
737
779
  return new CliStructuredError$1("MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION", layout.length === 1 ? "Contract-space layout violation detected" : `Contract-space layout violations detected (${layout.length})`, {
738
- why: `The on-disk \`migrations/\` directory and your \`extensions\` declaration are not in agreement.\n${lines.join("\n")}`,
739
- fix: "Declare the extension in `extensions` and re-emit its contract-space artefacts, or remove the orphan `migrations/<space>` directory.",
780
+ why: `The on-disk \`${migrationsDir}/\` directory and your \`extensions\` declaration are not in agreement.\n${lines.join("\n")}`,
781
+ fix: `Declare the extension in \`extensions\` and re-emit its contract-space artefacts, or remove the orphan \`${migrationsDir}/<space>\` directory.`,
740
782
  docsUrl: CONTRACT_SPACES_DOCS_URL,
741
783
  meta: { violations: layout }
742
784
  });
@@ -752,13 +794,13 @@ function mapIntegrityViolations(violations) {
752
794
  const contractUnreadable = violations.find((v) => v.kind === "contractUnreadable");
753
795
  if (contractUnreadable && contractUnreadable.kind === "contractUnreadable") return contractSpaceViolationError(`Contract-space contract validation failed for "${contractUnreadable.spaceId}"`, {
754
796
  why: contractUnreadable.detail,
755
- fix: "Re-emit the extension contract with `prisma-cli contract emit`, or fix the extension pack descriptor producing the invalid contract.",
797
+ fix: "Re-emit the extension contract with `{bin} contract emit`, or fix the extension pack descriptor producing the invalid contract.",
756
798
  violations: [contractUnreadable]
757
799
  });
758
800
  const structural = violations[0];
759
801
  return contractSpaceViolationError(`Contract-space integrity failure for "${"spaceId" in structural ? structural.spaceId : "*"}"`, {
760
802
  why: describeIntegrityViolation(structural),
761
- fix: "Re-emit the affected migration package(s) or restore the on-disk `migrations/` directory from version control.",
803
+ fix: `Re-emit the affected migration package(s) or restore the on-disk \`${migrationsDir}\` directory from version control.`,
762
804
  violations: [structural]
763
805
  });
764
806
  }
@@ -793,8 +835,8 @@ async function loadContractSpaceAggregateForCli(inputs) {
793
835
  * the contract-space refusal envelope, or return `null` when the model
794
836
  * is acceptable for the requested check scope.
795
837
  */
796
- function refuseContractSpaceIntegrity(aggregate, options) {
797
- return mapIntegrityViolations(aggregate.checkIntegrity(options));
838
+ function refuseContractSpaceIntegrity(aggregate, options, migrationsDir) {
839
+ return mapIntegrityViolations(aggregate.checkIntegrity(options), migrationsDir);
798
840
  }
799
841
  const PACKAGE_CORRUPTION_KINDS = /* @__PURE__ */ new Set([
800
842
  "hashMismatch",
@@ -806,8 +848,8 @@ const PACKAGE_CORRUPTION_KINDS = /* @__PURE__ */ new Set([
806
848
  * corruptions only (`hashMismatch`, `providedInvariantsMismatch`,
807
849
  * `packageUnloadable`).
808
850
  */
809
- function refusePackageCorruptionOnAggregate(aggregate) {
810
- return mapIntegrityViolations(aggregate.checkIntegrity().filter((v) => PACKAGE_CORRUPTION_KINDS.has(v.kind)));
851
+ function refusePackageCorruptionOnAggregate(aggregate, migrationsDir) {
852
+ return mapIntegrityViolations(aggregate.checkIntegrity().filter((v) => PACKAGE_CORRUPTION_KINDS.has(v.kind)), migrationsDir);
811
853
  }
812
854
  /**
813
855
  * Construct the tolerant {@link ContractSpaceAggregate} at the CLI
@@ -823,7 +865,7 @@ async function buildContractSpaceAggregate(inputs) {
823
865
  const failure = refuseContractSpaceIntegrity(loaded.value, {
824
866
  declaredExtensions,
825
867
  checkContracts: true
826
- });
868
+ }, inputs.migrationsDir);
827
869
  if (failure) return notOk(failure);
828
870
  return ok(loaded.value);
829
871
  }
@@ -1490,7 +1532,8 @@ async function executeDbVerify(options) {
1490
1532
  }),
1491
1533
  aggregate,
1492
1534
  skipMarker,
1493
- onProgress
1535
+ onProgress,
1536
+ migrationsDir: options.migrationsDir
1494
1537
  });
1495
1538
  }
1496
1539
  function buildLoadInputs(options) {
@@ -1573,7 +1616,7 @@ function emitVerifySpan(onProgress, kind) {
1573
1616
  * by the CLI's `--schema-only` mode.
1574
1617
  */
1575
1618
  function finaliseVerifyResult(args) {
1576
- const { verifyResult, aggregate, skipMarker, onProgress } = args;
1619
+ const { verifyResult, aggregate, skipMarker, onProgress, migrationsDir } = args;
1577
1620
  if (!verifyResult.ok) {
1578
1621
  emitVerifySpan(onProgress, "spanEndError");
1579
1622
  return notOk(new CliStructuredError$1("MIGRATION.CONTRACT_SPACE_VIOLATION", "Aggregate verifier introspection failed", {
@@ -1582,7 +1625,7 @@ function finaliseVerifyResult(args) {
1582
1625
  docsUrl: "https://pris.ly/contract-spaces"
1583
1626
  }));
1584
1627
  }
1585
- const markerDrift = skipMarker ? null : mapMarkerCheckFailures(aggregate.app.spaceId, verifyResult.value.markerCheck);
1628
+ const markerDrift = skipMarker ? null : mapMarkerCheckFailures(aggregate.app.spaceId, verifyResult.value.markerCheck, migrationsDir);
1586
1629
  emitVerifySpan(onProgress, markerDrift === null ? "spanEndOk" : "spanEndError");
1587
1630
  return ok({
1588
1631
  schemaResults: verifyResult.value.schemaCheck.perSpace,
@@ -1614,7 +1657,7 @@ function buildSkippedSchemaResult(space) {
1614
1657
  * `MIGRATION.CONTRACT_SPACE_VIOLATION` (was emitted by
1615
1658
  * `runContractSpaceVerifierMarkerCheck`).
1616
1659
  */
1617
- function mapMarkerCheckFailures(appSpaceId, section) {
1660
+ function mapMarkerCheckFailures(appSpaceId, section, migrationsDir) {
1618
1661
  const violations = [];
1619
1662
  for (const [spaceId, result] of section.perSpace) {
1620
1663
  if (result.kind === "ok" || result.kind === "absent") continue;
@@ -1622,14 +1665,14 @@ function mapMarkerCheckFailures(appSpaceId, section) {
1622
1665
  violations.push({
1623
1666
  kind: "hashMismatch",
1624
1667
  spaceId,
1625
- remediation: spaceId === appSpaceId ? "Run `prisma-cli db update` to advance the marker, or roll the database back to the recorded hash." : `Apply on-disk migrations under \`migrations/${spaceId}/\` to advance the marker, or remove the conflicting marker row.`
1668
+ remediation: spaceId === appSpaceId ? "Run `{bin} db update` to advance the marker, or roll the database back to the recorded hash." : `Apply on-disk migrations under \`${migrationsDir}/${spaceId}/\` to advance the marker, or remove the conflicting marker row.`
1626
1669
  });
1627
1670
  continue;
1628
1671
  }
1629
1672
  if (result.kind === "missingInvariants") violations.push({
1630
1673
  kind: "invariantsMismatch",
1631
1674
  spaceId,
1632
- remediation: `Re-apply the migrations under \`migrations/${spaceId}/\` so the marker carries invariants: ${result.missing.join(", ")}.`
1675
+ remediation: `Re-apply the migrations under \`${migrationsDir}/${spaceId}/\` so the marker carries invariants: ${result.missing.join(", ")}.`
1633
1676
  });
1634
1677
  }
1635
1678
  for (const orphan of section.orphanMarkers) violations.push({
@@ -1640,7 +1683,7 @@ function mapMarkerCheckFailures(appSpaceId, section) {
1640
1683
  if (violations.length === 0) return null;
1641
1684
  const lines = violations.map((v) => `- [${v.kind}] ${v.spaceId}: ${v.remediation}`);
1642
1685
  return new CliStructuredError$1("MIGRATION.CONTRACT_SPACE_VIOLATION", violations.length === 1 ? "Contract-space verifier found a violation" : `Contract-space verifier found violations (${violations.length})`, {
1643
- why: `The on-disk \`migrations/\` directory, the \`extensions\` declaration, and the live database marker rows are not in agreement.\n${lines.join("\n")}`,
1686
+ why: `The on-disk \`${migrationsDir}/\` directory, the \`extensions\` declaration, and the live database marker rows are not in agreement.\n${lines.join("\n")}`,
1644
1687
  fix: violations[0]?.remediation ?? "Review and reconcile the violations listed above.",
1645
1688
  docsUrl: "https://pris.ly/contract-spaces",
1646
1689
  meta: { violations }
@@ -1702,7 +1745,7 @@ async function executeMigrate(options) {
1702
1745
  atHeadResolutions.set(space.spaceId, outcome.plan);
1703
1746
  continue;
1704
1747
  }
1705
- if (outcome.kind === "never-planned") return notOk(buildNeverPlannedFailure(outcome.spaceId, outcome.targetHash));
1748
+ if (outcome.kind === "never-planned") return notOk(buildNeverPlannedFailure(outcome.spaceId, outcome.targetHash, migrationsDir));
1706
1749
  if (outcome.kind === "unreachable") return notOk(buildPathNotFoundFailure(outcome.spaceId, outcome.liveMarker, outcome.targetHash));
1707
1750
  if (outcome.kind === "unsatisfiable") {
1708
1751
  const structural = findPathWithDecision(outcome.targetSpace.graph(), outcome.liveHash, spaceTargetHash, { required: /* @__PURE__ */ new Set() });
@@ -1974,11 +2017,11 @@ function buildSuccess(args) {
1974
2017
  *
1975
2018
  * @internal Exported for testing only.
1976
2019
  */
1977
- function buildNeverPlannedFailure(spaceId, targetHash) {
2020
+ function buildNeverPlannedFailure(spaceId, targetHash, migrationsDir) {
1978
2021
  return {
1979
2022
  code: "MIGRATION_PATH_NOT_FOUND",
1980
2023
  summary: `No on-disk migrations for contract space "${spaceId}"`,
1981
- why: `migrate is replay-only: a contract space that declares managed storage elements must have an authored migration graph on disk. Space "${spaceId}" has no migrations under \`migrations/${spaceId}/\` but its head ref targets "${targetHash}".`,
2024
+ why: `migrate is replay-only: a contract space that declares managed storage elements must have an authored migration graph on disk. Space "${spaceId}" has no migrations under \`${migrationsDir}/${spaceId}/\` but its head ref targets "${targetHash}".`,
1982
2025
  meta: {
1983
2026
  spaceId,
1984
2027
  target: targetHash,
@@ -2011,7 +2054,7 @@ function buildPathNotFoundFailure(spaceId, marker, targetHash) {
2011
2054
  };
2012
2055
  }
2013
2056
  /**
2014
- * Creates a programmatic control client for Prisma Next operations.
2057
+ * Creates a programmatic control client for Prisma ORM operations.
2015
2058
  *
2016
2059
  * The client accepts framework component descriptors at creation time,
2017
2060
  * manages driver lifecycle via connect()/close(), and exposes domain
@@ -2499,7 +2542,10 @@ var ControlClientImpl = class {
2499
2542
  meta: void 0
2500
2543
  });
2501
2544
  }
2502
- const result = await emit(deserializedContract, this.stack, this.options.family.emission, { serializeContract: (contract) => this.options.target.contractSerializer.serializeContract(contract) });
2545
+ const result = await emit(deserializedContract, this.stack, this.options.family.emission, {
2546
+ serializeContract: (contract) => this.options.target.contractSerializer.serializeContract(contract),
2547
+ ...ifDefined("supportsNamespaces", this.options.target.supportsNamespaces)
2548
+ });
2503
2549
  onProgress?.({
2504
2550
  action: "emit",
2505
2551
  kind: "spanEnd",
@@ -2727,7 +2773,7 @@ function extractPackageSpecifiers(dtsContent) {
2727
2773
  }
2728
2774
  function validateContractDeps(dtsContent, projectRoot) {
2729
2775
  const packages = extractPackageSpecifiers(dtsContent);
2730
- const resolve = createRequire(`${projectRoot}/package.json`);
2776
+ const resolve = createRequire(resolve$1(projectRoot, "package.json"));
2731
2777
  const missing = [];
2732
2778
  for (const pkg of packages) try {
2733
2779
  resolve.resolve(`${pkg}/package.json`);
@@ -2831,7 +2877,7 @@ function validateProviderResult(providerResult) {
2831
2877
  * Canonical contract emit operation.
2832
2878
  *
2833
2879
  * This is the SINGLE publication path used by both the CLI command
2834
- * (`prisma-next contract emit`) and the Vite plugin
2880
+ * (`prisma contract emit`) and the Vite plugin
2835
2881
  * (`@internal/vite-plugin-contract-emit`). New callers must go through this
2836
2882
  * function rather than re-implementing load → emit → publish.
2837
2883
  *
@@ -2908,7 +2954,8 @@ async function executeContractEmit(options, dependencies = defaultContractEmitDe
2908
2954
  serializeContract,
2909
2955
  resolveImportSpecifier: createProjectSpecifierResolver(configPath ?? outputJsonPath),
2910
2956
  ...ifDefined("shouldPreserveEmpty", contractSerializer.shouldPreserveEmpty),
2911
- ...ifDefined("sortStorage", contractSerializer.sortStorage)
2957
+ ...ifDefined("sortStorage", contractSerializer.sortStorage),
2958
+ ...ifDefined("supportsNamespaces", config.target.supportsNamespaces)
2912
2959
  }));
2913
2960
  } catch (error) {
2914
2961
  endSpan(onProgress, "emit", "error");
@@ -2941,12 +2988,43 @@ function computeRefAdvancementName(options) {
2941
2988
  if (options.db === void 0) return "db";
2942
2989
  return null;
2943
2990
  }
2991
+ function contractDtsPathOf(contractJsonPath) {
2992
+ return contractJsonPath.replace(/\.json$/i, ".d.ts");
2993
+ }
2944
2994
  async function readContractIR(contractJson, contractJsonPath) {
2945
2995
  return {
2946
2996
  contract: contractJson,
2947
- contractDts: await readFile(contractJsonPath.replace(/\.json$/i, ".d.ts"), "utf-8")
2997
+ contractDts: await readFile(contractDtsPathOf(contractJsonPath), "utf-8")
2948
2998
  };
2949
2999
  }
3000
+ function fsErrorCodeOf(error) {
3001
+ const code = error instanceof Error ? Reflect.get(error, "code") : void 0;
3002
+ return typeof code === "string" ? code : void 0;
3003
+ }
3004
+ function errorUnreadableContractDts(contractJsonPath, cause) {
3005
+ const contractDtsPath = contractDtsPathOf(contractJsonPath);
3006
+ const code = fsErrorCodeOf(cause);
3007
+ return errorFileNotFound(contractDtsPath, {
3008
+ why: code === "ENOENT" ? `The contract types next to ${contractJsonPath} are missing: ${contractDtsPath}` : `The contract types next to ${contractJsonPath} could not be read${code === void 0 ? "" : ` (${code})`}: ${contractDtsPath}`,
3009
+ fix: "Run {bin} contract emit to regenerate the contract artifacts, then advance the ref again.",
3010
+ cause
3011
+ });
3012
+ }
3013
+ /**
3014
+ * Everything `advanceRefSafely` needs from disk, loaded before a command does
3015
+ * the work that precedes the ref write: the ref name is validated and the
3016
+ * sibling `.d.ts` of the contract to snapshot is read. The returned
3017
+ * `ContractIR` is what the command then hands to `advanceRefSafely`, so no
3018
+ * file is read after the database is signed.
3019
+ */
3020
+ async function preflightRefAdvancement(args) {
3021
+ if (!validateRefName(args.name)) return notOk(errorInvalidRefName(args.name));
3022
+ try {
3023
+ return ok(await readContractIR(args.contractJson, args.contractJsonPath));
3024
+ } catch (error) {
3025
+ return notOk(errorUnreadableContractDts(args.contractJsonPath, error));
3026
+ }
3027
+ }
2950
3028
  async function executeRefAdvancement(refsDir, migrationsDir, name, hash, contractIR) {
2951
3029
  if (!validateRefName(name)) throw errorInvalidRefName(name);
2952
3030
  await writeContractSnapshot(migrationsDir, hash, {
@@ -3012,7 +3090,10 @@ async function resolveRefAdvancementFields(options) {
3012
3090
  throw error;
3013
3091
  }
3014
3092
  }
3015
- /** migrate's --advance-ref tail: executeRefAdvancement with MigrationToolsError passed through, others rethrown. */
3093
+ /**
3094
+ * The --advance-ref tail of migrate and db sign: executeRefAdvancement with
3095
+ * MigrationToolsError failures passed through as notOk, others rethrown.
3096
+ */
3016
3097
  async function advanceRefSafely(args) {
3017
3098
  try {
3018
3099
  return ok(await executeRefAdvancement(args.refsDir, args.migrationsDir, args.name, args.hash, args.contractIR));
@@ -3056,7 +3137,7 @@ async function resolveContractRefToSnapshot(options) {
3056
3137
  } catch (error) {
3057
3138
  if (isEnoent$1(error)) return notOk(errorFileNotFound(options.contractPathAbsolute, {
3058
3139
  why: `Contract file not found at ${options.contractPathAbsolute}`,
3059
- fix: "Run `prisma-cli contract emit` first to generate the contract",
3140
+ fix: "Run `{bin} contract emit` first to generate the contract",
3060
3141
  cause: error
3061
3142
  }));
3062
3143
  return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), {
@@ -3197,7 +3278,7 @@ async function executeMigrateShowPlan(options) {
3197
3278
  dbConnection,
3198
3279
  hasDriver,
3199
3280
  why: "migrate --show needs a database connection to read the live marker (or pass --from <contract> for an offline preview)",
3200
- retryCommand: "prisma-cli migrate --show --from <contract>"
3281
+ retryCommand: "{bin} db migrate --show --from <contract>"
3201
3282
  });
3202
3283
  if (missingDb) return notOk(missingDb);
3203
3284
  }
@@ -3244,7 +3325,7 @@ async function executeMigrateShowPlan(options) {
3244
3325
  dbConnection,
3245
3326
  hasDriver,
3246
3327
  why: "@db resolves to the live database marker and requires a --db connection",
3247
- retryCommand: "prisma-cli migrate --show --from @db --db $DATABASE_URL"
3328
+ retryCommand: "{bin} db migrate --show --from @db --db $DATABASE_URL"
3248
3329
  });
3249
3330
  if (missingDb) return notOk(missingDb);
3250
3331
  } else {
@@ -3628,7 +3709,7 @@ function checkDanglingRefs(space) {
3628
3709
  code: "MIGRATION.CHECK_DANGLING_REF",
3629
3710
  where: relative(space.cwd, join(space.refsDir, `${name}.json`)),
3630
3711
  why: `Ref "${name}" points at ${entry.hash} which does not exist in the migration graph`,
3631
- nextActions: [runCommandAction("Point the ref at a graph node", `prisma-cli ref set ${name} <valid-hash>`), chooseAction("Or delete the ref")]
3712
+ nextActions: [runCommandAction("Point the ref at a graph node", `{bin} migration ref set ${name} <valid-hash>`), chooseAction("Or delete the ref")]
3632
3713
  });
3633
3714
  return failures;
3634
3715
  }
@@ -3871,7 +3952,7 @@ async function executeMigrationNewCommand(options) {
3871
3952
  } catch (error) {
3872
3953
  if (error instanceof Error && error.code === "ENOENT") return notOk(errorRuntime("CLI.FILE_NOT_FOUND", `Contract file not found at ${contractPathAbsolute}`, {
3873
3954
  why: `Contract file not found at ${contractPathAbsolute}`,
3874
- fix: "Run `prisma-cli contract emit` first to generate the contract"
3955
+ fix: "Run `{bin} contract emit` first to generate the contract"
3875
3956
  }));
3876
3957
  throw error;
3877
3958
  }
@@ -3882,21 +3963,21 @@ async function executeMigrationNewCommand(options) {
3882
3963
  } catch (error) {
3883
3964
  return notOk(errorRuntime("MIGRATION.CONTRACT_DESERIALIZATION_FAILED", "Contract JSON is invalid", {
3884
3965
  why: `Failed to deserialize ${contractPathAbsolute}: ${error instanceof Error ? error.message : String(error)}`,
3885
- fix: "Run `prisma-cli contract emit` to regenerate the contract",
3966
+ fix: "Run `{bin} contract emit` to regenerate the contract",
3886
3967
  cause: error
3887
3968
  }));
3888
3969
  }
3889
3970
  const toStorageHash = toContract.storage?.storageHash;
3890
3971
  if (typeof toStorageHash !== "string") return notOk(errorRuntime("CONTRACT.VALIDATION_FAILED", "Contract is missing storageHash", {
3891
3972
  why: `Contract at ${contractPathAbsolute} has no storageHash`,
3892
- fix: "Run `prisma-cli contract emit` to regenerate the contract"
3973
+ fix: "Run `{bin} contract emit` to regenerate the contract"
3893
3974
  }));
3894
3975
  const aggregate = await loadContractSpaceAggregate({
3895
3976
  migrationsDir,
3896
3977
  deserializeContract: (json) => familyInstance.deserializeContract(json),
3897
3978
  appContract: toContract
3898
3979
  });
3899
- const packageCorruptionFailure = refusePackageCorruptionOnAggregate(aggregate);
3980
+ const packageCorruptionFailure = refusePackageCorruptionOnAggregate(aggregate, migrationsDir);
3900
3981
  if (packageCorruptionFailure) return notOk(packageCorruptionFailure);
3901
3982
  const packages = aggregate.app.packages;
3902
3983
  const graph = aggregate.app.graph();
@@ -3914,7 +3995,7 @@ async function executeMigrationNewCommand(options) {
3914
3995
  }
3915
3996
  if (fromHash === toStorageHash && !options.from) return notOk(errorRuntime("MIGRATION.NO_CHANGES", "No changes detected", {
3916
3997
  why: "The from and to contract hashes are identical — there is nothing to migrate.",
3917
- fix: "Change the contract and run `prisma-cli contract emit` before creating a new migration. To author a data-only migration on the current contract hash, pass `--from <hash>` explicitly."
3998
+ fix: "Change the contract and run `{bin} contract emit` before creating a new migration. To author a data-only migration on the current contract hash, pass `--from <hash>` explicitly."
3918
3999
  }));
3919
4000
  const timestamp = /* @__PURE__ */ new Date();
3920
4001
  const packageDir = join(appMigrationsDir, formatMigrationDirName(timestamp, options.name ?? "migration"));
@@ -4138,11 +4219,15 @@ async function resolveFromForPlan(input) {
4138
4219
  const refs = space.refs;
4139
4220
  if (optionsFrom === void 0) {
4140
4221
  const dbRef = refs["db"];
4141
- if (!dbRef) return ok({
4142
- kind: "greenfield",
4143
- fromHash: null,
4144
- fromContract: null
4145
- });
4222
+ if (!dbRef) {
4223
+ if (graphIsEmpty(space)) return ok({
4224
+ kind: "greenfield",
4225
+ fromHash: null,
4226
+ fromContract: null,
4227
+ defaulted: true
4228
+ });
4229
+ return notOk(errorPlanOriginUnknown(getReachableRefs(refs, graph), findLatestMigration(graph)?.to ?? null));
4230
+ }
4146
4231
  return resolveFromPolicy({
4147
4232
  hash: dbRef.hash,
4148
4233
  provenance: {
@@ -4164,6 +4249,12 @@ async function resolveFromForPlan(input) {
4164
4249
  }
4165
4250
  return notOk(mapRefResolutionError(refResult.failure));
4166
4251
  }
4252
+ if (refResult.value.provenance.kind === "reserved-empty") return ok({
4253
+ kind: "greenfield",
4254
+ fromHash: null,
4255
+ fromContract: null,
4256
+ defaulted: false
4257
+ });
4167
4258
  return resolveFromPolicy(refResult.value, input, refs, optionsFrom);
4168
4259
  }
4169
4260
  async function resolveToForPlan(optionsTo, input) {
@@ -4175,6 +4266,13 @@ async function resolveToForPlan(optionsTo, input) {
4175
4266
  refs
4176
4267
  });
4177
4268
  if (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));
4269
+ if (refResult.value.provenance.kind === "reserved-empty") return notOk(mapRefResolutionError({
4270
+ kind: "wrong-grammar",
4271
+ input: optionsTo,
4272
+ expectedGrammar: "contract",
4273
+ message: "`@empty` is only valid as an origin (`--from`); planning a migration to the empty contract is not supported through this shortcut",
4274
+ fix: "Pass `--to` a contract hash, ref name, or migration directory name. To plan starting from an empty database, use `--from @empty`."
4275
+ }));
4178
4276
  const resolution = await resolveContractRef(refResult.value, space, {
4179
4277
  explicitLabel: optionsTo,
4180
4278
  artifactRole: "to"
@@ -4270,7 +4368,7 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4270
4368
  } catch (error) {
4271
4369
  if (isEnoent(error)) return notOk(errorFileNotFound(contractPathAbsolute, {
4272
4370
  why: `Contract file not found at ${contractPathAbsolute}`,
4273
- fix: `Run \`prisma-cli contract emit\` to generate ${contractPath}, or update \`config.contract.output\` in ${configPath}`
4371
+ fix: `Run \`{bin} contract emit\` to generate ${contractPath}, or update \`config.contract.output\` in ${configPath}`
4274
4372
  }));
4275
4373
  return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}` }));
4276
4374
  }
@@ -4291,6 +4389,7 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4291
4389
  let fromHash = null;
4292
4390
  let snapshotStartContract = null;
4293
4391
  let isAutoBaseline = false;
4392
+ let fromDefaulted = false;
4294
4393
  const tolerantAggregateResult = await loadContractSpaceAggregateForCli({
4295
4394
  targetId: config.target.targetId,
4296
4395
  migrationsDir,
@@ -4306,7 +4405,9 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4306
4405
  });
4307
4406
  if (!resolutionResult.ok) return notOk(resolutionResult.failure);
4308
4407
  switch (resolutionResult.value.kind) {
4309
- case "greenfield": break;
4408
+ case "greenfield":
4409
+ fromDefaulted = resolutionResult.value.defaulted;
4410
+ break;
4310
4411
  case "graph-node":
4311
4412
  fromHash = resolutionResult.value.fromHash;
4312
4413
  fromContract = resolutionResult.value.fromContract;
@@ -4504,6 +4605,7 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4504
4605
  operations: [],
4505
4606
  emittedExtensionDirs,
4506
4607
  pendingPlaceholders: true,
4608
+ ...fromDefaulted ? { fromDefaulted } : {},
4507
4609
  summary: "Planned migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit",
4508
4610
  timings: { total: Date.now() - startTime }
4509
4611
  });
@@ -4522,6 +4624,7 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4522
4624
  })),
4523
4625
  emittedExtensionDirs,
4524
4626
  ...preview !== void 0 ? { preview } : {},
4627
+ ...fromDefaulted ? { fromDefaulted } : {},
4525
4628
  summary: buildPlanSummary(plannedOps.length, emittedExtensionDirs.length),
4526
4629
  timings: { total: Date.now() - startTime }
4527
4630
  });
@@ -4681,6 +4784,6 @@ async function executeRefListCommand(options) {
4681
4784
  }
4682
4785
  }
4683
4786
  //#endregion
4684
- export { loadContractRawSafely as $, errorMigrationPlanningFailed as A, statusForMigrationHash as At, executeDbUpdate as B, errorDestructiveChanges as C, resolveRefAdvancementFields as Ct, errorLegendHumanOnly as D, runMigrationCheck as Dt, errorHashMismatch as E, runContractSpaceSeedPhase as Et, errorTargetMigrationNotSupported as F, executeRefAdvancement as G, executeMigrateShowPlan as H, errorTargetMismatch as I, executeRefSetCommand as J, executeRefDeleteCommand as K, errorUnexpected as L, errorPathUnreachable as M, toDeclaredExtensionsFromRaw as Mt, errorRunnerFailed as N, errorMarkerMissing as O, runMigrationList as Ot, errorRuntime as P, loadAggregateIntegrityViolations as Q, executeContractEmit as R, errorDatabaseConnectionRequired as S, resolveMigrationRef as St, errorFileNotFound as T, runCommandAction as Tt, executeMigrationNewCommand as U, executeDbVerify as V, executeMigrationPlanCommand as W, hasMigrationPath as X, findPackageByDirPath as Y, listRefsByContractHash as Z, enumerateCheckSpaces as _, requireLiveDatabase as _t, buildContractSpaceAggregate as a, maskConnectionUrl as at, errorContractArgConflict as b, resolveContractRefToSnapshot as bt, buildRefAdvancementFields as c, readContractEnvelope as ct, closeQuietly as d, refuseContractSpaceIntegrity as dt, loadContractSpaceAggregateForCli as et, computeRefAdvancementName as f, refuseDeclaredExtensionTargetMismatch as ft, enrichContract as g, refuseUnknownInvariants as gt, disposeEmitQueue as h, refusePackageCorruptionOnAggregate as ht, appliedHashesFromLedger as i, mapIntegrityViolations as it, errorNoMigrations as j, targetSupportsMigrations as jt, errorMigrationPackageNotFound as k, sanitizeErrorMessage as kt, checkSingleTarget as l, readContractIR as lt, deriveStatusEdgeAnnotations as m, refuseMissingInvariantPath as mt, advanceRefSafely as n, mapCaughtMigrationError as nt, buildMigrationSpaceGraphEntries as o, migrationSpaceListEntriesFromAggregate as ot, createControlClient as p, refuseMarkerOutsideGraph as pt, executeRefListCommand as q, appContractStandInFromIdentity as r, mapContractAtError as rt, buildReadAggregate as s, originHashForStatus as st, CliStructuredError$1 as t, looksLikePath as tt, chooseAction as u, readMigrationRefs as ut, errorConfigValidation$1 as v, resolveAppTargetPath as vt, errorDriverRequired as w, resolveToForPlan as wt, errorContractValidationFailed as x, resolveFromForPlan as xt, errorConsentPlanMismatch as y, resolveContractRef$1 as yt, executeDbInit as z };
4787
+ export { loadAggregateIntegrityViolations as $, errorMigrationPackageNotFound as A, runMigrationList as At, executeDbInit as B, errorDatabaseConnectionRequired as C, resolveFromForPlan as Ct, errorHashMismatch as D, runCommandAction as Dt, errorFileNotFound as E, resolveToForPlan as Et, errorRuntime as F, executeMigrationPlanCommand as G, executeDbVerify as H, errorTargetMigrationNotSupported as I, executeRefListCommand as J, executeRefAdvancement as K, errorTargetMismatch as L, errorNoMigrations as M, statusForMigrationHash as Mt, errorPathUnreachable as N, targetSupportsMigrations as Nt, errorLegendHumanOnly as O, runContractSpaceSeedPhase as Ot, errorRunnerFailed as P, toDeclaredExtensionsFromRaw as Pt, listRefsByContractHash as Q, errorUnexpected as R, errorContractValidationFailed as S, resolveContractRefToSnapshot as St, errorDriverRequired as T, resolveRefAdvancementFields as Tt, executeMigrateShowPlan as U, executeDbUpdate as V, executeMigrationNewCommand as W, findPackageByDirPath as X, executeRefSetCommand as Y, hasMigrationPath as Z, enumerateCheckSpaces as _, refusePackageCorruptionOnAggregate as _t, buildContractSpaceAggregate as a, mapIntegrityViolations as at, errorConsentPlanMismatch as b, resolveAppTargetPath as bt, buildRefAdvancementFields as c, originHashForStatus as ct, closeQuietly as d, readContractIR as dt, loadContractRawSafely as et, computeRefAdvancementName as f, readMigrationRefs as ft, enrichContract as g, refuseMissingInvariantPath as gt, disposeEmitQueue as h, refuseMarkerOutsideGraph as ht, appliedHashesFromLedger as i, mapContractAtError as it, errorMigrationPlanningFailed as j, sanitizeErrorMessage as jt, errorMarkerMissing as k, runMigrationCheck as kt, checkSingleTarget as l, preflightRefAdvancement as lt, deriveStatusEdgeAnnotations as m, refuseDeclaredExtensionTargetMismatch as mt, advanceRefSafely as n, looksLikePath as nt, buildMigrationSpaceGraphEntries as o, maskConnectionUrl as ot, createControlClient as p, refuseContractSpaceIntegrity as pt, executeRefDeleteCommand as q, appContractStandInFromIdentity as r, mapCaughtMigrationError as rt, buildReadAggregate as s, migrationSpaceListEntriesFromAggregate as st, CliStructuredError$1 as t, loadContractSpaceAggregateForCli as tt, chooseAction as u, readContractEnvelope as ut, errorAdvanceRefArgConflict as v, refuseUnknownInvariants as vt, errorDestructiveChanges as w, resolveMigrationRef as wt, errorContractArgConflict as x, resolveContractRef$1 as xt, errorConfigValidation$1 as y, requireLiveDatabase as yt, executeContractEmit as z };
4685
4788
 
4686
- //# sourceMappingURL=ref-h6InR6dO-rGfl18Jv.mjs.map
4789
+ //# sourceMappingURL=ref-DcqFmceq-QaUjgZeM.mjs.map