@prisma/orm-toolchain 8.0.0-rc.19-dev.4 → 8.0.0-rc.19-dev.6

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 (30) hide show
  1. package/dist/{aggregate-Da8PGnzg.d.mts → aggregate-BpcQdygS.d.mts} +11 -7
  2. package/dist/aggregate-BpcQdygS.d.mts.map +1 -0
  3. package/dist/{aggregate-C30LiAd-.mjs → aggregate-T_HG6gq6.mjs} +13 -8
  4. package/dist/aggregate-T_HG6gq6.mjs.map +1 -0
  5. package/dist/{caught-errors-Dijk7Hgg-DBua0IMw.mjs → caught-errors-Bmbi1dBu-DKO5X2tN.mjs} +26 -4
  6. package/dist/caught-errors-Bmbi1dBu-DKO5X2tN.mjs.map +1 -0
  7. package/dist/cli.mjs +207 -38
  8. package/dist/cli.mjs.map +1 -1
  9. package/dist/cli__control-api.d.mts +5 -5
  10. package/dist/cli__control-api.mjs +2 -2
  11. package/dist/cli__control-api__testing.d.mts +1 -1
  12. package/dist/cli__control-api__testing.mjs +1 -1
  13. package/dist/cli__control-api__testing.mjs.map +1 -1
  14. package/dist/cli__migration-cli.mjs +1 -1
  15. package/dist/cli__migration-cli.mjs.map +1 -1
  16. package/dist/{db-sign-DyugidHS-DGvMQ558.d.mts → db-sign-gvrl0kFE-D-nTGx88.d.mts} +25 -9
  17. package/dist/db-sign-gvrl0kFE-D-nTGx88.d.mts.map +1 -0
  18. package/dist/migration-tools.d.mts +1 -1
  19. package/dist/migration-tools.mjs +1 -1
  20. package/dist/migration-tools__aggregate.d.mts +1 -1
  21. package/dist/migration-tools__aggregate.mjs +1 -1
  22. package/dist/{ref-BCcYHMHw-CY5QunMw.mjs → ref-DEiY2Cbd-Bt7yXfOO.mjs} +333 -85
  23. package/dist/ref-DEiY2Cbd-Bt7yXfOO.mjs.map +1 -0
  24. package/dist/vite-plugin-contract-emit.mjs +1 -1
  25. package/package.json +12 -12
  26. package/dist/aggregate-C30LiAd-.mjs.map +0 -1
  27. package/dist/aggregate-Da8PGnzg.d.mts.map +0 -1
  28. package/dist/caught-errors-Dijk7Hgg-DBua0IMw.mjs.map +0 -1
  29. package/dist/db-sign-DyugidHS-DGvMQ558.d.mts.map +0 -1
  30. package/dist/ref-BCcYHMHw-CY5QunMw.mjs.map +0 -1
package/dist/cli.mjs CHANGED
@@ -4,14 +4,14 @@ import { t as MigrationToolsError } from "./errors-DXha_4l--relAaiI4.mjs";
4
4
  import { t as contractSnapshotDir } from "./contract-snapshot-store-6gIBcUeb-DJK3OM0j.mjs";
5
5
  import { s as readMigrationsDir } from "./io-BNxFm3eg-DYD82QeZ.mjs";
6
6
  import { c as spaceMigrationDirectory, l as spaceRefsDirectory } from "./verify-contract-spaces-YzEHF9zj-DGZgox_3.mjs";
