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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -11,7 +11,7 @@ import { d as writeRef, r as readRef } from "./refs-DM3q3IZC-BC6H6P0X.mjs";
11
11
  import { a as contractHashAtMarker } from "./aggregate-BIjV2dM9.mjs";
12
12
  import { i as createScaffoldSpecifierResolver } from "./import-roots-CWlCTZJ9.mjs";
13
13
  import { o as isLiveMarkerRef } from "./ref-resolution-Eo0QHp4f.mjs";
14
- import { $ as refuseContractSpaceIntegrity, A as executeRefDeleteCommand, B as loadAggregateIntegrityViolations, D as executeMigrationNewCommand, E as executeMigrateShowPlan, F as hasMigrationPath, G as looksLikePath, H as loadContractSource, I as isStatementVerb, J as matchConsents, K as mapContractAtError, L as labelsText, M as executeRefSetCommand, N as findPackageByDirPath, O as executeMigrationPlanCommand, P as formatSourceDiagnostic, Q as readMigrationRefs, R as listRefsByContractHash, St as withWarningFindings, U as loadContractSourceWithStack, V as loadContractRawSafely, W as loadContractSpaceAggregateForCli, X as planEverySpace, Y as migrationSpaceListEntriesFromAggregate, Z as preflightRefAdvancement, _ as deriveStatusEdgeAnnotations, _t as snapshotVerifierFor, a as advanceRefSafely, at as requireDatabaseForLiveMarkerUse, b as enumerateCheckSpaces, bt as toDeclaredExtensionsFromRaw, ct as resolveContractRefToSnapshot, d as buildRefAdvancementFields, f as checkSingleTarget, g as createControlClient, gt as runMigrationList, h as convertAndDelete, ht as runMigrationCheck, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as renamedAndDeleted, j as executeRefListCommand, l as buildMigrationSpaceGraphEntries, m as contractValidationMeta, n as NO_REF_ADVANCEMENT, nt as refusePackageCorruptionOnAggregate, ot as resolveAppTargetPath, p as computeRefAdvancementName, pt as retryCommandFor, r as RECORDED_CONTRACT_REF_FORMS, rt as refuseUnknownInvariants, s as appliedHashesFromLedger, st as resolveContractRef$1, t as ALL_CONTRACT_REF_FORMS, tt as refuseMissingInvariantPath, u as buildReadAggregate, ut as resolveMigrationRef, vt as sourceWarningDiagnostic, x as executeContractEmit, xt as validateLoadedContract, yt as statusForMigrationHash, z as liveMarkerUse } from "./ref-hKV9pGrC-DVWnb8cQ.mjs";
14
+ import { $ as refuseContractSpaceIntegrity, A as executeRefDeleteCommand, B as loadAggregateIntegrityViolations, Ct as withWarningFindings, D as executeMigrationNewCommand, E as executeMigrateShowPlan, F as hasMigrationPath, G as looksLikePath, H as loadContractSource, I as isStatementVerb, J as matchConsents, K as mapContractAtError, L as labelsText, M as executeRefSetCommand, N as findPackageByDirPath, O as executeMigrationPlanCommand, P as formatSourceDiagnostic, Q as readMigrationRefs, R as listRefsByContractHash, St as validateLoadedContract, U as loadContractSourceWithStack, V as loadContractRawSafely, W as loadContractSpaceAggregateForCli, X as planEverySpace, Y as migrationSpaceListEntriesFromAggregate, Z as preflightRefAdvancement, _ as deriveStatusEdgeAnnotations, _t as skippedOperationsText, a as advanceRefSafely, at as requireDatabaseForLiveMarkerUse, b as enumerateCheckSpaces, bt as statusForMigrationHash, ct as resolveContractRefToSnapshot, d as buildRefAdvancementFields, f as checkSingleTarget, g as createControlClient, gt as runMigrationList, h as convertAndDelete, ht as runMigrationCheck, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as renamedAndDeleted, j as executeRefListCommand, l as buildMigrationSpaceGraphEntries, m as contractValidationMeta, n as NO_REF_ADVANCEMENT, nt as refusePackageCorruptionOnAggregate, ot as resolveAppTargetPath, p as computeRefAdvancementName, pt as retryCommandFor, r as RECORDED_CONTRACT_REF_FORMS, rt as refuseUnknownInvariants, s as appliedHashesFromLedger, st as resolveContractRef$1, t as ALL_CONTRACT_REF_FORMS, tt as refuseMissingInvariantPath, u as buildReadAggregate, ut as resolveMigrationRef, vt as snapshotVerifierFor, x as executeContractEmit, xt as toDeclaredExtensionsFromRaw, yt as sourceWarningDiagnostic, z as liveMarkerUse } from "./ref-DH9J_oNY-CipATbYR.mjs";
15
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-BcC8eB0h-C5bRd-aC.mjs";
16
16
  import { a as resolveGating, i as readUserConfig, r as ensureInstallationId, s as runTelemetry, u as userConfigPath } from "./exports-DwuO4y2c.mjs";
