@prisma/orm-toolchain 8.0.0-rc.24-dev.23 → 8.0.0-rc.24-dev.24
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-BmhAhXYL.d.mts → aggregate-C6PGBKyb.d.mts} +7 -3
- package/dist/aggregate-C6PGBKyb.d.mts.map +1 -0
- package/dist/{aggregate-BIjV2dM9.mjs → aggregate-CRIdmKmq.mjs} +12 -8
- package/dist/aggregate-CRIdmKmq.mjs.map +1 -0
- package/dist/{caught-errors-Cll-zcA1-MXR0HE1V.mjs → caught-errors-I1l50iPc-D_-F2M3t.mjs} +21 -5
- package/dist/caught-errors-I1l50iPc-D_-F2M3t.mjs.map +1 -0
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +187 -67
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +17 -5
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +2 -2
- package/dist/cli__control-api__testing.d.mts +1 -1
- package/dist/cli__migration-cli.mjs +3 -3
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/{contract-snapshot-store-nWnsWPPQ-rJ94UCcE.mjs → contract-snapshot-store-B0fRbVHB-BN2g8BKh.mjs} +3 -3
- package/dist/{contract-snapshot-store-nWnsWPPQ-rJ94UCcE.mjs.map → contract-snapshot-store-B0fRbVHB-BN2g8BKh.mjs.map} +1 -1
- package/dist/{db-sign-DGSaPRQ--B_9CmDng.d.mts → db-sign-Bv-FZMAD-uQhMNCC7.d.mts} +42 -26
- package/dist/db-sign-Bv-FZMAD-uQhMNCC7.d.mts.map +1 -0
- package/dist/{errors-DXha_4l--relAaiI4.mjs → errors-BMq40nYH-Cg8PBect.mjs} +33 -4
- package/dist/errors-BMq40nYH-Cg8PBect.mjs.map +1 -0
- package/dist/{errors-CLwhWJiz.d.mts → errors-oP9FaWWm.d.mts} +5 -2
- package/dist/errors-oP9FaWWm.d.mts.map +1 -0
- package/dist/{graph-membership-DxpNgxfZ-BfqA-H7V.mjs → graph-membership-D7m41lWA-B68g1CRS.mjs} +3 -3
- package/dist/{graph-membership-DxpNgxfZ-BfqA-H7V.mjs.map → graph-membership-D7m41lWA-B68g1CRS.mjs.map} +1 -1
- package/dist/{invariants-DrF9p5Gd-BF70vGl1.mjs → invariants-DxCj82g2-DhGkStla.mjs} +3 -3
- package/dist/{invariants-DrF9p5Gd-BF70vGl1.mjs.map → invariants-DxCj82g2-DhGkStla.mjs.map} +1 -1
- package/dist/{io-4O31S6Ei-DvsFKW_Y.mjs → io-B39zsxMm-D5Wcf6cf.mjs} +5 -5
- package/dist/{io-4O31S6Ei-DvsFKW_Y.mjs.map → io-B39zsxMm-D5Wcf6cf.mjs.map} +1 -1
- package/dist/{migration-CWyjX9vz.mjs → migration-DTmtOJ0n.mjs} +3 -3
- package/dist/{migration-CWyjX9vz.mjs.map → migration-DTmtOJ0n.mjs.map} +1 -1
- package/dist/migration-tools.d.mts +6 -5
- package/dist/migration-tools.mjs +12 -12
- package/dist/migration-tools__aggregate.d.mts +1 -1
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
- package/dist/migration-tools__errors.d.mts +2 -2
- package/dist/migration-tools__errors.mjs +2 -2
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.mjs +1 -1
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.d.mts +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.d.mts +3 -2
- package/dist/migration-tools__refs.mjs +2 -2
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/{ref-D4GWEHQU-BOqb4i_E.mjs → ref-DfuqRCA7-CPPoVHY9.mjs} +459 -101
- package/dist/ref-DfuqRCA7-CPPoVHY9.mjs.map +1 -0
- package/dist/{ref-resolution-Eo0QHp4f.mjs → ref-resolution-C9j2SSb6.mjs} +2 -2
- package/dist/{ref-resolution-Eo0QHp4f.mjs.map → ref-resolution-C9j2SSb6.mjs.map} +1 -1
- package/dist/{ref-resolution-BPhR-kta.d.mts → ref-resolution-UwnXbc9M.d.mts} +2 -2
- package/dist/{ref-resolution-BPhR-kta.d.mts.map → ref-resolution-UwnXbc9M.d.mts.map} +1 -1
- package/dist/refs-B5N_vHH7.d.mts +1 -0
- package/dist/{refs-BNCUu58Y-BIso5Jfg.d.mts → refs-CkGjbosE-CLkrSkQ4.d.mts} +18 -3
- package/dist/refs-CkGjbosE-CLkrSkQ4.d.mts.map +1 -0
- package/dist/{refs-DM3q3IZC-BC6H6P0X.mjs → refs-t_JbIjGo-CRpBRRkq.mjs} +79 -20
- package/dist/refs-t_JbIjGo-CRpBRRkq.mjs.map +1 -0
- package/dist/{spaces-BIABdklg.mjs → spaces-OVZ0QzWJ.mjs} +5 -5
- package/dist/{spaces-BIABdklg.mjs.map → spaces-OVZ0QzWJ.mjs.map} +1 -1
- package/dist/{verify-contract-spaces-BmnQiKDj-JwT2fAPh.mjs → verify-contract-spaces-BOnqhfQs-BBq5YOKo.mjs} +11 -7
- package/dist/verify-contract-spaces-BOnqhfQs-BBq5YOKo.mjs.map +1 -0
- package/dist/vite-plugin-contract-emit.mjs +1 -1
- package/package.json +12 -12
- package/dist/aggregate-BIjV2dM9.mjs.map +0 -1
- package/dist/aggregate-BmhAhXYL.d.mts.map +0 -1
- package/dist/caught-errors-Cll-zcA1-MXR0HE1V.mjs.map +0 -1
- package/dist/db-sign-DGSaPRQ--B_9CmDng.d.mts.map +0 -1
- package/dist/errors-CLwhWJiz.d.mts.map +0 -1
- package/dist/errors-DXha_4l--relAaiI4.mjs.map +0 -1
- package/dist/ref-D4GWEHQU-BOqb4i_E.mjs.map +0 -1
- package/dist/refs-BNCUu58Y-BIso5Jfg.d.mts.map +0 -1
- package/dist/refs-DM3q3IZC-BC6H6P0X.mjs.map +0 -1
- package/dist/verify-contract-spaces-BmnQiKDj-JwT2fAPh.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { a as expandContractInputs, c as globContractInputMatching, d as loadConfigFiles, g as requireConfigSections, h as ormConfigSection, i as evaluateConfigModule, r as buildLoadedConfig } from "./exports-CSVHjfwG.mjs";
|
|
2
2
|
import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
|
|
3
|
-
import { t as MigrationToolsError } from "./errors-
|
|
4
|
-
import { t as contractSnapshotDir } from "./contract-snapshot-store-
|
|
5
|
-
import { s as readMigrationsDir } from "./io-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { t as MigrationToolsError } from "./errors-BMq40nYH-Cg8PBect.mjs";
|
|
4
|
+
import { t as contractSnapshotDir } from "./contract-snapshot-store-B0fRbVHB-BN2g8BKh.mjs";
|
|
5
|
+
import { s as readMigrationsDir } from "./io-B39zsxMm-D5Wcf6cf.mjs";
|
|
6
|
+
import { l as spaceMigrationDirectory, u as spaceRefsDirectory } from "./verify-contract-spaces-BOnqhfQs-BBq5YOKo.mjs";
|
|
7
|
+
import { A as errorHashMismatch, C as errorContractConfigMissing, D as errorDriverRequired, E as errorDatabaseConnectionRequired, F as errorMigrationPackageNotFound, G as errorRuntime, K as errorSignRefsNotWritten, L as errorNoMigrations, M as errorLegendHumanOnly, N as errorMarkerMissing, O as errorFileNotFound, Q as errorStatementNeedsMigrationFile, S as errorContractArgConflict, T as errorConvertAndDelete, _t as selfEmitCommand, a as appRefsDirFor, b as errorConfigValidation$1, bt as targetSupportsMigrations, c as cliCommand, d as closeQuietly, dt as redactUrlCredentials, ft as requireLiveDatabase, g as displayPath, gt as runCommandAction, h as dbUpdateRerun, i as appMigrationsDirFor, k as errorFromCaught, lt as printedPlanCommand, n as CliStructuredError$1$1, nt as errorTargetMismatch, o as baseDirFor, ot as maskConnectionUrl, p as contractPathFor, pt as rerunFlags, s as chooseAction, st as migrationsDirFor, tt as errorTargetMigrationNotSupported, u as cliInvocation, ut as readContractEnvelope, v as errorAdvanceRefArgConflict, vt as shellQuoted, w as errorContractValidationFailed, x as errorConsentUnused, yt as statementFlag } from "./caught-errors-I1l50iPc-D_-F2M3t.mjs";
|
|
8
8
|
import { r as getEmittedArtifactPaths } from "./exports-CVgs3YWV-BF4rqnxF.mjs";
|
|
9
|
-
import { r as isInSpaceHistory } from "./graph-membership-
|
|
10
|
-
import {
|
|
11
|
-
import { a as contractHashAtMarker } from "./aggregate-
|
|
9
|
+
import { r as isInSpaceHistory } from "./graph-membership-D7m41lWA-B68g1CRS.mjs";
|
|
10
|
+
import { i as readRef, n as advanceRef } from "./refs-t_JbIjGo-CRpBRRkq.mjs";
|
|
11
|
+
import { a as contractHashAtMarker } from "./aggregate-CRIdmKmq.mjs";
|
|
12
12
|
import { i as createScaffoldSpecifierResolver } from "./import-roots-Dqs1_cn4.mjs";
|
|
13
|
-
import { o as isLiveMarkerRef } from "./ref-resolution-
|
|
14
|
-
import { $ as
|
|
13
|
+
import { o as isLiveMarkerRef } from "./ref-resolution-C9j2SSb6.mjs";
|
|
14
|
+
import { $ as planEverySpace, A as executeMigrationNewCommand, B as labelsText, C as errorPermitPolicyChangeNeedsRef, Ct as statusForMigrationHash, Et as withWarningFindings, F as executeRefSetCommand, G as loadContractSource, H as liveMarkerUse, I as findPackageByDirPath, J as looksLikePath, K as loadContractSourceWithStack, L as formatSourceDiagnostic, N as executeRefDeleteCommand, P as executeRefListCommand, Q as migrationSpaceListEntriesFromAggregate, R as hasMigrationPath, S as enumerateCheckSpaces, St as sourceWarningDiagnostic, Tt as validateLoadedContract, U as loadAggregateIntegrityViolations, V as listRefsByContractHash, W as loadContractRawSafely, Y as mapContractAtError, Z as matchConsents, _ as databasePoliciesInForce, a as advanceRefSafely, at as refusePackageCorruptionOnAggregate, bt as skippedOperationsText, ct as requireDatabaseForLiveMarkerUse, d as buildRefAdvancementFields, dt as resolveContractRefToSnapshot, et as preflightRefAdvancement, f as checkSingleTarget, g as createControlClient, gt as retryCommandFor, h as convertAndDelete, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as refuseMissingInvariantPath, j as executeMigrationPlanCommand, k as executeMigrateShowPlan, l as buildMigrationSpaceGraphEntries, lt as resolveAppTargetPath, m as contractValidationMeta, n as NO_REF_ADVANCEMENT, nt as refuseContractSpaceIntegrity, ot as refuseUnknownInvariants, p as computeRefAdvancementName, pt as resolveMigrationRef, q as loadContractSpaceAggregateForCli, r as RECORDED_CONTRACT_REF_FORMS, s as appliedHashesFromLedger, st as renamedAndDeleted, t as ALL_CONTRACT_REF_FORMS, tt as readMigrationRefs, u as buildReadAggregate, ut as resolveContractRef$1, v as declaredSettingsText, vt as runMigrationCheck, w as executeContractEmit, wt as toDeclaredExtensionsFromRaw, xt as snapshotVerifierFor, y as deriveStatusEdgeAnnotations, yt as runMigrationList, z as isStatementVerb } from "./ref-DfuqRCA7-CPPoVHY9.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";
|
|
18
18
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
19
19
|
import { CliStructuredError } from "@prisma/orm-framework/errors/control";
|
|
20
|
-
import { APP_SPACE_ID, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_SCHEMA_FAILURE, VERIFY_CODE_TARGET_MISMATCH, createControlStack, hasPslContractBuild, issueLabel, migrationSubjectJson, schemaIssuesWhy } from "@prisma/orm-framework/components/control";
|
|
20
|
+
import { APP_SPACE_ID, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_SCHEMA_FAILURE, VERIFY_CODE_TARGET_MISMATCH, createControlStack, databasePoliciesOf, databasePolicyDifferences, databasePolicyValueText, hasPslContractBuild, issueLabel, migrationSubjectJson, sameMarkerHashes, schemaIssuesWhy } from "@prisma/orm-framework/components/control";
|
|
21
21
|
import { InternalError, isInternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
22
22
|
import { DOCS_BASE, docsUrlFor, isStructuredError, isStructuredErrorCode } from "@prisma/orm-framework/utils/structured-error";
|
|
23
23
|
import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve } from "pathe";
|
|
24
|
+
import { errorMarkerPoliciesCorrupt } from "@prisma/orm-framework/errors/execution";
|
|
24
25
|
import { mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
25
26
|
import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
|
|
26
27
|
import { type } from "arktype";
|
|
@@ -43,8 +44,8 @@ import stringWidth from "string-width";
|
|
|
43
44
|
import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
|
|
44
45
|
import { isCI } from "ci-info";
|
|
45
46
|
import { build } from "esbuild";
|
|
46
|
-
//#region ../../../1-framework/3-tooling/cli/dist/cli-
|
|
47
|
-
var version = "8.0.0-rc.24-dev.
|
|
47
|
+
//#region ../../../1-framework/3-tooling/cli/dist/cli-CXMtfH46.mjs
|
|
48
|
+
var version = "8.0.0-rc.24-dev.24";
|
|
48
49
|
const ESCAPES = {
|
|
49
50
|
"\\": "\\\\",
|
|
50
51
|
" ": "\\t",
|
|
@@ -360,6 +361,8 @@ const dbFlag = flag.string({
|
|
|
360
361
|
brief: "Database connection string",
|
|
361
362
|
placeholder: "url"
|
|
362
363
|
});
|
|
364
|
+
/** Consent for `db migrate` and `db update` to write the ref's declared policies into the database. */
|
|
365
|
+
const permitPolicyChangeFlag = flag.boolean({ brief: "Check the run against the ref's declared policies and write them into the database when it succeeds" });
|
|
363
366
|
/** The file `contract infer` writes when nothing names another. */
|
|
364
367
|
const INFERRED_CONTRACT_FILENAME = "contract.prisma";
|
|
365
368
|
/**
|
|
@@ -973,9 +976,11 @@ function applySummaryText(result) {
|
|
|
973
976
|
const planned = result.plan.operations.length;
|
|
974
977
|
const spaces = result.perSpace?.length ?? 0;
|
|
975
978
|
const across = spaces > 0 ? ` across ${spaces} contract space${spaces === 1 ? "" : "s"}` : "";
|
|
979
|
+
const policies = result.databasePoliciesUpdated;
|
|
976
980
|
if (result.changedStorageEntities !== void 0) return result.summary;
|
|
977
|
-
if (executed === 0) return `Database already matches contract${across}`;
|
|
978
|
-
|
|
981
|
+
if (executed === 0) return policies === void 0 ? `Database already matches contract${across}` : `Policies updated: ${declaredSettingsText(policies)}`;
|
|
982
|
+
const applied = executed < planned ? `Applied ${executed} of ${planned} operation(s)${across}; ${skippedOperationsText(planned - executed)}` : `Applied ${executed} operation(s)${across}`;
|
|
983
|
+
return policies === void 0 ? applied : `${applied}; policies updated: ${declaredSettingsText(policies)}`;
|
|
979
984
|
}
|
|
980
985
|
/** For each namespace the plan removes, the answers that answer all of its questions. */
|
|
981
986
|
function namespaceAnswerLines(result) {
|
|
@@ -1756,27 +1761,33 @@ function signSummary(spaces) {
|
|
|
1756
1761
|
const signedText = signed.length === 0 ? "signed nothing" : `signed ${quotedList(signed)}`;
|
|
1757
1762
|
return `${problems.charAt(0).toUpperCase()}${problems.slice(1)}; ${signedText}`;
|
|
1758
1763
|
}
|
|
1759
|
-
/** The `db sign`
|
|
1760
|
-
function
|
|
1761
|
-
return
|
|
1764
|
+
/** The arguments of `db sign` that change what it signs or where, which a re-run repeats. */
|
|
1765
|
+
function signRerunArgs(args) {
|
|
1766
|
+
return [
|
|
1762
1767
|
...args.contractRef === void 0 ? [] : ["--contract", shellQuoted(args.contractRef)],
|
|
1763
1768
|
...args.advanceRef === void 0 ? [] : ["--advance-ref", shellQuoted(args.advanceRef)],
|
|
1764
1769
|
...args.noAdvanceRef ? ["--no-advance-ref"] : []
|
|
1765
|
-
]
|
|
1770
|
+
];
|
|
1771
|
+
}
|
|
1772
|
+
/** The `db sign` command that runs this one again, with the arguments the user gave. */
|
|
1773
|
+
function rerunCommand(invocation) {
|
|
1774
|
+
return cliCommand(invocation, "db sign", invocation.rerunArgs ?? []);
|
|
1766
1775
|
}
|
|
1767
1776
|
function markerConflictDiagnostic(outcome, rerun) {
|
|
1768
1777
|
const { expected, found } = outcome;
|
|
1778
|
+
const changedBack = expected !== null && sameMarkerHashes(found, expected);
|
|
1769
1779
|
return {
|
|
1770
1780
|
code: "MIGRATION.MARKER_CAS_FAILURE",
|
|
1771
1781
|
severity: "error",
|
|
1772
1782
|
summary: `Marker of space "${outcome.space}" changed while db sign ran`,
|
|
1773
|
-
why: `Another process, such as migrate, changed the marker from ${expected?.storageHash ?? "no marker"} to ${found?.storageHash ?? "no marker"} after db sign read it, so db sign did not sign the space.`,
|
|
1783
|
+
why: changedBack ? "Another process changed the marker and changed it back while db sign was writing it, so db sign did not sign the space." : `Another process, such as migrate, changed the marker from ${expected?.storageHash ?? "no marker"} to ${found?.storageHash ?? "no marker"} after db sign read it, so db sign did not sign the space.`,
|
|
1774
1784
|
nextActions: [{
|
|
1775
1785
|
kind: "run-command",
|
|
1776
1786
|
label: "Sign again once the other process has finished",
|
|
1777
1787
|
command: rerun
|
|
1778
1788
|
}],
|
|
1779
1789
|
meta: {
|
|
1790
|
+
reason: changedBack ? "markerChanged" : "storageHash",
|
|
1780
1791
|
space: outcome.space,
|
|
1781
1792
|
expectedStorageHash: expected?.storageHash ?? null,
|
|
1782
1793
|
foundStorageHash: found?.storageHash ?? null,
|
|
@@ -1856,10 +1867,7 @@ function hydrateContract(config, json, path) {
|
|
|
1856
1867
|
async function advanceExtensionRef(args) {
|
|
1857
1868
|
const refsDir = spaceRefsDirectory(spaceMigrationDirectory(args.migrationsDir, args.space));
|
|
1858
1869
|
try {
|
|
1859
|
-
await
|
|
1860
|
-
hash: args.hash,
|
|
1861
|
-
invariants: []
|
|
1862
|
-
});
|
|
1870
|
+
await advanceRef(refsDir, args.name, args.hash);
|
|
1863
1871
|
return ok(void 0);
|
|
1864
1872
|
} catch (error) {
|
|
1865
1873
|
if (MigrationToolsError.is(error)) return notOk(error);
|
|
@@ -2004,11 +2012,15 @@ function createDbSignCommand(createClient = createControlClient) {
|
|
|
2004
2012
|
});
|
|
2005
2013
|
if (!connection.ok) return notOk$1(connection.failure);
|
|
2006
2014
|
const dbConnection = connection.value;
|
|
2007
|
-
const
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2015
|
+
const invocation = {
|
|
2016
|
+
...cliInvocation(ctx, args.flags.db),
|
|
2017
|
+
rerunArgs: signRerunArgs({
|
|
2018
|
+
contractRef,
|
|
2019
|
+
advanceRef: args.flags.advanceRef,
|
|
2020
|
+
noAdvanceRef: args.flags.noAdvanceRef
|
|
2021
|
+
})
|
|
2022
|
+
};
|
|
2023
|
+
const rerun = rerunCommand(invocation);
|
|
2012
2024
|
const header = headerBlock$1({
|
|
2013
2025
|
contract: contractRef ?? emitted.value.displayPath,
|
|
2014
2026
|
database: maskConnectionUrl(dbConnection)
|
|
@@ -2017,6 +2029,7 @@ function createDbSignCommand(createClient = createControlClient) {
|
|
|
2017
2029
|
const signed = await client.dbSign({
|
|
2018
2030
|
contract,
|
|
2019
2031
|
migrationsDir,
|
|
2032
|
+
invocation,
|
|
2020
2033
|
connection: dbConnection,
|
|
2021
2034
|
onProgress: controlProgressReporter(ctx.report)
|
|
2022
2035
|
});
|
|
@@ -2335,11 +2348,7 @@ function updatePresentations(inputs) {
|
|
|
2335
2348
|
]
|
|
2336
2349
|
}, ...migrationResultBlocks(document, inputs.invocation, inputs.databaseStorageHash)],
|
|
2337
2350
|
json: () => document,
|
|
2338
|
-
next: () => migrationResultNextActions(document, inputs.invocation,
|
|
2339
|
-
...inputs.to === void 0 ? [] : ["--to", shellQuoted(inputs.to)],
|
|
2340
|
-
...inputs.advanceRef === void 0 ? [] : ["--advance-ref", shellQuoted(inputs.advanceRef)],
|
|
2341
|
-
...inputs.statements.map(statementFlag)
|
|
2342
|
-
]))
|
|
2351
|
+
next: () => migrationResultNextActions(document, inputs.invocation, dbUpdateRerun(inputs.invocation, inputs.statements.map(statementFlag)))
|
|
2343
2352
|
};
|
|
2344
2353
|
}
|
|
2345
2354
|
/**
|
|
@@ -2422,6 +2431,7 @@ function updateDocument(inputs) {
|
|
|
2422
2431
|
} },
|
|
2423
2432
|
...ifDefined("perSpace", value.perSpace),
|
|
2424
2433
|
...ifDefined("changedStorageEntities", value.changedStorageEntities),
|
|
2434
|
+
...ifDefined("databasePoliciesUpdated", value.databasePoliciesUpdated),
|
|
2425
2435
|
appliedStatements: value.appliedStatements,
|
|
2426
2436
|
temporaryValues: value.temporaryValues,
|
|
2427
2437
|
...value.mode === "plan" ? {
|
|
@@ -2467,7 +2477,8 @@ function createDbUpdateCommand(createClient) {
|
|
|
2467
2477
|
advanceRef: flag.string({
|
|
2468
2478
|
brief: "Advance the named ref to the post-command contract hash",
|
|
2469
2479
|
placeholder: "name"
|
|
2470
|
-
})
|
|
2480
|
+
}),
|
|
2481
|
+
permitPolicyChange: permitPolicyChangeFlag
|
|
2471
2482
|
} },
|
|
2472
2483
|
statements: dbUpdateStatementVerbs,
|
|
2473
2484
|
needs: { config: ormConfigSection },
|
|
@@ -2517,6 +2528,10 @@ function createDbUpdateCommand(createClient) {
|
|
|
2517
2528
|
if (!resolved.ok) return notOk$1(normalizeError(resolved.failure));
|
|
2518
2529
|
destination = resolved.value;
|
|
2519
2530
|
}
|
|
2531
|
+
if (args.flags.permitPolicyChange === true && destination?.ref === void 0) return notOk$1(normalizeError(errorPermitPolicyChangeNeedsRef({
|
|
2532
|
+
command: "db update",
|
|
2533
|
+
to: args.flags.to
|
|
2534
|
+
})));
|
|
2520
2535
|
const prepared = await prepareMigrationRun({
|
|
2521
2536
|
config: ctx.config,
|
|
2522
2537
|
cwd: ctx.cwd,
|
|
@@ -2525,13 +2540,11 @@ function createDbUpdateCommand(createClient) {
|
|
|
2525
2540
|
createClient,
|
|
2526
2541
|
retryCommand: () => retryCommandFor({
|
|
2527
2542
|
commandName: args.flags.dryRun ? "db update --dry-run" : "db update",
|
|
2528
|
-
|
|
2529
|
-
advanceRef: args.flags.advanceRef,
|
|
2530
|
-
statements: [
|
|
2543
|
+
rerunArgs: [...rerunFlags(args.flags), ...[
|
|
2531
2544
|
...planned,
|
|
2532
2545
|
...previewConsents,
|
|
2533
2546
|
...unansweredConsents(ctx.statements)
|
|
2534
|
-
],
|
|
2547
|
+
].map(statementFlag)],
|
|
2535
2548
|
canRunOffline: false
|
|
2536
2549
|
})
|
|
2537
2550
|
});
|
|
@@ -2569,20 +2582,17 @@ function createDbUpdateCommand(createClient) {
|
|
|
2569
2582
|
...previewConsents,
|
|
2570
2583
|
...unansweredConsents(ctx.statements)
|
|
2571
2584
|
].map(statementFlag);
|
|
2572
|
-
const rerunArgs = [
|
|
2573
|
-
...args.flags.to === void 0 ? [] : ["--to", shellQuoted(args.flags.to)],
|
|
2574
|
-
...args.flags.advanceRef === void 0 ? [] : ["--advance-ref", shellQuoted(args.flags.advanceRef)],
|
|
2575
|
-
...statementArgs
|
|
2576
|
-
];
|
|
2577
2585
|
const result = await client.dbUpdate({
|
|
2578
2586
|
contract: contractJson,
|
|
2579
2587
|
mode,
|
|
2580
2588
|
migrationsDir,
|
|
2581
2589
|
statements: [...planned, ...previewConsents],
|
|
2590
|
+
...ifDefined("ref", destination?.ref),
|
|
2591
|
+
...args.flags.permitPolicyChange === true ? { permitPolicyChange: true } : {},
|
|
2582
2592
|
answerQuestions: promptPlanQuestions(ctx.prompt, ctx.statements),
|
|
2583
2593
|
invocation: {
|
|
2584
2594
|
...cliInvocation(ctx, args.flags.db),
|
|
2585
|
-
rerunArgs,
|
|
2595
|
+
rerunArgs: rerunFlags(args.flags),
|
|
2586
2596
|
statementArgs
|
|
2587
2597
|
},
|
|
2588
2598
|
onPlannerWarnings: plannerWarnings.onPlannerWarnings,
|
|
@@ -2629,13 +2639,15 @@ function createDbUpdateCommand(createClient) {
|
|
|
2629
2639
|
});
|
|
2630
2640
|
return ok$1(ctx.present({ data: document }, updatePresentations({
|
|
2631
2641
|
document,
|
|
2632
|
-
invocation:
|
|
2642
|
+
invocation: {
|
|
2643
|
+
...cliInvocation(ctx, args.flags.db),
|
|
2644
|
+
rerunArgs: rerunFlags(args.flags)
|
|
2645
|
+
},
|
|
2633
2646
|
databaseStorageHash,
|
|
2634
2647
|
contractPath: prepared.value.contractDisplayPath,
|
|
2635
2648
|
database: prepared.value.database,
|
|
2636
2649
|
to: args.flags.to,
|
|
2637
2650
|
dryRun: args.flags.dryRun,
|
|
2638
|
-
advanceRef: args.flags.advanceRef,
|
|
2639
2651
|
statements: [...planned, ...previewConsents]
|
|
2640
2652
|
})));
|
|
2641
2653
|
}
|
|
@@ -9562,6 +9574,19 @@ const EMITTED_CONTRACT_TARGET = {
|
|
|
9562
9574
|
entry: void 0,
|
|
9563
9575
|
refName: void 0
|
|
9564
9576
|
};
|
|
9577
|
+
function migrateTargetOf({ entry, refName }) {
|
|
9578
|
+
if (entry === void 0) return void 0;
|
|
9579
|
+
return refName === void 0 ? {
|
|
9580
|
+
kind: "hash",
|
|
9581
|
+
hash: entry.hash
|
|
9582
|
+
} : {
|
|
9583
|
+
kind: "ref",
|
|
9584
|
+
ref: {
|
|
9585
|
+
name: refName,
|
|
9586
|
+
...entry
|
|
9587
|
+
}
|
|
9588
|
+
};
|
|
9589
|
+
}
|
|
9565
9590
|
/**
|
|
9566
9591
|
* `--to` as a contract the app graph knows. A ref target keeps the invariants
|
|
9567
9592
|
* the ref declares; a bare hash or `@empty` carries none. An omitted `--to`
|
|
@@ -9620,6 +9645,7 @@ function createMigrateCommand(createClient) {
|
|
|
9620
9645
|
placeholder: "name"
|
|
9621
9646
|
}),
|
|
9622
9647
|
show: flag.boolean({ brief: "Preview the migration route without applying (read-only)" }),
|
|
9648
|
+
permitPolicyChange: permitPolicyChangeFlag,
|
|
9623
9649
|
from: flag.string({
|
|
9624
9650
|
brief: `From-state for the --show preview (${ALL_CONTRACT_REF_FORMS})`,
|
|
9625
9651
|
placeholder: "contract"
|
|
@@ -9636,7 +9662,8 @@ function createMigrateCommand(createClient) {
|
|
|
9636
9662
|
createClient,
|
|
9637
9663
|
...ifDefined("db", args.flags.db),
|
|
9638
9664
|
...ifDefined("to", args.flags.to),
|
|
9639
|
-
...ifDefined("from", args.flags.from)
|
|
9665
|
+
...ifDefined("from", args.flags.from),
|
|
9666
|
+
...args.flags.permitPolicyChange === true ? { permitPolicyChange: true } : {}
|
|
9640
9667
|
});
|
|
9641
9668
|
if (!planned.ok) return notOk$1(normalizeError(planned.failure));
|
|
9642
9669
|
const plan = planned.value;
|
|
@@ -9673,8 +9700,7 @@ function createMigrateCommand(createClient) {
|
|
|
9673
9700
|
createClient,
|
|
9674
9701
|
retryCommand: retryCommandFor({
|
|
9675
9702
|
commandName: "db migrate",
|
|
9676
|
-
|
|
9677
|
-
advanceRef: args.flags.advanceRef,
|
|
9703
|
+
rerunArgs: rerunFlags(args.flags),
|
|
9678
9704
|
canRunOffline: false
|
|
9679
9705
|
})
|
|
9680
9706
|
});
|
|
@@ -9711,6 +9737,10 @@ function createMigrateCommand(createClient) {
|
|
|
9711
9737
|
contractHash: aggregate.app.contract().storage.storageHash
|
|
9712
9738
|
});
|
|
9713
9739
|
if (offlineTarget !== void 0 && !offlineTarget.ok) return notOk$1(offlineTarget.failure);
|
|
9740
|
+
if (args.flags.permitPolicyChange === true && offlineTarget?.value.refName === void 0) return notOk$1(normalizeError(errorPermitPolicyChangeNeedsRef({
|
|
9741
|
+
command: "db migrate",
|
|
9742
|
+
to: args.flags.to
|
|
9743
|
+
})));
|
|
9714
9744
|
let document;
|
|
9715
9745
|
try {
|
|
9716
9746
|
await client.connect(dbConnection);
|
|
@@ -9719,6 +9749,8 @@ function createMigrateCommand(createClient) {
|
|
|
9719
9749
|
const appMarker = markers.get(aggregate.app.spaceId) ?? null;
|
|
9720
9750
|
const target = offlineTarget === void 0 ? liveMarkerTarget(appMarker) : offlineTarget.value;
|
|
9721
9751
|
const refEntry = target.entry;
|
|
9752
|
+
const permitPolicyChange = args.flags.permitPolicyChange === true;
|
|
9753
|
+
const inForce = databasePoliciesInForce(markers, aggregate.app.spaceId, familyInstance.markerLocation);
|
|
9722
9754
|
const planned = await planEverySpace({
|
|
9723
9755
|
aggregate,
|
|
9724
9756
|
markers,
|
|
@@ -9730,7 +9762,8 @@ function createMigrateCommand(createClient) {
|
|
|
9730
9762
|
storageNameOf: (operation) => familyInstance.storageNameOf(operation),
|
|
9731
9763
|
migrationsDir,
|
|
9732
9764
|
invocation: cliInvocation(ctx, args.flags.db),
|
|
9733
|
-
readLedger: (spaceId) => client.readLedger(spaceId)
|
|
9765
|
+
readLedger: (spaceId) => client.readLedger(spaceId),
|
|
9766
|
+
change: inForce.change
|
|
9734
9767
|
});
|
|
9735
9768
|
if (!planned.ok) return notOk$1(normalizeError(planned.failure));
|
|
9736
9769
|
if (refEntry !== void 0 && refEntry.invariants.length > 0) {
|
|
@@ -9777,12 +9810,11 @@ function createMigrateCommand(createClient) {
|
|
|
9777
9810
|
migrationsDir,
|
|
9778
9811
|
invocation: {
|
|
9779
9812
|
...cliInvocation(ctx, args.flags.db),
|
|
9780
|
-
rerunArgs:
|
|
9813
|
+
rerunArgs: rerunFlags(args.flags)
|
|
9781
9814
|
},
|
|
9782
9815
|
onProgress: controlProgressReporter(ctx.report),
|
|
9783
|
-
...ifDefined("
|
|
9784
|
-
...
|
|
9785
|
-
...ifDefined("refName", target.refName)
|
|
9816
|
+
...ifDefined("target", migrateTargetOf(target)),
|
|
9817
|
+
...permitPolicyChange ? { permitPolicyChange } : {}
|
|
9786
9818
|
});
|
|
9787
9819
|
if (!applied.ok) return notOk$1(normalizeError(applied.failure));
|
|
9788
9820
|
const { value } = applied;
|
|
@@ -9811,7 +9843,8 @@ function createMigrateCommand(createClient) {
|
|
|
9811
9843
|
perSpace: value.perSpace,
|
|
9812
9844
|
...ifDefined("pathDecision", value.pathDecision),
|
|
9813
9845
|
timings: { total: Date.now() - startedAt },
|
|
9814
|
-
advancedRef
|
|
9846
|
+
advancedRef,
|
|
9847
|
+
...ifDefined("databasePoliciesUpdated", value.databasePoliciesUpdated)
|
|
9815
9848
|
};
|
|
9816
9849
|
} catch (error) {
|
|
9817
9850
|
return notOk$1(normalizeError(errorFromCaught(error, (message) => `Unexpected error during migrate: ${message}`, { connection: typeof dbConnection === "string" ? dbConnection : void 0 })));
|
|
@@ -11212,22 +11245,69 @@ function contractUnreadableFinding(reason) {
|
|
|
11212
11245
|
}
|
|
11213
11246
|
};
|
|
11214
11247
|
}
|
|
11215
|
-
|
|
11248
|
+
const AUTHOR_MIGRATIONS_BACK = "This database's change policy permits only migrations: author migrations that bring it back onto the migration graph, commit them, and deploy again";
|
|
11249
|
+
/**
|
|
11250
|
+
* The marker of `space` names no contract in the migration graph. The advice follows the database's
|
|
11251
|
+
* change policy `change`; when the policies cannot be read (`undefined`), it recommends no command,
|
|
11252
|
+
* since the policy might forbid it.
|
|
11253
|
+
*/
|
|
11254
|
+
function markerNotInHistoryFinding(space, change) {
|
|
11216
11255
|
const message = `Database was updated outside the migration system (marker for space "${space}" does not match any migration)`;
|
|
11217
|
-
|
|
11256
|
+
const why = "The marker the database carries names no contract in the on-disk migration graph.";
|
|
11257
|
+
if (change === void 0) return {
|
|
11218
11258
|
document: {
|
|
11219
11259
|
code: "MIGRATION.MARKER_NOT_IN_HISTORY",
|
|
11220
11260
|
severity: "warn",
|
|
11221
11261
|
message,
|
|
11222
|
-
hints: [
|
|
11262
|
+
hints: [POLICIES_FIRST]
|
|
11223
11263
|
},
|
|
11224
11264
|
diagnostic: {
|
|
11225
11265
|
code: "MIGRATION.MARKER_NOT_IN_HISTORY",
|
|
11226
11266
|
severity: "warn",
|
|
11227
11267
|
summary: message,
|
|
11228
|
-
why:
|
|
11268
|
+
why: `${why} ${POLICIES_FIRST}.`,
|
|
11229
11269
|
meta: { space },
|
|
11230
|
-
nextActions: [
|
|
11270
|
+
nextActions: []
|
|
11271
|
+
}
|
|
11272
|
+
};
|
|
11273
|
+
const reconciles = change.includes("reconcile");
|
|
11274
|
+
return {
|
|
11275
|
+
document: {
|
|
11276
|
+
code: "MIGRATION.MARKER_NOT_IN_HISTORY",
|
|
11277
|
+
severity: "warn",
|
|
11278
|
+
message,
|
|
11279
|
+
hints: reconciles ? ["Run '{bin} db sign' to overwrite the marker if the database already matches the contract", "Run '{bin} db update' to push the current contract to the database"] : [AUTHOR_MIGRATIONS_BACK]
|
|
11280
|
+
},
|
|
11281
|
+
diagnostic: {
|
|
11282
|
+
code: "MIGRATION.MARKER_NOT_IN_HISTORY",
|
|
11283
|
+
severity: "warn",
|
|
11284
|
+
summary: message,
|
|
11285
|
+
why,
|
|
11286
|
+
meta: {
|
|
11287
|
+
space,
|
|
11288
|
+
change: [...change]
|
|
11289
|
+
},
|
|
11290
|
+
nextActions: reconciles ? [runCommandAction("Overwrite the marker if the database already matches the contract", "{bin} db sign"), runCommandAction("Or push the current contract to the database", "{bin} db update")] : [chooseAction(AUTHOR_MIGRATIONS_BACK)]
|
|
11291
|
+
}
|
|
11292
|
+
};
|
|
11293
|
+
}
|
|
11294
|
+
const POLICIES_FIRST = "The database's change policy cannot be read, so the way back onto the graph cannot be chosen: have meta.policies corrected first";
|
|
11295
|
+
/** The application space's marker records policies that cannot be read; `migration status` reports it and goes on. */
|
|
11296
|
+
function markerPoliciesUnreadableFinding(corrupt) {
|
|
11297
|
+
return {
|
|
11298
|
+
document: {
|
|
11299
|
+
code: "CONTRACT.MARKER_ROW_CORRUPT",
|
|
11300
|
+
severity: "warn",
|
|
11301
|
+
message: `${corrupt.message}: ${corrupt.why ?? ""}`,
|
|
11302
|
+
hints: corrupt.fix === void 0 ? [] : [corrupt.fix]
|
|
11303
|
+
},
|
|
11304
|
+
diagnostic: {
|
|
11305
|
+
code: "CONTRACT.MARKER_ROW_CORRUPT",
|
|
11306
|
+
severity: "warn",
|
|
11307
|
+
summary: corrupt.message,
|
|
11308
|
+
...ifDefined("why", corrupt.why),
|
|
11309
|
+
nextActions: corrupt.nextActions ?? [],
|
|
11310
|
+
...ifDefined("meta", corrupt.meta)
|
|
11231
11311
|
}
|
|
11232
11312
|
};
|
|
11233
11313
|
}
|
|
@@ -11300,7 +11380,8 @@ function buildNoPathSummary(args) {
|
|
|
11300
11380
|
function buildStatusHeadline(args) {
|
|
11301
11381
|
if (args.markerDiverged && args.markerHash !== void 0) return `Database marker ${shortDisplayHash(args.markerHash)} is not in the on-disk migration graph`;
|
|
11302
11382
|
if (args.pendingCount === 0) return "Up to date";
|
|
11303
|
-
|
|
11383
|
+
const to = args.refName === void 0 ? shortDisplayHash(args.targetHash) : shellQuoted(args.refName);
|
|
11384
|
+
return `${args.pendingCount} pending — run \`{bin} db migrate --to ${to}\``;
|
|
11304
11385
|
}
|
|
11305
11386
|
/**
|
|
11306
11387
|
* One space's section: its heading, where more than one space is in scope, on
|
|
@@ -11321,6 +11402,23 @@ function sectionBlock(section) {
|
|
|
11321
11402
|
lines: [...heading, ...body]
|
|
11322
11403
|
};
|
|
11323
11404
|
}
|
|
11405
|
+
function policyDifferenceJson(difference) {
|
|
11406
|
+
return difference.setting === "change" ? {
|
|
11407
|
+
...difference,
|
|
11408
|
+
declared: [...difference.declared],
|
|
11409
|
+
inForce: [...difference.inForce]
|
|
11410
|
+
} : difference;
|
|
11411
|
+
}
|
|
11412
|
+
/** Each policy setting the ref declares that differs from the one the database records. */
|
|
11413
|
+
function differencesBlock(differences) {
|
|
11414
|
+
return {
|
|
11415
|
+
kind: "drawing",
|
|
11416
|
+
lines: [[{
|
|
11417
|
+
text: "differences:",
|
|
11418
|
+
tone: "heading"
|
|
11419
|
+
}], ...differences.map(({ setting, declared, inForce }) => [{ text: ` ${setting}: ref declares ${databasePolicyValueText(declared)}, database has ${databasePolicyValueText(inForce)}` }])]
|
|
11420
|
+
};
|
|
11421
|
+
}
|
|
11324
11422
|
function statusPresentations(inputs) {
|
|
11325
11423
|
const legend = inputs.legend;
|
|
11326
11424
|
return {
|
|
@@ -11365,6 +11463,7 @@ function statusPresentations(inputs) {
|
|
|
11365
11463
|
lines: toneDrawing(legend)
|
|
11366
11464
|
}],
|
|
11367
11465
|
...inputs.sections.map(sectionBlock),
|
|
11466
|
+
...inputs.differences.length === 0 ? [] : [differencesBlock(inputs.differences)],
|
|
11368
11467
|
inputs.headline
|
|
11369
11468
|
],
|
|
11370
11469
|
json: () => inputs.document
|
|
@@ -11424,7 +11523,7 @@ const migrationStatusCommand = defineOrmCommand({
|
|
|
11424
11523
|
const findings = [];
|
|
11425
11524
|
const loaded = await buildReadAggregate(ctx.config, { migrationsDir });
|
|
11426
11525
|
if (!loaded.ok) return notOk$1(normalizeError(loaded.failure));
|
|
11427
|
-
const { aggregate, contractHash } = loaded.value;
|
|
11526
|
+
const { aggregate, contractHash, markerLocation } = loaded.value;
|
|
11428
11527
|
const contractConfig = { contract: ifDefined("output", contractPathFor(ctx.config)) };
|
|
11429
11528
|
try {
|
|
11430
11529
|
await readContractEnvelope(contractConfig);
|
|
@@ -11499,6 +11598,20 @@ const migrationStatusCommand = defineOrmCommand({
|
|
|
11499
11598
|
let noPath;
|
|
11500
11599
|
let headlineTargetHash = activeRefHash ?? contractHash;
|
|
11501
11600
|
let totalPending = 0;
|
|
11601
|
+
let reportedUnreadablePolicies = false;
|
|
11602
|
+
/** The database's policies, or undefined when they cannot be read, which is reported once as a finding. */
|
|
11603
|
+
const appPoliciesInForce = () => {
|
|
11604
|
+
const read = databasePoliciesOf(database.markersBySpace.get(aggregate.app.spaceId));
|
|
11605
|
+
if (read.ok) return read.value;
|
|
11606
|
+
if (!reportedUnreadablePolicies) {
|
|
11607
|
+
reportedUnreadablePolicies = true;
|
|
11608
|
+
findings.push(markerPoliciesUnreadableFinding(errorMarkerPoliciesCorrupt({
|
|
11609
|
+
why: read.failure.why,
|
|
11610
|
+
space: aggregate.app.spaceId,
|
|
11611
|
+
markerLocation
|
|
11612
|
+
})));
|
|
11613
|
+
}
|
|
11614
|
+
};
|
|
11502
11615
|
for (const entry of scopedSpaces) {
|
|
11503
11616
|
const space = aggregate.space(entry.space);
|
|
11504
11617
|
if (space === void 0) continue;
|
|
@@ -11526,7 +11639,7 @@ const migrationStatusCommand = defineOrmCommand({
|
|
|
11526
11639
|
space: entry.space,
|
|
11527
11640
|
markerHash: readMarker.storageHash
|
|
11528
11641
|
};
|
|
11529
|
-
findings.push(markerNotInHistoryFinding(entry.space));
|
|
11642
|
+
findings.push(markerNotInHistoryFinding(entry.space, appPoliciesInForce()?.change));
|
|
11530
11643
|
}
|
|
11531
11644
|
if (origin !== void 0 && !markerDiverged && originHash !== targetHash && noPath === void 0 && !hasMigrationPath(graph, originHash, targetHash)) noPath = {
|
|
11532
11645
|
origin,
|
|
@@ -11599,6 +11712,9 @@ const migrationStatusCommand = defineOrmCommand({
|
|
|
11599
11712
|
}
|
|
11600
11713
|
}
|
|
11601
11714
|
}
|
|
11715
|
+
const declaredPolicies = connects ? activeRefEntry?.policies : void 0;
|
|
11716
|
+
const policiesToCompare = declaredPolicies === void 0 ? void 0 : appPoliciesInForce();
|
|
11717
|
+
const differences = declaredPolicies === void 0 || policiesToCompare === void 0 ? void 0 : databasePolicyDifferences(declaredPolicies, policiesToCompare);
|
|
11602
11718
|
const rendered = renderMigrationGraphSpaceTrees(renderInputs);
|
|
11603
11719
|
const treesBySpace = new Map(renderInputs.map((input, index) => [input.spaceId, rendered[index] ?? ""]));
|
|
11604
11720
|
const sections = scopedSpaces.map((entry) => {
|
|
@@ -11609,20 +11725,23 @@ const migrationStatusCommand = defineOrmCommand({
|
|
|
11609
11725
|
showHeading: showSpaceHeadings
|
|
11610
11726
|
};
|
|
11611
11727
|
});
|
|
11612
|
-
const
|
|
11728
|
+
const pathSummary = scopedSpaces.every((entry) => entry.migrations.length === 0) ? "No migrations found" : noPath !== void 0 ? buildNoPathSummary(noPath) : buildStatusHeadline({
|
|
11613
11729
|
pendingCount: totalPending,
|
|
11614
11730
|
targetHash: headlineTargetHash,
|
|
11731
|
+
refName: activeRefName,
|
|
11615
11732
|
markerDiverged: divergedMarker !== void 0,
|
|
11616
11733
|
markerHash: divergedMarker?.markerHash
|
|
11617
11734
|
});
|
|
11735
|
+
const summary = differences !== void 0 && differences.length > 0 && activeRefName !== void 0 ? `${pathSummary}; policies differ from ${activeRefName}` : pathSummary;
|
|
11618
11736
|
const diagnostics = findings.map((finding) => finding.diagnostic);
|
|
11619
11737
|
const document = {
|
|
11620
11738
|
ok: true,
|
|
11621
11739
|
spaces: statusSpaces,
|
|
11622
11740
|
summary,
|
|
11623
|
-
diagnostics: findings.map((finding) => finding.document)
|
|
11741
|
+
diagnostics: findings.map((finding) => finding.document),
|
|
11742
|
+
...ifDefined("policyDifferences", differences?.map(policyDifferenceJson))
|
|
11624
11743
|
};
|
|
11625
|
-
const alarming = divergedMarker !== void 0 || totalPending > 0 || noPath !== void 0;
|
|
11744
|
+
const alarming = divergedMarker !== void 0 || totalPending > 0 || noPath !== void 0 || differences !== void 0 && differences.length > 0;
|
|
11626
11745
|
return ok$1(ctx.present({
|
|
11627
11746
|
data: document,
|
|
11628
11747
|
diagnostics
|
|
@@ -11637,6 +11756,7 @@ const migrationStatusCommand = defineOrmCommand({
|
|
|
11637
11756
|
migrationsDir: displayPath(migrationsDir, ctx.cwd),
|
|
11638
11757
|
database: connects && typeof dbConnection === "string" ? maskConnectionUrl(dbConnection) : void 0,
|
|
11639
11758
|
ref: activeRefName,
|
|
11759
|
+
differences: differences ?? [],
|
|
11640
11760
|
from: args.flags.from,
|
|
11641
11761
|
space: args.flags.space,
|
|
11642
11762
|
legend: args.flags.legend ? renderMigrationGraphLegend({
|