7
- import { $ as errorTargetMismatch, C as errorDatabaseConnectionRequired, D as errorHashMismatch, E as errorFromCaught, H as errorRuntime, M as errorMigrationPackageNotFound, P as errorNoMigrations, Q as errorTargetMigrationNotSupported, S as errorConvertAndDelete, T as errorFileNotFound, U as errorSignRefsNotWritten, Y as errorStatementNeedsMigrationFile, a as appRefsDirFor, b as errorContractConfigMissing, c as cliCommand, ct as redactUrlCredentials, d as closeQuietly, ft as runCommandAction, g as errorAdvanceRefArgConflict, gt as targetSupportsMigrations, ht as statementFlag, i as appMigrationsDirFor, it as migrationsDirFor, j as errorMarkerMissing, k as errorLegendHumanOnly, lt as requireLiveDatabase, m as displayPath, mt as shellQuoted, n as CliStructuredError$1$1, o as baseDirFor, ot as printedPlanCommand, p as contractPathFor, pt as selfEmitCommand, rt as maskConnectionUrl, s as chooseAction, st as readContractEnvelope, u as cliInvocation, v as errorConfigValidation$1, w as errorDriverRequired, x as errorContractValidationFailed, y as errorContractArgConflict } from "./caught-errors-Dijk7Hgg-DBua0IMw.mjs";
7
+ import { $ as errorTargetMigrationNotSupported, A as errorLegendHumanOnly, C as errorConvertAndDelete, D as errorFromCaught, E as errorFileNotFound, F as errorNoMigrations, M as errorMarkerMissing, N as errorMigrationPackageNotFound, O as errorHashMismatch, S as errorContractValidationFailed, T as errorDriverRequired, U as errorRuntime, W as errorSignRefsNotWritten, X as errorStatementNeedsMigrationFile, _t as targetSupportsMigrations, a as appRefsDirFor, at as migrationsDirFor, b as errorContractArgConflict, c as cliCommand, ct as readContractEnvelope, d as closeQuietly, et as errorTargetMismatch, g as errorAdvanceRefArgConflict, gt as statementFlag, ht as shellQuoted, i as appMigrationsDirFor, it as maskConnectionUrl, lt as redactUrlCredentials, m as displayPath, mt as selfEmitCommand, n as CliStructuredError$1$1, o as baseDirFor, p as contractPathFor, pt as runCommandAction, s as chooseAction, st as printedPlanCommand, u as cliInvocation, ut as requireLiveDatabase, v as errorConfigValidation$1, w as errorDatabaseConnectionRequired, x as errorContractConfigMissing, y as errorConsentUnused } from "./caught-errors-Bmbi1dBu-DKO5X2tN.mjs";
8
8
  import { r as getEmittedArtifactPaths } from "./exports-BCIlMjIW-DkUBVDzl.mjs";
9
9
  import { r as isInSpaceHistory } from "./graph-membership-DxpNgxfZ-BfqA-H7V.mjs";
10
10
  import { d as writeRef, r as readRef } from "./refs-DM3q3IZC-BC6H6P0X.mjs";
11
- import { a as contractHashAtMarker } from "./aggregate-C30LiAd-.mjs";
11
+ import { a as contractHashAtMarker } from "./aggregate-T_HG6gq6.mjs";
12
12
  import { i as createScaffoldSpecifierResolver } from "./import-roots-DXD7fung.mjs";
13
13
  import { o as isLiveMarkerRef } from "./ref-resolution-Eo0QHp4f.mjs";