17
17
  import { createRequire } from "node:module";
@@ -43,8 +43,8 @@ import stringWidth from "string-width";
43
43
  import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
44
44
  import { isCI } from "ci-info";
45
45
  import { build } from "esbuild";
46
- //#region ../../../1-framework/3-tooling/cli/dist/cli-CFId1dwB.mjs
47
- var version = "8.0.0-rc.23-dev.13";
46
+ //#region ../../../1-framework/3-tooling/cli/dist/cli-DMFXjnp3.mjs
47
+ var version = "8.0.0-rc.24-dev.1";
48
48
  const ESCAPES = {
49
49
  "\\": "\\\\",
50
50
  " ": "\\t",
@@ -833,6 +833,11 @@ function renderPreviewStatement(text, language) {
833
833
  function previewBlockHeader(preview) {
834
834
  return preview.statements.length > 0 && preview.statements.every((s) => s.language === "sql") ? "DDL preview" : "Operation preview";
835
835
  }
836
+ /** A planner warning as the CLI prints it: its summary, then its why. */
837
+ function plannerWarningText(warning) {
838
+ if (warning.why === void 0) return warning.summary;
839
+ return `${/[.!?]$/.test(warning.summary) ? warning.summary : `${warning.summary}.`} ${warning.why}`;
840
+ }
836
841
  const SLOT_TEXT = {
837
842
  convert: "conversion slot written in migration.ts",
838
843
  backfill: "backfill slots written in migration.ts"
@@ -918,6 +923,14 @@ function operationBlocks$2(result) {
918
923
  roots: result.plan.operations.map(operationNode)
919
924
  }, ...destructiveWarningBlocks(hasDestructive)];
920
925
  }
926
+ /** What the planner flagged without refusing to plan it, each its summary followed by its why. */
927
+ function plannerWarningBlocks(result) {
928
+ return (result.plannerWarnings ?? []).map((warning) => ({
929
+ kind: "summary",
930
+ status: "warn",
931
+ text: plannerWarningText(warning)
932
+ }));
933
+ }
921
934
  /** The statements a database would run, printed verbatim rather than laid out. */
922
935
  function previewBlocks$2(preview) {
923
936
  if (preview === void 0) return [];
@@ -938,26 +951,13 @@ function previewBlocks$2(preview) {
938
951
  lines: statements
939
952
  }];
940
953
  }
941
- /** What the planner flagged without refusing to plan it. */
942
- function plannerWarningBlocks(result) {
943
- const warnings = result.warnings ?? [];
944
- if (warnings.length === 0) return [];
945
- return [{
946
- kind: "summary",
947
- status: "warn",
948
- text: "Planner warnings"
949
- }, {
950
- kind: "list",
951
- items: warnings.map((warning) => warning.summary)
952
- }];
953
- }
954
954
  /** The new required fields whose existing rows get a temporary value, and how to choose the value. */
