@prisma/orm-toolchain 8.0.0-rc.11-dev.39 → 8.0.0-rc.11-dev.41
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/{aggregate-DKBycuzO.d.mts → aggregate-BxeUZtei.d.mts} +14 -4
- package/dist/aggregate-BxeUZtei.d.mts.map +1 -0
- package/dist/{aggregate-DI9VS7yL.mjs → aggregate-DqY54LCk.mjs} +43 -31
- package/dist/aggregate-DqY54LCk.mjs.map +1 -0
- package/dist/cli.mjs +87 -32
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +75 -6
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/cli__control-api__testing.d.mts +1 -1
- package/dist/cli__migration-cli.mjs +2 -2
- package/dist/contract-snapshot-store-Bok5nQYi-D3g_P7im.d.mts +59 -0
- package/dist/contract-snapshot-store-Bok5nQYi-D3g_P7im.d.mts.map +1 -0
- package/dist/{contract-snapshot-store-D-mFkiHR-CFl0ulR2.mjs → contract-snapshot-store-CM9ubenX-o8kTVHxP.mjs} +48 -11
- package/dist/contract-snapshot-store-CM9ubenX-o8kTVHxP.mjs.map +1 -0
- package/dist/contract-snapshot-store-DrIwu5pn.d.mts +2 -0
- package/dist/{db-verify-BdKY7U7l-6VLIVuKF.d.mts → db-verify-BkwsVjIf-CDWnVSjr.d.mts} +6 -2
- package/dist/db-verify-BkwsVjIf-CDWnVSjr.d.mts.map +1 -0
- package/dist/{errors-SoLLYLtw-DMxVbVs9.mjs → errors-BIroGS9E-Dg6CF-dm.mjs} +15 -3
- package/dist/{errors-SoLLYLtw-DMxVbVs9.mjs.map → errors-BIroGS9E-Dg6CF-dm.mjs.map} +1 -1
- package/dist/{graph-membership-DY1Onbc3-CwBd6wuB.mjs → graph-membership-CdU6royq-gP9Kb9Eh.mjs} +3 -3
- package/dist/{graph-membership-DY1Onbc3-CwBd6wuB.mjs.map → graph-membership-CdU6royq-gP9Kb9Eh.mjs.map} +1 -1
- package/dist/{hash-DH8hl5Rq-BpM2t3Nu.mjs → hash-BAZVWU4a-BdynTmar.mjs} +24 -3
- package/dist/hash-BAZVWU4a-BdynTmar.mjs.map +1 -0
- package/dist/hash-CwWGlFWV.d.mts +1 -0
- package/dist/{hash-XZYYKJ-i.d.mts → hash-DclMqd7S-WBvXJ_4C.d.mts} +17 -4
- package/dist/hash-DclMqd7S-WBvXJ_4C.d.mts.map +1 -0
- package/dist/{invariants-Cww4bv0v-BEiFxmbX.mjs → invariants-CUbFGAse-DqgE4fhO.mjs} +3 -3
- package/dist/{invariants-Cww4bv0v-BEiFxmbX.mjs.map → invariants-CUbFGAse-DqgE4fhO.mjs.map} +1 -1
- package/dist/{io-DSQXOfBH-GRpmFG2F.mjs → io-CyV6U3am-CMJIi_UO.mjs} +7 -7
- package/dist/io-CyV6U3am-CMJIi_UO.mjs.map +1 -0
- package/dist/io-D8Epu7iY.d.mts +1 -0
- package/dist/{io-sr4CO9_t-C3eV_kn-.d.mts → io-DZfMV51z-BKlH5Dhb.d.mts} +9 -2
- package/dist/io-DZfMV51z-BKlH5Dhb.d.mts.map +1 -0
- package/dist/{migration-B9w-7dKe.mjs → migration-D95UJ0Dj.mjs} +4 -4
- package/dist/{migration-B9w-7dKe.mjs.map → migration-D95UJ0Dj.mjs.map} +1 -1
- package/dist/{migration-graph-CW4bMmTz-B5xFtFVB.mjs → migration-graph-BBWEuNAt-C6X6rauo.mjs} +3 -3
- package/dist/{migration-graph-CW4bMmTz-B5xFtFVB.mjs.map → migration-graph-BBWEuNAt-C6X6rauo.mjs.map} +1 -1
- package/dist/{migration-graph-Dqndu0i5.d.mts → migration-graph-CHhNBJSJ.d.mts} +2 -2
- package/dist/{migration-graph-Dqndu0i5.d.mts.map → migration-graph-CHhNBJSJ.d.mts.map} +1 -1
- package/dist/{migration-graph-tarTxJ99-BrGBANeE.d.mts → migration-graph-tarTxJ99-2GNs0O8U.d.mts} +2 -2
- package/dist/{migration-graph-tarTxJ99-BrGBANeE.d.mts.map → migration-graph-tarTxJ99-2GNs0O8U.d.mts.map} +1 -1
- package/dist/migration-tools.d.mts +12 -10
- package/dist/migration-tools.mjs +14 -14
- package/dist/migration-tools__aggregate.d.mts +1 -1
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__contract-snapshot-store.d.mts +4 -2
- package/dist/migration-tools__contract-snapshot-store.mjs +2 -2
- package/dist/migration-tools__errors.mjs +1 -1
- package/dist/migration-tools__hash.d.mts +2 -1
- package/dist/migration-tools__hash.mjs +1 -1
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.d.mts +2 -2
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.d.mts +2 -2
- package/dist/migration-tools__migration-graph.mjs +2 -2
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/{ref-DlKsxbtg-B55l0TCq.mjs → ref-D5u8Xxwc-BjjqYtnQ.mjs} +212 -48
- package/dist/ref-D5u8Xxwc-BjjqYtnQ.mjs.map +1 -0
- package/dist/{ref-resolution-BWpwb8_b.mjs → ref-resolution-BwWLoU7C.mjs} +2 -2
- package/dist/{ref-resolution-BWpwb8_b.mjs.map → ref-resolution-BwWLoU7C.mjs.map} +1 -1
- package/dist/{refs-BpSpzdYB-BcDelHGt.mjs → refs-S0wu2JkI-BbFdehLe.mjs} +3 -3
- package/dist/{refs-BpSpzdYB-BcDelHGt.mjs.map → refs-S0wu2JkI-BbFdehLe.mjs.map} +1 -1
- package/dist/{spaces-DzFtKEl3.mjs → spaces--kxjIRHx.mjs} +14 -13
- package/dist/spaces--kxjIRHx.mjs.map +1 -0
- package/dist/{verify-contract-spaces-_vwt5LT0-BQAf8Q4T.mjs → verify-contract-spaces-BLkC9r9l-CJIppNL8.mjs} +4 -4
- package/dist/{verify-contract-spaces-_vwt5LT0-BQAf8Q4T.mjs.map → verify-contract-spaces-BLkC9r9l-CJIppNL8.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +1 -1
- package/package.json +12 -12
- package/dist/aggregate-DI9VS7yL.mjs.map +0 -1
- package/dist/aggregate-DKBycuzO.d.mts.map +0 -1
- package/dist/contract-snapshot-store-BqDMcO4r.d.mts +0 -27
- package/dist/contract-snapshot-store-BqDMcO4r.d.mts.map +0 -1
- package/dist/contract-snapshot-store-D-mFkiHR-CFl0ulR2.mjs.map +0 -1
- package/dist/db-verify-BdKY7U7l-6VLIVuKF.d.mts.map +0 -1
- package/dist/hash-DH8hl5Rq-BpM2t3Nu.mjs.map +0 -1
- package/dist/hash-XZYYKJ-i.d.mts.map +0 -1
- package/dist/io-DSQXOfBH-GRpmFG2F.mjs.map +0 -1
- package/dist/io-DYfeLJxR.d.mts +0 -1
- package/dist/io-sr4CO9_t-C3eV_kn-.d.mts.map +0 -1
- package/dist/ref-DlKsxbtg-B55l0TCq.mjs.map +0 -1
- package/dist/spaces-DzFtKEl3.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { r as getEmittedArtifactPaths } from "./exports-DI1kMms6--e9LdT9A.mjs";
|
|
2
|
-
import { t as MigrationToolsError } from "./errors-
|
|
3
|
-
import { t as contractSnapshotDir } from "./contract-snapshot-store-
|
|
2
|
+
import { t as MigrationToolsError } from "./errors-BIroGS9E-Dg6CF-dm.mjs";
|
|
3
|
+
import { t as contractSnapshotDir } from "./contract-snapshot-store-CM9ubenX-o8kTVHxP.mjs";
|
|
4
4
|
import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
|
|
5
|
-
import { r as readRef } from "./refs-
|
|
6
|
-
import { c as spaceMigrationDirectory } from "./verify-contract-spaces-
|
|
5
|
+
import { r as readRef } from "./refs-S0wu2JkI-BbFdehLe.mjs";
|
|
6
|
+
import { c as spaceMigrationDirectory } from "./verify-contract-spaces-BLkC9r9l-CJIppNL8.mjs";
|
|
7
7
|
import { i as createScaffoldSpecifierResolver } from "./import-roots-CCyOuQxb.mjs";
|
|
8
|
-
import { $ as
|
|
8
|
+
import { $ as hasMigrationPath, A as errorLegendHumanOnly, At as runMigrationList, B as errorUnexpected, C as errorContractArgConflict, Ct as resolveContractRefToSnapshot, D as errorDriverRequired, Dt as runCommandAction, E as errorDestructiveChanges, F as errorPathUnreachable, Ft as toDeclaredExtensionsFromRaw, G as executeMigrateShowPlan, I as errorRunnerFailed, K as executeMigrationNewCommand, L as errorRuntime, M as errorMigrationPackageNotFound, Mt as snapshotVerifierFor, N as errorMigrationPlanningFailed, Nt as statusForMigrationHash, O as errorFileNotFound, P as errorNoMigrations, Pt as targetSupportsMigrations, Q as findPackageByDirPath, R as errorTargetMigrationNotSupported, S as errorConsentPlanMismatch, St as resolveContractRef$1, T as errorDatabaseConnectionRequired, Tt as resolveMigrationRef, V as executeContractEmit, X as executeRefListCommand, Y as executeRefDeleteCommand, Z as executeRefSetCommand, _t as refuseMissingInvariantPath, at as mapCaughtMigrationError, b as errorAdvanceRefArgConflict, bt as requireLiveDatabase, c as buildMigrationSpaceGraphEntries, ct as maskConnectionUrl, d as checkSingleTarget, dt as preflightRefAdvancement, et as listRefsByContractHash, f as chooseAction, ft as readContractEnvelope, g as deriveStatusEdgeAnnotations, gt as refuseMarkerOutsideGraph, h as createControlClient, i as advanceRefSafely, it as looksLikePath, j as errorMarkerMissing, jt as sanitizeErrorMessage, k as errorHashMismatch, kt as runMigrationCheck, l as buildReadAggregate, lt as migrationSpaceListEntriesFromAggregate, m as computeRefAdvancementName, mt as refuseContractSpaceIntegrity, n as ERROR_CODE_DESTRUCTIVE_CHANGES, nt as loadContractRawSafely, o as appliedHashesFromLedger, ot as mapContractAtError, p as closeQuietly, pt as readMigrationRefs, q as executeMigrationPlanCommand, r as NO_REF_ADVANCEMENT, rt as loadContractSpaceAggregateForCli, t as CliStructuredError$1$1, tt as loadAggregateIntegrityViolations, u as buildRefAdvancementFields, ut as originHashForStatus, vt as refusePackageCorruptionOnAggregate, w as errorContractValidationFailed, x as errorConfigValidation$1, xt as resolveAppTargetPath, y as enumerateCheckSpaces, yt as refuseUnknownInvariants, z as errorTargetMismatch } from "./ref-D5u8Xxwc-BjjqYtnQ.mjs";
|
|
9
9
|
import { n as buildNextSteps, t as InitOutputSchema } from "./output-D83nTTpC-XlvN30yS.mjs";
|
|
10
10
|
import { r as loadConfig, t as finalizeConfig } from "./exports-DJ4RhlW4.mjs";
|
|
11
11
|
import { createRequire } from "node:module";
|
|
@@ -36,7 +36,7 @@ import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
|
|
|
36
36
|
import stringWidth from "string-width";
|
|
37
37
|
import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
|
|
38
38
|
import { build } from "esbuild";
|
|
39
|
-
//#region ../../../1-framework/3-tooling/cli/dist/load-config-
|
|
39
|
+
//#region ../../../1-framework/3-tooling/cli/dist/load-config-CIO302MA.mjs
|
|
40
40
|
const MISSING_CONFIG_ACTION = {
|
|
41
41
|
kind: "run-command",
|
|
42
42
|
label: "Create a config file",
|
|
@@ -1853,20 +1853,23 @@ function errorConsentTokenUnresolved(targetId) {
|
|
|
1853
1853
|
});
|
|
1854
1854
|
}
|
|
1855
1855
|
/** A prompt that names nothing cannot be consented to knowingly. */
|
|
1856
|
-
function errorConsentOperationsMissing() {
|
|
1856
|
+
function errorConsentOperationsMissing(options) {
|
|
1857
1857
|
return new CliStructuredError$1("CLI.CONSENT_OPERATIONS_MISSING", "The plan was refused as destructive but named no operations to confirm.", {
|
|
1858
1858
|
why: "The consent prompt has to list what is about to be destroyed, and the refusal carried no operations to list.",
|
|
1859
1859
|
nextActions: [{
|
|
1860
1860
|
kind: "run-command",
|
|
1861
1861
|
label: "Preview the plan",
|
|
1862
|
-
command: "{bin} db update --dry-run"
|
|
1862
|
+
command: options?.previewCommand ?? "{bin} db update --dry-run"
|
|
1863
1863
|
}]
|
|
1864
1864
|
});
|
|
1865
1865
|
}
|
|
1866
|
+
/** The indented per-operation list every destructive-consent question renders. */
|
|
1867
|
+
function destructiveOperationList(operations) {
|
|
1868
|
+
return operations.map((operation) => ` - ${operation.label}`).join("\n");
|
|
1869
|
+
}
|
|
1866
1870
|
/** The question the user answers before anything is dropped. */
|
|
1867
1871
|
function destructiveConsentQuestion(operations, token) {
|
|
1868
|
-
|
|
1869
|
-
return [`Apply ${operations.length} destructive operation(s) to ${token}? Data they remove cannot be recovered:`, listed].join("\n");
|
|
1872
|
+
return [`Apply ${operations.length} destructive operation(s) to ${token}? Data they remove cannot be recovered:`, destructiveOperationList(operations)].join("\n");
|
|
1870
1873
|
}
|
|
1871
1874
|
function updatePresentations(inputs) {
|
|
1872
1875
|
const { document, database, dryRun } = inputs;
|
|
@@ -7600,7 +7603,8 @@ function createMigrateCommand(createClient) {
|
|
|
7600
7603
|
migrationsDir,
|
|
7601
7604
|
appContract,
|
|
7602
7605
|
extensions: ctx.config.extensions ?? [],
|
|
7603
|
-
deserializeContract: (json) => familyInstance.deserializeContract(json)
|
|
7606
|
+
deserializeContract: (json) => familyInstance.deserializeContract(json),
|
|
7607
|
+
...ifDefined("verifySnapshotContent", snapshotVerifierFor(ctx.config))
|
|
7604
7608
|
});
|
|
7605
7609
|
if (!loaded.ok) return notOk$1(normalizeError(loaded.failure));
|
|
7606
7610
|
const aggregate = loaded.value;
|
|
@@ -7919,9 +7923,13 @@ const migrationCheckCommand = defineOrmCommand({
|
|
|
7919
7923
|
const migrationsDir = migrationsDirFor(ctx.config, ctx.cwd);
|
|
7920
7924
|
const appMigrationsDir = appMigrationsDirFor(ctx.config, ctx.cwd);
|
|
7921
7925
|
const appMigrationsRelative = displayPath(appMigrationsDir, ctx.cwd);
|
|
7922
|
-
const
|
|
7926
|
+
const verifySnapshotContent = snapshotVerifierFor(ctx.config);
|
|
7927
|
+
const loaded = await buildReadAggregate(ctx.config, {
|
|
7928
|
+
migrationsDir,
|
|
7929
|
+
...ifDefined("verifySnapshotContent", verifySnapshotContent)
|
|
7930
|
+
});
|
|
7923
7931
|
if (!loaded.ok) return notOk$1(normalizeError(loaded.failure));
|
|
7924
|
-
const spaces = await enumerateCheckSpaces(loaded.value.aggregate, migrationsDir, ctx.cwd);
|
|
7932
|
+
const spaces = await enumerateCheckSpaces(loaded.value.aggregate, migrationsDir, ctx.cwd, verifySnapshotContent);
|
|
7925
7933
|
let document;
|
|
7926
7934
|
let resolvedSpaceId;
|
|
7927
7935
|
if (target !== void 0) {
|
|
@@ -7943,7 +7951,7 @@ const migrationCheckCommand = defineOrmCommand({
|
|
|
7943
7951
|
...ifDefined("spaceFilter", spaceFilter)
|
|
7944
7952
|
});
|
|
7945
7953
|
if (!checked.ok) return notOk$1(normalizeError(checked.failure));
|
|
7946
|
-
const violations = await loadAggregateIntegrityViolations(ctx.config, migrationsDir);
|
|
7954
|
+
const violations = await loadAggregateIntegrityViolations(ctx.config, migrationsDir, verifySnapshotContent);
|
|
7947
7955
|
const scoped = spaceFilter === void 0 ? violations : violations.filter((violation) => violation.kind !== "disjointness" && violation.spaceId === spaceFilter);
|
|
7948
7956
|
const failures = [...checked.value.failures, ...scoped.map((violation) => integrityViolationToCheckFailure(violation, migrationsDir))];
|
|
7949
7957
|
document = failures.length === 0 ? {
|
|
@@ -8521,21 +8529,34 @@ function outcomeFields(result, migrationsRelative) {
|
|
|
8521
8529
|
]
|
|
8522
8530
|
};
|
|
8523
8531
|
}
|
|
8524
|
-
function operationNodes$1(
|
|
8525
|
-
return
|
|
8532
|
+
function operationNodes$1(operations) {
|
|
8533
|
+
return operations.map((operation) => operation.operationClass === "destructive" ? {
|
|
8526
8534
|
label: operation.label,
|
|
8527
8535
|
status: "warn"
|
|
8528
8536
|
} : { label: operation.label });
|
|
8529
8537
|
}
|
|
8538
|
+
/**
|
|
8539
|
+
* One tree root per written package: the auto-baseline package first (when
|
|
8540
|
+
* this run wrote one), then the app-space package. A baseline-only run has
|
|
8541
|
+
* no `dir`, so the app-space root falls back to `baselineDir`.
|
|
8542
|
+
*/
|
|
8543
|
+
function operationRoots(result) {
|
|
8544
|
+
const baselineOperations = result.baselineOperations ?? [];
|
|
8545
|
+
return [...baselineOperations.length > 0 && result.baselineDir !== void 0 ? [{
|
|
8546
|
+
label: result.baselineDir,
|
|
8547
|
+
children: operationNodes$1(baselineOperations)
|
|
8548
|
+
}] : [], ...result.operations.length > 0 ? [{
|
|
8549
|
+
label: result.dir ?? result.baselineDir ?? "operations",
|
|
8550
|
+
children: operationNodes$1(result.operations)
|
|
8551
|
+
}] : []];
|
|
8552
|
+
}
|
|
8530
8553
|
function operationBlocks$1(result) {
|
|
8531
|
-
|
|
8532
|
-
|
|
8554
|
+
const written = [...result.baselineOperations ?? [], ...result.operations];
|
|
8555
|
+
if (written.length === 0) return [];
|
|
8556
|
+
const destructive = written.some((operation) => operation.operationClass === "destructive");
|
|
8533
8557
|
return [{
|
|
8534
8558
|
kind: "tree",
|
|
8535
|
-
roots:
|
|
8536
|
-
label: result.dir ?? "operations",
|
|
8537
|
-
children: operationNodes$1(result)
|
|
8538
|
-
}]
|
|
8559
|
+
roots: operationRoots(result)
|
|
8539
8560
|
}, ...destructive ? [{
|
|
8540
8561
|
kind: "summary",
|
|
8541
8562
|
status: "warn",
|
|
@@ -8567,14 +8588,26 @@ function originNoticeBlocks(result) {
|
|
|
8567
8588
|
text: "No db ref set — planning from an empty database. Run db init, db update, or db sign if a database already exists."
|
|
8568
8589
|
}];
|
|
8569
8590
|
}
|
|
8591
|
+
function warningBlocks(result) {
|
|
8592
|
+
return (result.warnings ?? []).map((text) => ({
|
|
8593
|
+
kind: "summary",
|
|
8594
|
+
status: "warn",
|
|
8595
|
+
text
|
|
8596
|
+
}));
|
|
8597
|
+
}
|
|
8570
8598
|
function planBlocks(result, migrationsRelative) {
|
|
8571
8599
|
const outcome = outcomeFields(result, migrationsRelative);
|
|
8572
|
-
if (result.noOp) return [
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8600
|
+
if (result.noOp) return [
|
|
8601
|
+
...warningBlocks(result),
|
|
8602
|
+
{
|
|
8603
|
+
kind: "summary",
|
|
8604
|
+
status: "ok",
|
|
8605
|
+
text: "No changes detected"
|
|
8606
|
+
},
|
|
8607
|
+
outcome
|
|
8608
|
+
];
|
|
8577
8609
|
if (result.pendingPlaceholders === true) return [
|
|
8610
|
+
...warningBlocks(result),
|
|
8578
8611
|
{
|
|
8579
8612
|
kind: "summary",
|
|
8580
8613
|
status: "warn",
|
|
@@ -8584,6 +8617,7 @@ function planBlocks(result, migrationsRelative) {
|
|
|
8584
8617
|
outcome
|
|
8585
8618
|
];
|
|
8586
8619
|
return [
|
|
8620
|
+
...warningBlocks(result),
|
|
8587
8621
|
{
|
|
8588
8622
|
kind: "summary",
|
|
8589
8623
|
status: "ok",
|
|
@@ -8597,10 +8631,11 @@ function planBlocks(result, migrationsRelative) {
|
|
|
8597
8631
|
}
|
|
8598
8632
|
function planNextActions(result, migrationsRelative) {
|
|
8599
8633
|
if (result.pendingPlaceholders === true) {
|
|
8600
|
-
const
|
|
8634
|
+
const stubFiles = [.../* @__PURE__ */ new Set([...result.baselineDir === void 0 ? [] : [join(result.baselineDir, "migration.ts")], ...result.dir === void 0 ? [] : [join(result.dir, "migration.ts")]])];
|
|
8635
|
+
const migrationTs = stubFiles.at(-1) ?? join("<dir>", "migration.ts");
|
|
8601
8636
|
return [{
|
|
8602
8637
|
kind: "edit-file",
|
|
8603
|
-
label: `Replace each placeholder(...) call in ${migrationTs} with your query`
|
|
8638
|
+
label: `Replace each placeholder(...) call in ${stubFiles.join(" and ") || migrationTs} with your query`
|
|
8604
8639
|
}, runCommandAction("Run it to self-emit ops.json and attest the package", `node "${migrationTs}"`)];
|
|
8605
8640
|
}
|
|
8606
8641
|
const written = [
|
|
@@ -8647,11 +8682,15 @@ function planPresentations(inputs) {
|
|
|
8647
8682
|
next: () => planNextActions(inputs.document, inputs.migrationsRelative)
|
|
8648
8683
|
};
|
|
8649
8684
|
}
|
|
8685
|
+
/** The question the user answers before a destructive baseline is written. */
|
|
8686
|
+
function destructiveBaselineQuestion(operations) {
|
|
8687
|
+
return [`Write a baseline migration containing ${operations.length} destructive operation(s)? Applying it would remove data that cannot be recovered:`, destructiveOperationList(operations)].join("\n");
|
|
8688
|
+
}
|
|
8650
8689
|
function createMigrationPlanCommand(createClient) {
|
|
8651
8690
|
return defineOrmCommand({
|
|
8652
8691
|
help: {
|
|
8653
8692
|
summary: "Plan a migration from contract changes",
|
|
8654
|
-
description: "Compares the emitted contract against the latest on-disk migration state\nand produces a new migration package with the required operations.\
|
|
8693
|
+
description: "Compares the emitted contract against the latest on-disk migration state\nand produces a new migration package with the required operations.\nOn an empty migrations directory a baseline package is derived from the\n`db` ref first; a baseline containing destructive operations is only\nwritten with your consent: the command asks you to type the project\ndirectory name, or takes `--confirm <directory>` where there is nobody\nto ask. Offline — does not consult the database.",
|
|
8655
8694
|
examples: [
|
|
8656
8695
|
"migration plan",
|
|
8657
8696
|
"migration plan --name add-users-table",
|
|
@@ -8675,8 +8714,13 @@ function createMigrationPlanCommand(createClient) {
|
|
|
8675
8714
|
} },
|
|
8676
8715
|
needs: { config: ormConfigSection },
|
|
8677
8716
|
handler: async (args, ctx) => {
|
|
8717
|
+
const seededDirs = [];
|
|
8678
8718
|
const seeded = (record) => {
|
|
8679
8719
|
if (record.action !== "updated") return;
|
|
8720
|
+
for (const dirName of record.newMigrationDirs) seededDirs.push({
|
|
8721
|
+
spaceId: record.spaceId,
|
|
8722
|
+
dirName
|
|
8723
|
+
});
|
|
8680
8724
|
const step = `Seed contract space ${record.spaceId}`;
|
|
8681
8725
|
ctx.report({
|
|
8682
8726
|
kind: "step-started",
|
|
@@ -8694,13 +8738,15 @@ function createMigrationPlanCommand(createClient) {
|
|
|
8694
8738
|
}
|
|
8695
8739
|
});
|
|
8696
8740
|
};
|
|
8697
|
-
const
|
|
8741
|
+
const plan = (consent) => executeMigrationPlanCommand({
|
|
8698
8742
|
config: ctx.config,
|
|
8699
8743
|
cwd: ctx.cwd,
|
|
8700
8744
|
configPath: projectConfigPathFor(ctx.cwd),
|
|
8701
8745
|
...ifDefined("name", args.flags.name),
|
|
8702
8746
|
...ifDefined("from", args.flags.from),
|
|
8703
8747
|
...ifDefined("to", args.flags.to),
|
|
8748
|
+
...ifDefined("consent", consent),
|
|
8749
|
+
...ifDefined("carryEmittedExtensionDirs", consent !== void 0 && seededDirs.length > 0 ? [...seededDirs] : void 0),
|
|
8704
8750
|
client: createClient({
|
|
8705
8751
|
family: ctx.config.family,
|
|
8706
8752
|
target: ctx.config.target,
|
|
@@ -8709,6 +8755,14 @@ function createMigrationPlanCommand(createClient) {
|
|
|
8709
8755
|
extensions: ctx.config.extensions ?? []
|
|
8710
8756
|
})
|
|
8711
8757
|
}, Date.now(), { onSeeded: seeded });
|
|
8758
|
+
let planned = await plan();
|
|
8759
|
+
if (!planned.ok && planned.failure.code === ERROR_CODE_DESTRUCTIVE_CHANGES) {
|
|
8760
|
+
const verdict = blindCast(planned.failure.meta ?? {});
|
|
8761
|
+
if (verdict.destructiveOperations === void 0 || verdict.destructiveOperations.length === 0 || verdict.planHash === void 0) return notOk$1(normalizeError(errorConsentOperationsMissing({ previewCommand: "{bin} migration plan" })));
|
|
8762
|
+
const token = consentToken(ctx.cwd);
|
|
8763
|
+
if (!await ctx.prompt.consent(destructiveBaselineQuestion(verdict.destructiveOperations), { token })) return notOk$1(normalizeError(planned.failure));
|
|
8764
|
+
planned = await plan({ planHash: verdict.planHash });
|
|
8765
|
+
}
|
|
8712
8766
|
if (!planned.ok) return notOk$1(normalizeError(planned.failure));
|
|
8713
8767
|
ctx.report({
|
|
8714
8768
|
kind: "message",
|
|
@@ -8914,7 +8968,8 @@ const migrationShowCommand = defineOrmCommand({
|
|
|
8914
8968
|
migrationsDir,
|
|
8915
8969
|
appContract,
|
|
8916
8970
|
extensions: [],
|
|
8917
|
-
deserializeContract: (json) => familyInstance.deserializeContract(json)
|
|
8971
|
+
deserializeContract: (json) => familyInstance.deserializeContract(json),
|
|
8972
|
+
...ifDefined("verifySnapshotContent", snapshotVerifierFor(ctx.config))
|
|
8918
8973
|
});
|
|
8919
8974
|
if (!loaded.ok) return notOk$1(normalizeError(loaded.failure));
|
|
8920
8975
|
const aggregate = loaded.value;
|