14
- import { $ as refuseMissingInvariantPath, A as executeRefDeleteCommand, B as loadContractRawSafely, D as executeMigrationNewCommand, E as executeMigrateShowPlan, F as hasMigrationPath, G as mapContractAtError, H as loadContractSourceWithStack, I as isStatementVerb, J as preflightRefAdvancement, L as listRefsByContractHash, M as executeRefSetCommand, N as findPackageByDirPath, O as executeMigrationPlanCommand, P as formatSourceDiagnostic, Q as refuseMarkerOutsideGraph, R as liveMarkerUse, U as loadContractSpaceAggregateForCli, V as loadContractSource, W as looksLikePath, X as refuseContractSpaceIntegrity, Y as readMigrationRefs, _ as deriveStatusEdgeAnnotations, _t as toDeclaredExtensionsFromRaw, a as advanceRefSafely, at as resolveContractRefToSnapshot, b as enumerateCheckSpaces, d as buildRefAdvancementFields, et as refusePackageCorruptionOnAggregate, f as checkSingleTarget, ft as runMigrationCheck, g as createControlClient, gt as statusForMigrationHash, h as convertAndDelete, ht as sourceWarningDiagnostic, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as resolveContractRef$1, j as executeRefListCommand, l as buildMigrationSpaceGraphEntries, m as contractValidationMeta, mt as snapshotVerifierFor, n as NO_REF_ADVANCEMENT, nt as requireDatabaseForLiveMarkerUse, p as computeRefAdvancementName, pt as runMigrationList, q as migrationSpaceListEntriesFromAggregate, r as RECORDED_CONTRACT_REF_FORMS, rt as resolveAppTargetPath, s as appliedHashesFromLedger, st as resolveMigrationRef, t as ALL_CONTRACT_REF_FORMS, tt as refuseUnknownInvariants, u as buildReadAggregate, ut as retryCommandFor, vt as validateLoadedContract, x as executeContractEmit, z as loadAggregateIntegrityViolations } from "./ref-BCcYHMHw-CY5QunMw.mjs";
14
+ import { $ as refuseMarkerOutsideGraph, A as executeRefDeleteCommand, B as loadContractRawSafely, D as executeMigrationNewCommand, E as executeMigrateShowPlan, F as hasMigrationPath, G as mapContractAtError, H as loadContractSourceWithStack, I as isStatementVerb, J as migrationSpaceListEntriesFromAggregate, L as listRefsByContractHash, M as executeRefSetCommand, N as findPackageByDirPath, O as executeMigrationPlanCommand, P as formatSourceDiagnostic, R as liveMarkerUse, U as loadContractSpaceAggregateForCli, V as loadContractSource, W as looksLikePath, X as readMigrationRefs, Y as preflightRefAdvancement, Z as refuseContractSpaceIntegrity, _ as deriveStatusEdgeAnnotations, _t as statusForMigrationHash, a as advanceRefSafely, at as resolveContractRef$1, b as enumerateCheckSpaces, ct as resolveMigrationRef, d as buildRefAdvancementFields, dt as retryCommandFor, et as refuseMissingInvariantPath, f as checkSingleTarget, g as createControlClient, gt as sourceWarningDiagnostic, h as convertAndDelete, ht as snapshotVerifierFor, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as resolveAppTargetPath, j as executeRefListCommand, l as buildMigrationSpaceGraphEntries, m as contractValidationMeta, mt as runMigrationList, n as NO_REF_ADVANCEMENT, nt as refuseUnknownInvariants, ot as resolveContractRefToSnapshot, p as computeRefAdvancementName, pt as runMigrationCheck, q as matchConsents, r as RECORDED_CONTRACT_REF_FORMS, rt as requireDatabaseForLiveMarkerUse, s as appliedHashesFromLedger, t as ALL_CONTRACT_REF_FORMS, tt as refusePackageCorruptionOnAggregate, u as buildReadAggregate, vt as toDeclaredExtensionsFromRaw, x as executeContractEmit, yt as validateLoadedContract, z as loadAggregateIntegrityViolations } from "./ref-DEiY2Cbd-Bt7yXfOO.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 { createRequire } from "node:module";
17
17
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
@@ -40,7 +40,7 @@ import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
40
40
  import stringWidth from "string-width";
41
41
  import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
42
42
  import { build } from "esbuild";
43
- //#region ../../../1-framework/3-tooling/cli/dist/load-config-sbrxCnAP.mjs
43
+ //#region ../../../1-framework/3-tooling/cli/dist/load-config-8vRcnzNe.mjs
44
44
  /**
45
45
  * `isStructuredError` is the repo's own check, and it is the one that matters here: it holds the
46
46
  * regular expression for a dotted `NAMESPACE.SUBCODE`, so only a code the protocol accepts
@@ -936,15 +936,28 @@ function applySummaryText(result) {
936
936
  if (executed === 0) return `Database already matches contract${across}`;
937
937
  return `Applied ${executed} operation(s)${across}`;
938
938
  }
939
+ /** For each namespace the plan removes, the answers that answer all of its questions. */
940
+ function namespaceAnswerLines(result) {
941
+ const added = result.addedNamespaces ?? [];
942
+ return (result.removedNamespaces ?? []).map(({ namespaceId, answeredBy }) => {
943
+ return { label: `every question about namespace "${namespaceId}": ${statementFlag({
944
+ verb: "delete",
945
+ text: namespaceId
946
+ })}${added.length === 0 ? "" : `, or ${added.map((target) => statementFlag({
947
+ verb: "rename",
948
+ text: `${namespaceId}:${target}`
949
+ })).join(" or ")} if it was renamed`}${answeredBy === void 0 ? "" : " (answered)"}` };
950
+ });
951
+ }
939
952
  /**
940
953
  * The questions an apply would ask, as a dry run lists them: each operation that would lose data,
941
- * answered by `--delete` or `--rename`, and each that would widen access, answered by `--allow`.
954
+ * answered by `--delete` or `--rename`, and each that would change access, answered by `--allow`.
942
955
  */