955
955
  function temporaryValueBlocks$1(result, invocation, databaseStorageHash) {
956
956
  const get = result.mode === "plan" ? "would get" : "got";
957
957
  return (result.temporaryValues ?? []).map(({ field, value }) => ({
958
958
  kind: "summary",
959
959
  status: "warn",
960
- text: `Existing rows ${get} ${value} in field "${field}". To choose the value, plan a migration with ${printedPlanCommand(invocation, databaseStorageHash, [statementFlag({
960
+ 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({
961
961
  verb: "backfill",
962
962
  text: field
963
963
  })])} instead.`
@@ -970,11 +970,12 @@ function planSummaryText(result) {
970
970
  }
971
971
  function applySummaryText(result) {
972
972
  const executed = result.execution?.operationsExecuted ?? 0;
973
+ const planned = result.plan.operations.length;
973
974
  const spaces = result.perSpace?.length ?? 0;
974
975
  const across = spaces > 0 ? ` across ${spaces} contract space${spaces === 1 ? "" : "s"}` : "";
975
976
  if (result.changedStorageEntities !== void 0) return result.summary;
976
977
  if (executed === 0) return `Database already matches contract${across}`;
977
- return `Applied ${executed} operation(s)${across}`;
978
+ return executed < planned ? `Applied ${executed} of ${planned} operation(s)${across}; ${skippedOperationsText(planned - executed)}` : `Applied ${executed} operation(s)${across}`;
978
979
  }
979
980
  /** For each namespace the plan removes, the answers that answer all of its questions. */
980
981
  function namespaceAnswerLines(result) {
@@ -1128,9 +1129,8 @@ function migrationResultNextActions(result, invocation, applyCommand) {
1128
1129
  return result.mode === "plan" ? [runCommandAction("Apply the planned operations", applyCommand)] : [runCommandAction(result.perSpace !== void 0 && result.perSpace.length === 1 ? "Confirm the space is up to date" : "Confirm every space is up to date", cliCommand(invocation, "migration status"))];
1129
1130
  }
1130
1131
  /**
1131
- * Collects the planner's warnings a run hands to `onPlannerWarnings`. A failed run reports them as
1132
- * `warn` messages, which reach the human and the `--json` output; a successful one lists them in
1133
- * its result.
1132
+ * Collects the planner's warnings a run hands to `onPlannerWarnings`. A successful run shows them
1133
+ * in its result; a failed one reports them as `warn` messages, which come before its error.
1134
1134
  */
1135
1135
  function plannerWarningsCollector(report) {
1136
1136
  let collected = [];
@@ -1143,7 +1143,7 @@ function plannerWarningsCollector(report) {
1143
1143
  for (const warning of collected) report({
1144
1144
  kind: "message",
1145
1145
  severity: "warn",
1146
- text: warning.summary
1146
+ text: plannerWarningText(warning)
1147
1147
  });
1148
1148
  }
1149
1149
  };
@@ -1255,7 +1255,7 @@ function initDocument(inputs) {
1255
1255
  ...ifDefined("perSpace", value.perSpace),
1256
1256
  advancedRef: inputs.advancedRef,
1257
1257
  plannedAdvanceRef: inputs.plannedAdvanceRef,
1258
- ...inputs.plannerWarnings.length > 0 ? { warnings: inputs.plannerWarnings } : {},
1258
+ ...inputs.plannerWarnings.length > 0 ? { plannerWarnings: inputs.plannerWarnings } : {},
1259
1259
  summary: value.summary,
1260
1260
  timings: { total: Date.now() - inputs.startedAt }
1261
1261
  };
@@ -2430,7 +2430,7 @@ function updateDocument(inputs) {
2430
2430
  removedNamespaces: removedNamespacesJson(value, inputs.statements),
2431
2431
  addedNamespaces: value.namespaces?.added ?? []
2432
2432
  } : {},
2433
- ...inputs.plannerWarnings.length > 0 ? { warnings: inputs.plannerWarnings } : {},
2433
+ ...inputs.plannerWarnings.length > 0 ? { plannerWarnings: inputs.plannerWarnings } : {},
2434
2434
  advancedRef: inputs.advancedRef,
2435
2435
  plannedAdvanceRef: inputs.plannedAdvanceRef,
2436
2436
  summary: value.summary,
@@ -10725,14 +10725,14 @@ function temporaryValueBlocks(result) {
10725
10725
  return result.temporaryValues.map(({ field, value }) => ({
10726
10726
  kind: "summary",
10727
10727
  status: "warn",
10728
- text: `Existing rows get ${value} in field "${field}". To choose the value, plan again with ${statementFlag({
10728
+ text: `Field "${field}" gets the temporary value ${value} where existing data has none. To choose the value, plan again with ${statementFlag({
10729
10729
  verb: "backfill",
10730
10730
  text: field
10731
10731
  })}.`
10732
10732
  }));
10733
10733
  }
10734
10734
  function warningBlocks(result) {
10735
- return (result.warnings ?? []).map((text) => ({
10735
+ return [...result.warnings ?? [], ...(result.plannerWarnings ?? []).map(plannerWarningText)].map((text) => ({
10736
10736
  kind: "summary",
10737
10737
  status: "warn",
10738
10738
  text
@@ -11816,6 +11816,45 @@ const refSetCommand = createRefSetCommand();
11816
11816
  * dotted code.
11817
11817
  */
11818
11818
  const DOCS_BASE_URL = `${DOCS_BASE}/`;
11819
+ const commands = {
11820
+ "contract print": contractPrintCommand,
11821
+ "contract emit": contractEmitCommand,
11822
+ "contract format": formatCommand,
11823
+ "contract infer": contractInferCommand,
11824
+ "db init": dbInitCommand,
11825
+ "db migrate": migrateCommand,
11826
+ "db schema": dbSchemaCommand,
11827
+ "db sign": dbSignCommand,
11828
+ "db update": dbUpdateCommand,
11829
+ "db verify": dbVerifyCommand,
11830
+ lsp: lspCommand,
11831
+ "migration check": migrationCheckCommand,
11832
+ "migration graph": migrationGraphCommand,
11833
+ "migration list": migrationListCommand,
11834
+ "migration log": migrationLogCommand,
11835
+ "migration new": migrationNewCommand,
11836
+ "migration plan": migrationPlanCommand,
11837
+ "migration ref delete": refDeleteCommand,
11838
+ "migration ref list": refListCommand,
11839
+ "migration ref set": refSetCommand,
11840
+ "migration show": migrationShowCommand,
11841
+ "migration status": migrationStatusCommand,
11842
+ "orm init": initCommand
11843
+ };
11844
+ const CLI_DOCS_URL = "https://www.prisma.io/docs/cli";
11845
+ const PRISMA_7_INSTALL = "install its CLI with `npm install --save-dev @prisma/prisma7@7`";
11846
+ function v7Command(from, entry) {
11847
+ const { whileMigrationsStayOnPrisma7, prisma7Invocation, reason, ...rest } = entry;
11848
+ const invocation = `prisma7 ${prisma7Invocation ?? from}`;
11849
+ const prisma7 = whileMigrationsStayOnPrisma7 ? `While Prisma 7 still owns this project's migrations, ${PRISMA_7_INSTALL} and run \`${invocation}\` instead.` : `To keep using Prisma 7, ${PRISMA_7_INSTALL} and run \`${invocation}\`.`;
11850
+ return {
11851
+ from,
11852
+ code: "CLI.V7_COMMAND",
11853
+ summary: `\`{bin} ${from}\` is a Prisma 7 command and is not available in Prisma 8`,
11854
+ reason: `${reason} ${prisma7}`,
11855
+ ...rest
11856
+ };
11857
+ }
11819
11858
  /**
11820
11859
  * The unit the ORM contributes to a CLI: its config section, its commands by
11821
11860
  * name, where its diagnostics are documented, and the invocations it retired.
@@ -11823,31 +11862,7 @@ const DOCS_BASE_URL = `${DOCS_BASE}/`;
11823
11862
  */
11824
11863
  const ormCommandFamily = defineCommandFamily({
11825
11864
  configSection: ormConfigSection,
11826
- commands: {
11827
- "contract print": contractPrintCommand,
11828
- "contract emit": contractEmitCommand,
11829
- "contract format": formatCommand,
11830
- "contract infer": contractInferCommand,
11831
- "db init": dbInitCommand,
11832
- "db migrate": migrateCommand,
11833
- "db schema": dbSchemaCommand,
11834
- "db sign": dbSignCommand,
11835
- "db update": dbUpdateCommand,
11836
- "db verify": dbVerifyCommand,
11837
- lsp: lspCommand,
11838
- "migration check": migrationCheckCommand,
11839
- "migration graph": migrationGraphCommand,
11840
- "migration list": migrationListCommand,
11841
- "migration log": migrationLogCommand,
11842
- "migration new": migrationNewCommand,
11843
- "migration plan": migrationPlanCommand,
11844
- "migration ref delete": refDeleteCommand,
11845
- "migration ref list": refListCommand,
11846
- "migration ref set": refSetCommand,
11847
- "migration show": migrationShowCommand,
11848
- "migration status": migrationStatusCommand,
11849
- "orm init": initCommand
11850
- },
11865
+ commands,
11851
11866
  docsBaseUrl: DOCS_BASE_URL,
11852
11867
  redirects: [
11853
11868
  {
@@ -11879,36 +11894,84 @@ const ormCommandFamily = defineCommandFamily({
11879
11894
  replacement: "{bin} migration status --to <contract>",
11880
11895
  reason: "One flag names the target contract, whether it is a ref, a hash or a migration."
11881
11896
  },
11882
- {
11883
- from: "migrate dev",
11884
- replacement: "{bin} contract emit",
11885
- 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 --advance-ref db`; while Prisma 7 still owns this project's migrations, run `migrate dev` with Prisma 7's CLI instead."
11886
- },
11887
- {
11888
- from: "migrate deploy",
11897
+ v7Command("migrate dev", {
11898
+ replacement: [
11899
+ "{bin} contract emit",
11900
+ "{bin} migration plan --name <name>",
11901
+ "{bin} db migrate --advance-ref db"
11902
+ ],
11903
+ 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 --advance-ref db`.",
11904
+ whileMigrationsStayOnPrisma7: true,
11905
+ help: "contract emit"
11906
+ }),
11907
+ v7Command("migrate deploy", {
11889
11908
  replacement: "{bin} db migrate",
11890
- reason: "`db migrate` applies the planned migrations; while Prisma 7 still owns this project's migrations, run `migrate deploy` with Prisma 7's CLI instead."
11891
- },
11892
- {
11893
- from: "migrate status",
11909
+ reason: "`db migrate` applies the planned migrations.",
11910
+ whileMigrationsStayOnPrisma7: true,
11911
+ help: "db migrate"
11912
+ }),
11913
+ v7Command("migrate status", {
11894
11914
  replacement: "{bin} migration status",
11895
- reason: "`migration status` reports which planned migrations the database has applied; while Prisma 7 still owns this project's migrations, run `migrate status` with Prisma 7's CLI instead."
11896
- },
11897
- {
11898
- from: "migrate diff",
11915
+ reason: "`migration status` reports which planned migrations the database has applied.",
11916
+ whileMigrationsStayOnPrisma7: true,
11917
+ help: "migration status"
11918
+ }),
11919
+ v7Command("migrate diff", {
11899
11920
  replacement: "{bin} db update --dry-run",
11900
- reason: "`db update --dry-run` prints the changes between the contract and a live database without applying them; to write the changes between two contracts as a migration package use `migration plan`, and to report drift use `db verify`."
11901
- },
11902
- {
11903
- from: "migrate reset",
11921
+ reason: "`db update --dry-run` prints the changes between the contract and a live database without applying them; to write the changes between two contracts as a migration package use `migration plan`, and to report drift use `db verify`.",
11922
+ prisma7Invocation: "migrate diff --from-config-datasource --to-schema <path>",
11923
+ help: "db update"
11924
+ }),
11925
+ v7Command("migrate reset", {
11904
11926
  replacement: "{bin} db update",
11905
- reason: "Prisma 8 has no reset: `db update` moves the database to the contract without a reset and asks before losing data, on a database whose migration history does not need to be kept; a database that changes only through migrations is moved with `db migrate`; while Prisma 7 still owns this project's migrations, run `migrate reset` with Prisma 7's CLI instead."
11906
- },
11907
- {
11908
- from: "migrate resolve",
11927
+ reason: "Prisma 8 has no reset: `db update` moves the database to the contract without a reset and asks before losing data, on a database whose migration history does not need to be kept; a database that changes only through migrations is moved with `db migrate`.",
11928
+ whileMigrationsStayOnPrisma7: true,
11929
+ help: "db update"
11930
+ }),
11931
+ v7Command("migrate resolve", {
11909
11932
  replacement: "{bin} db sign <migration>",
11910
- reason: "`db sign <migration>` checks that the database already has that migration's schema and moves the database marker to that migration's contract, so `db migrate` continues after it; `migration status` does not list the migration as applied. Use it where you would run `migrate resolve --applied` after applying a migration's changes by hand. While Prisma 7 still owns this project's migrations, run `migrate resolve` with Prisma 7's CLI instead."
11911
- }
11933
+ reason: "`db sign <migration>` checks that the database already has that migration's schema and moves the database marker to that migration's contract, so `db migrate` continues after it; `migration status` does not list the migration as applied. Use it where you would run `migrate resolve --applied` after applying a migration's changes by hand.",
11934
+ whileMigrationsStayOnPrisma7: true,
11935
+ prisma7Invocation: "migrate resolve --applied <migration>",
11936
+ help: "db sign"
11937
+ }),
11938
+ v7Command("generate", {
11939
+ replacement: "{bin} contract emit",
11940
+ help: "contract emit",
11941
+ reason: "Prisma 8 has no client generation step. `contract emit` reads your schema and writes contract.json and contract.d.ts, the contract files the ORM reads to know your data model and its types."
11942
+ }),
11943
+ v7Command("validate", {
11944
+ docsUrl: CLI_DOCS_URL,
11945
+ reason: "Prisma 8 has no separate validate command. `contract emit` reports an invalid schema when it runs, and writes the contract files when the schema is valid."
11946
+ }),
11947
+ v7Command("format", {
11948
+ replacement: "{bin} contract format",
11949
+ help: "contract format",
11950
+ reason: "`contract format` formats the PSL schema files your prisma.config.ts names as the contract source, in place. It leaves a schema written in TypeScript untouched."
11951
+ }),
11952
+ v7Command("studio", {
11953
+ docsUrl: CLI_DOCS_URL,
11954
+ reason: "Prisma 8 has no Studio command for browsing and editing your data in a browser."
11955
+ }),
11956
+ v7Command("db pull", {
11957
+ replacement: "{bin} contract infer",
11958
+ help: "contract infer",
11959
+ reason: "`contract infer` reads the live database, named with `--db <url>`, and writes its schema as a PSL contract file. Run `contract emit` afterwards to write the contract files the ORM reads, then `db sign` to record that the database matches the contract, so queries can run against it."
11960
+ }),
11961
+ v7Command("db push", {
11962
+ replacement: "{bin} db update",
11963
+ help: "db update",
11964
+ reason: "`db update` changes the database to match the contract directly, without migration files, and asks before any change that would lose data. On a new database, `db init` creates what the contract declares and never removes or changes anything already there. Both read the contract files `contract emit` writes, so run `contract emit` after changing the schema."
11965
+ }),
11966
+ v7Command("db seed", {
11967
+ docsUrl: CLI_DOCS_URL,
11968
+ reason: "Prisma 8 has no seed command. Run your seed script directly, for example with node."
11969
+ }),
11970
+ v7Command("db execute", {
11971
+ docsUrl: CLI_DOCS_URL,
11972
+ prisma7Invocation: "db execute --file <path>",
11973
+ reason: "Prisma 8 has no command that runs a script file of statements against the database."
11974
+ })
11912
11975
  ]
11913
11976
  });
11914
11977
  /**