943
956
  function questionBlocks(result) {
944
957
  const entries = [...(result.dataLoss ?? []).map((entry) => ({
945
958
  entry,
946
959
  verb: "delete"
947
- })), ...(result.accessWidening ?? []).map((entry) => ({
960
+ })), ...(result.accessChanges ?? []).map((entry) => ({
948
961
  entry,
949
962
  verb: "allow"
950
963
  }))];
@@ -953,10 +966,10 @@ function questionBlocks(result) {
953
966
  kind: "tree",
954
967
  roots: [{
955
968
  label: "An apply asks about",
956
- children: entries.map(({ entry, verb }) => ({ label: `${result.plan.operations[entry.operationIndex]?.label ?? "an operation"}: ${statementFlag({
969
+ children: [...entries.map(({ entry, verb }) => ({ label: `${result.plan.operations[entry.operationIndex]?.label ?? "an operation"}: ${statementFlag({
957
970
  verb,
958
971
  text: entry.text
959
- })}${entry.answered ? " (answered)" : ""}` }))
972
+ })}${entry.answered ? " (answered)" : ""}` })), ...namespaceAnswerLines(result)]
960
973
  }]
961
974
  }];
962
975
  }
@@ -2089,22 +2102,113 @@ function createDbSignCommand(createClient = createControlClient) {
2089
2102
  }
2090
2103
  const dbSignCommand = createDbSignCommand();
2091
2104
  /**
2092
- * Asks a plan's questions through the engine's statement prompt, all in one batch that refuses a
2093
- * statement nothing consumed before the command acts. Flags answer first; where nobody can answer,
2094
- * the engine refuses and lists every question.
2105
+ * The answers the `--delete` values give when one of them names a namespace of the questions: the
2106
+ * engine answers a question only with a value equal to its subject, one value per question, so a
2107
+ * namespace that answers every question about its models is matched here. The values are taken
2108
+ * from the engine; `undefined` leaves them to it.
2109
+ */
2110
+ function namespaceDeletes(questions, statements) {
2111
+ const deletes = statements.values().filter(({ verb }) => verb === "delete");
2112
+ const removed = new Set(questions.flatMap(({ removedNamespace }) => removedNamespace ?? []));
2113
+ if (!deletes.some(({ text }) => removed.has(text))) return void 0;
2114
+ const taken = statements.take("delete").map(({ text }) => text);
2115
+ const deletable = questions.map((question, index) => ({
2116
+ question,
2117
+ index
2118
+ })).filter(({ question }) => question.verbs.includes("delete"));
2119
+ const matched = matchConsents("delete", deletable.map(({ question }) => ({
2120
+ text: question.subject,
2121
+ removedNamespace: question.removedNamespace
2122
+ })), taken);
2123
+ if (matched.unused.length > 0) throw errorConsentUnused(matched.unused, questions.map(({ subject }) => subject));
2124
+ const answered = /* @__PURE__ */ new Map();
2125
+ for (const [position] of matched.answered) {
2126
+ const entry = deletable[position];
2127
+ if (entry !== void 0) answered.set(entry.index, {
2128
+ verb: "delete",
2129
+ text: entry.question.subject
2130
+ });
2131
+ }
2132
+ return answered;
2133
+ }
2134
+ function engineQuestion(question) {
2135
+ return {
2136
+ question: question.question,
2137
+ subject: question.subject,
2138
+ verbs: question.verbs,
2139
+ forms: question.forms,
2140
+ validate: question.validate
2141
+ };
2142
+ }
2143
+ /** Whether an answer is the namespace's own: a `delete` of it, or a `rename` of it. */
2144
+ function isConsentRequired(error) {
2145
+ return typeof error === "object" && error !== null && "code" in error && error.code === "CLI.CONSENT_REQUIRED";
2146
+ }
2147
+ /**
2148
+ * Asks the questions one at a time, so a `delete` typed for a namespace the destination removed
2149
+ * answers the rest of that namespace's questions without asking them. A `rename` of the namespace
2150
+ * answers only its own question and leaves the rest open: the command plans again with it and asks
2151
+ * what is left, such as a model of the namespace that also changed its name. When nobody can
2152
+ * answer a question, the engine is asked every question still open at once, so its refusal names
2153
+ * them all.
2154
+ */
2155
+ async function askOneAtATime(prompt, asked) {
2156
+ const answered = /* @__PURE__ */ new Map();
2157
+ const namespaceDeleted = /* @__PURE__ */ new Map();
2158
+ const namespaceRenamed = /* @__PURE__ */ new Set();
2159
+ for (const [position, { question, index }] of asked.entries()) {
2160
+ const { removedNamespace } = question;
2161
+ if (removedNamespace !== void 0 && namespaceRenamed.has(removedNamespace)) continue;
2162
+ const deleted = removedNamespace === void 0 ? void 0 : namespaceDeleted.get(removedNamespace);
2163
+ if (deleted !== void 0) {
2164
+ answered.set(index, deleted);
2165
+ continue;
2166
+ }
2167
+ const [typed] = await prompt.statements([engineQuestion(question)]).catch(async (error) => {
2168
+ if (!isConsentRequired(error)) throw error;
2169
+ await prompt.statements(asked.slice(position).map(({ question: open }) => engineQuestion(open)), { last: true });
2170
+ throw error;
2171
+ });
2172
+ if (typed === void 0) continue;
2173
+ const answer = {
2174
+ verb: typed.verb,
2175
+ text: typed.text
2176
+ };
2177
+ answered.set(index, answer);
2178
+ const ofNamespace = question.namespaceAnswer?.(answer.verb, answer.text);
2179
+ if (removedNamespace !== void 0 && ofNamespace === "delete") namespaceDeleted.set(removedNamespace, answer);
2180
+ if (removedNamespace !== void 0 && ofNamespace === "rename") namespaceRenamed.add(removedNamespace);
2181
+ }
2182
+ await prompt.statements([], { last: true });
2183
+ return answered;
2184
+ }
2185
+ /**
2186
+ * Asks a plan's questions through the engine's statement prompt. Flags answer first; where nobody
2187
+ * can answer, the engine refuses and lists every question. A `--delete` that names a namespace
2188
+ * answers every question about a model or field of it, and so does a `delete` of the namespace
2189
+ * typed at the prompt; a typed `rename` of it plans again before the rest are asked. Without such a namespace, the questions are asked in one batch
2190
+ * that refuses a statement nothing consumed before the command acts.
2095
2191
  */
2096
- function promptPlanQuestions(prompt) {
2192
+ function promptPlanQuestions(prompt, statements) {
2097
2193
  return async (questions) => {
2098
- return (await prompt.statements(questions.map((question) => ({
2099
- question: question.question,
2100
- subject: question.subject,
2101
- verbs: question.verbs,
2102
- forms: question.forms,
2103
- validate: question.validate
2104
- })), { last: true })).map(({ verb, text }) => ({
2105
- verb,
2106
- text
2107
- }));
2194
+ const answered = namespaceDeletes(questions, statements) ?? /* @__PURE__ */ new Map();
2195
+ const asked = questions.map((question, index) => ({
2196
+ question,
2197
+ index
2198
+ })).filter(({ index }) => !answered.has(index));
2199
+ const byIndex = new Map(answered);
2200
+ if (asked.some(({ question }) => question.removedNamespace !== void 0)) for (const [index, answer] of await askOneAtATime(prompt, asked)) byIndex.set(index, answer);
2201
+ else {
2202
+ const answers = await prompt.statements(asked.map(({ question }) => engineQuestion(question)), { last: true });
2203
+ asked.forEach(({ index }, position) => {
2204
+ const answer = answers[position];
2205
+ if (answer !== void 0) byIndex.set(index, {
2206
+ verb: answer.verb,
2207
+ text: answer.text
2208
+ });
2209
+ });
2210
+ }
2211
+ return questions.map((_, index) => byIndex.get(index));
2108
2212
  };
2109
2213
  }
2110
2214
  const verbs = {
@@ -2118,7 +2222,7 @@ const verbs = {
2118
2222
  },
2119
2223
  allow: {
2120
2224
  arity: 1,
2121
- brief: "Let the command widen who can read or write the rows of a model: --allow Model"
2225
+ brief: "Let the command change who can read or write a model's data: --allow Model"
2122
2226
  },
2123
2227
  convert: {
2124
2228
  arity: 1,
@@ -2189,25 +2293,43 @@ function updatePresentations(inputs) {
2189
2293
  }
2190
2294
  /**
2191
2295
  * Whether a flag the run was given answers each entry's question: a `--delete` answers every loss
2192
- * of its subject, and an `--allow` one operation, in order.
2296
+ * of its subject, or of every subject in the namespace it names, and an `--allow` one operation, in
2297
+ * order.
2193
2298
  */
2194
2299
  function answeredByFlags(entries, verb, given) {
2195
- const flagsLeft = /* @__PURE__ */ new Map();
2196
- for (const statement of given) if (statement.verb === verb) flagsLeft.set(statement.text, (flagsLeft.get(statement.text) ?? 0) + 1);
2197
- return entries.map((entry) => {
2198
- const left = flagsLeft.get(entry.text) ?? 0;
2199
- if (left > 0 && verb === "allow") flagsLeft.set(entry.text, left - 1);
2200
- return left > 0;
2300
+ const matched = matchConsents(verb, entries.map(({ text, removedNamespace }) => ({
2301
+ text,
2302
+ removedNamespace
2303
+ })), given.filter((statement) => statement.verb === verb).map(({ text }) => text));
2304
+ return entries.map((_, index) => {
2305
+ const text = matched.answered.get(index);
2306
+ return text === void 0 ? void 0 : {
2307
+ verb,
2308
+ text
2309
+ };
2201
2310
  });
2202
2311
  }
2203
- function subjectEntryJson(entry, answered) {
2312
+ function subjectEntryJson(entry, answeredBy) {
2204
2313
  return {
2205
2314
  operationIndex: entry.operationIndex,
2206
2315
  subject: migrationSubjectJson(entry.subject),
2207
2316
  text: entry.text,
2208
- answered: answered === true
2317
+ answered: answeredBy !== void 0,
2318
+ ...ifDefined("answeredBy", answeredBy),
2319
+ ...ifDefined("removedNamespace", entry.removedNamespace)
2209
2320
  };
2210
2321
  }
2322
+ /** The namespaces the plan removes, each with the `--delete` of it that answers its questions, if one does. */
2323
+ function removedNamespacesJson(value, given) {
2324
+ const answered = answeredByFlags(value.dataLoss, "delete", given);
2325
+ return (value.namespaces?.removed ?? []).map((namespaceId) => ({
2326
+ namespaceId,
2327
+ ...ifDefined("answeredBy", answered.some((statement) => statement?.text === namespaceId) ? {
2328
+ verb: "delete",
2329
+ text: namespaceId
2330
+ } : void 0)
2331
+ }));
2332
+ }
2211
2333
  /** The data-loss entries a dry run lists, each with how it loses data and whether a flag answers it. */
2212
2334
  function dataLossEntriesJson(entries, given) {
2213
2335
  const answered = answeredByFlags(entries, "delete", given);
@@ -2252,7 +2374,9 @@ function updateDocument(inputs) {
2252
2374
  temporaryValues: value.temporaryValues,
2253
2375
  ...value.mode === "plan" ? {
2254
2376
  dataLoss: dataLossEntriesJson(value.dataLoss, inputs.statements),
2255
- accessWidening: accessEntriesJson(value.accessWidening, inputs.statements)
2377
+ accessChanges: accessEntriesJson(value.accessChanges, inputs.statements),
2378
+ removedNamespaces: removedNamespacesJson(value, inputs.statements),
2379
+ addedNamespaces: value.namespaces?.added ?? []
2256
2380
  } : {},
2257
2381
  ...inputs.plannerWarnings.length > 0 ? { warnings: inputs.plannerWarnings } : {},
2258
2382
  advancedRef: inputs.advancedRef,
@@ -2272,7 +2396,7 @@ function createDbUpdateCommand(createClient) {
2272
2396
  return defineOrmCommand({
2273
2397
  help: {
2274
2398
  summary: "Update your database schema to match your contract",
2275
- description: "Compares the database to the emitted contract and applies the changes that\nclose the gap, whether or not the database was bootstrapped with `db init`.\nBefore it applies an operation that would lose data, it asks what the\noperation means: --rename keeps the data under a new name, --delete lets it\ngo. Before it widens who can read or write rows, it asks for --allow. Where\nnobody can answer, it refuses and lists every question. Use --dry-run to see\nthe operations and the questions without applying anything.",
2399
+ description: "Compares the database to the emitted contract and applies the changes that\nclose the gap, whether or not the database was bootstrapped with `db init`.\nBefore it applies an operation that would lose data, it asks what the\noperation means: --rename keeps the data under a new name, --delete lets it\ngo. Before it changes who can read or write a model's data, it asks for\n--allow. Where nobody can answer, it refuses and lists every question. Use\n--dry-run to see the operations and the questions without applying anything.",
2276
2400
  examples: [
2277
2401
  "db update",
2278
2402
  "db update --dry-run",
@@ -2381,13 +2505,25 @@ function createDbUpdateCommand(createClient) {
2381
2505
  try {
2382
2506
  await client.connect(dbConnection);
2383
2507
  const plannerWarnings = plannerWarningsCollector(ctx.report);
2508
+ const rerunArgs = [
2509
+ ...args.flags.to === void 0 ? [] : ["--to", shellQuoted(args.flags.to)],
2510
+ ...args.flags.advanceRef === void 0 ? [] : ["--advance-ref", shellQuoted(args.flags.advanceRef)],
2511
+ ...[
2512
+ ...renames,
2513
+ ...previewConsents,
2514
+ ...unansweredConsents(ctx.statements)
2515
+ ].map(statementFlag)
2516
+ ];
2384
2517
  const result = await client.dbUpdate({
2385
2518
  contract: contractJson,
2386
2519
  mode,
2387
2520
  migrationsDir,
2388
2521
  statements: [...renames, ...previewConsents],
2389
- answerQuestions: promptPlanQuestions(ctx.prompt),
2390
- invocation: cliInvocation(ctx, args.flags.db),
2522
+ answerQuestions: promptPlanQuestions(ctx.prompt, ctx.statements),
2523
+ invocation: {
2524
+ ...cliInvocation(ctx, args.flags.db),
2525
+ rerunArgs
2526
+ },
2391
2527
  onPlannerWarnings: plannerWarnings.onPlannerWarnings,
2392
2528
  onProgress: controlProgressReporter(ctx.report)
2393
2529
  });
@@ -9500,7 +9636,10 @@ function createMigrateCommand(createClient) {
9500
9636
  const applied = await client.migrate({
9501
9637
  contract: applyContract,
9502
9638
  migrationsDir,
9503
- invocation: cliInvocation(ctx, args.flags.db),
9639
+ invocation: {
9640
+ ...cliInvocation(ctx, args.flags.db),
9641
+ rerunArgs: [...args.flags.to === void 0 ? [] : ["--to", shellQuoted(args.flags.to)], ...args.flags.advanceRef === void 0 ? [] : ["--advance-ref", shellQuoted(args.flags.advanceRef)]]
9642
+ },
9504
9643
  onProgress: controlProgressReporter(ctx.report),
9505
9644
  ...ifDefined("refHash", refEntry?.hash),
9506
9645
  ...refEntry?.invariants === void 0 ? {} : { refInvariants: refEntry.invariants },
@@ -10603,7 +10742,7 @@ function createMigrationPlanCommand(createClient) {
10603
10742
  verb,
10604
10743
  text
10605
10744
  }))),
10606
- answerQuestions: promptPlanQuestions(ctx.prompt),
10745
+ answerQuestions: promptPlanQuestions(ctx.prompt, ctx.statements),
10607
10746
  client: createClient({
10608
10747
  family: ctx.config.family,
10609
10748
  target: ctx.config.target,
@@ -11548,6 +11687,36 @@ const ormCommandFamily = defineCommandFamily({
11548
11687
  flag: "ref",
11549
11688
  replacement: "{bin} migration status --to <contract>",
11550
11689
  reason: "One flag names the target contract, whether it is a ref, a hash or a migration."
11690
+ },
11691
+ {
11692
+ from: "migrate dev",
11693
+ replacement: "{bin} contract emit",
11694
+ 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."
11695
+ },
11696
+ {
11697
+ from: "migrate deploy",
11698
+ replacement: "{bin} db migrate",
11699
+ 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."
11700
+ },
11701
+ {
11702
+ from: "migrate status",
11703
+ replacement: "{bin} migration status",
11704
+ 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."
11705
+ },
11706
+ {
11707
+ from: "migrate diff",
11708
+ replacement: "{bin} db update --dry-run",
11709
+ 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`."
11710
+ },
11711
+ {
11712
+ from: "migrate reset",
11713
+ replacement: "{bin} db migrate",
11714
+ reason: "Prisma 8 never drops a database: drop and recreate it with your database's own tools, then `db migrate` applies every migration; while Prisma 7 still owns this project's migrations, run `migrate reset` with Prisma 7's CLI instead."
11715
+ },
11716
+ {
11717
+ from: "migrate resolve",
11718
+ replacement: "{bin} db sign <migration>",
11719
+ 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."
11551
11720
  }
11552
11721
  ]
11553
11722
  });