@prisma-next/cli 0.12.0-dev.3 → 0.12.0-dev.31
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 +180 -163
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-KgJorIvG.mjs → client-xeWpMlq1.mjs} +39 -15
- package/dist/client-xeWpMlq1.mjs.map +1 -0
- package/dist/{command-helpers-Bbw1GbwL.mjs → command-helpers-DK_5ItoJ.mjs} +284 -24
- package/dist/command-helpers-DK_5ItoJ.mjs.map +1 -0
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.mjs +4 -5
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.mjs +3 -3
- package/dist/commands/db-sign.mjs +4 -4
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +10 -7
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.mjs +1 -1
- package/dist/commands/migrate.d.mts +1 -1
- package/dist/commands/migrate.mjs +5 -6
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/migration-check.mjs +1 -1
- package/dist/commands/migration-graph.d.mts +13 -7
- package/dist/commands/migration-graph.d.mts.map +1 -1
- package/dist/commands/migration-graph.mjs +171 -2
- package/dist/commands/migration-graph.mjs.map +1 -0
- package/dist/commands/migration-list.d.mts +24 -26
- package/dist/commands/migration-list.d.mts.map +1 -1
- package/dist/commands/migration-list.mjs +2 -190
- package/dist/commands/migration-log.d.mts +6 -18
- package/dist/commands/migration-log.d.mts.map +1 -1
- package/dist/commands/migration-log.mjs +1 -137
- package/dist/commands/migration-new.mjs +3 -3
- package/dist/commands/migration-plan.d.mts +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.d.mts +1 -1
- package/dist/commands/migration-show.mjs +3 -4
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +41 -141
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +2 -759
- package/dist/commands/ref.d.mts +1 -1
- package/dist/commands/ref.mjs +3 -3
- package/dist/commands/telemetry/index.d.mts +7 -0
- package/dist/commands/telemetry/index.d.mts.map +1 -0
- package/dist/commands/telemetry/index.mjs +2 -0
- package/dist/{contract-at-errors-BxP-TOMl.mjs → contract-at-errors-DG3kjgoz.mjs} +2 -2
- package/dist/{contract-at-errors-BxP-TOMl.mjs.map → contract-at-errors-DG3kjgoz.mjs.map} +1 -1
- package/dist/{contract-emit-D-4jrNve.mjs → contract-emit-BO0l6fnT.mjs} +3 -3
- package/dist/{contract-emit-D-4jrNve.mjs.map → contract-emit-BO0l6fnT.mjs.map} +1 -1
- package/dist/{contract-emit-DxcGl4Uq.mjs → contract-emit-C0Bs0VRj.mjs} +3 -3
- package/dist/{contract-emit-DxcGl4Uq.mjs.map → contract-emit-C0Bs0VRj.mjs.map} +1 -1
- package/dist/{contract-infer-D8uEbJuu.mjs → contract-infer-2wtPflGH.mjs} +3 -3
- package/dist/{contract-infer-D8uEbJuu.mjs.map → contract-infer-2wtPflGH.mjs.map} +1 -1
- package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs → contract-space-aggregate-loader-Dbr3-jHF.mjs} +4 -4
- package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs.map → contract-space-aggregate-loader-Dbr3-jHF.mjs.map} +1 -1
- package/dist/{db-verify-v_vUKXTU.mjs → db-verify-CxHiSiTG.mjs} +4 -4
- package/dist/{db-verify-v_vUKXTU.mjs.map → db-verify-CxHiSiTG.mjs.map} +1 -1
- package/dist/exports/control-api.d.mts +1 -1
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +2 -2
- package/dist/exports/index.mjs +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/{framework-components-fYXjz_in.mjs → framework-components-CxOVKAAh.mjs} +2 -2
- package/dist/{framework-components-fYXjz_in.mjs.map → framework-components-CxOVKAAh.mjs.map} +1 -1
- package/dist/{global-flags-DEHjV8_s.d.mts → global-flags-DG4uY5tV.d.mts} +1 -1
- package/dist/{global-flags-DEHjV8_s.d.mts.map → global-flags-DG4uY5tV.d.mts.map} +1 -1
- package/dist/{init-Cv9UzWL5.mjs → init-R272pxux.mjs} +5 -58
- package/dist/init-R272pxux.mjs.map +1 -0
- package/dist/{inspect-live-schema-C6ohV_oQ.mjs → inspect-live-schema-RekOwfi5.mjs} +3 -3
- package/dist/{inspect-live-schema-C6ohV_oQ.mjs.map → inspect-live-schema-RekOwfi5.mjs.map} +1 -1
- package/dist/{migration-check-BiBJoYYW.mjs → migration-check-Dc0cOhKH.mjs} +2 -2
- package/dist/{migration-check-BiBJoYYW.mjs.map → migration-check-Dc0cOhKH.mjs.map} +1 -1
- package/dist/{migration-command-scaffold-CjvwO6at.mjs → migration-command-scaffold-ApB3NxWY.mjs} +3 -3
- package/dist/{migration-command-scaffold-CjvwO6at.mjs.map → migration-command-scaffold-ApB3NxWY.mjs.map} +1 -1
- package/dist/migration-graph-space-render-dmLLWift.mjs +1966 -0
- package/dist/migration-graph-space-render-dmLLWift.mjs.map +1 -0
- package/dist/migration-list-C5sXrl0U.mjs +228 -0
- package/dist/migration-list-C5sXrl0U.mjs.map +1 -0
- package/dist/migration-list-types-DS63IdFd.d.mts +23 -0
- package/dist/migration-list-types-DS63IdFd.d.mts.map +1 -0
- package/dist/migration-log-DD_vCbYW.mjs +203 -0
- package/dist/migration-log-DD_vCbYW.mjs.map +1 -0
- package/dist/{migration-plan-9DJ7q7_z.mjs → migration-plan-CeTjQOIG.mjs} +5 -5
- package/dist/{migration-plan-9DJ7q7_z.mjs.map → migration-plan-CeTjQOIG.mjs.map} +1 -1
- package/dist/migration-status-qV8ctwPy.mjs +432 -0
- package/dist/migration-status-qV8ctwPy.mjs.map +1 -0
- package/dist/{output-B60Gw5fu.mjs → output-CF_hqzI-.mjs} +1 -1
- package/dist/{output-B60Gw5fu.mjs.map → output-CF_hqzI-.mjs.map} +1 -1
- package/dist/{ref-advancement-DUZqsue6.mjs → ref-advancement-V1o-9LVK.mjs} +1 -1
- package/dist/{ref-advancement-DUZqsue6.mjs.map → ref-advancement-V1o-9LVK.mjs.map} +1 -1
- package/dist/telemetry-S-NGi9U6.mjs +122 -0
- package/dist/telemetry-S-NGi9U6.mjs.map +1 -0
- package/dist/{types-Dt_SfqFm.d.mts → types-Mh7mdPHM.d.mts} +13 -2
- package/dist/types-Mh7mdPHM.d.mts.map +1 -0
- package/dist/{verify-DCA9Sldu.mjs → verify-BdI-BgYi.mjs} +2 -2
- package/dist/{verify-DCA9Sldu.mjs.map → verify-BdI-BgYi.mjs.map} +1 -1
- package/package.json +22 -19
- package/src/cli.ts +5 -0
- package/src/commands/db-update.ts +7 -1
- package/src/commands/init/index.ts +6 -35
- package/src/commands/init/init.ts +1 -14
- package/src/commands/init/inputs.ts +0 -75
- package/src/commands/migration-graph.ts +143 -82
- package/src/commands/migration-list.ts +55 -25
- package/src/commands/migration-log.ts +23 -89
- package/src/commands/migration-status-overlay.ts +61 -0
- package/src/commands/migration-status.ts +431 -1055
- package/src/commands/telemetry/index.ts +107 -0
- package/src/commands/telemetry/status.ts +67 -0
- package/src/control-api/client.ts +11 -1
- package/src/control-api/operations/apply.ts +1 -0
- package/src/control-api/operations/db-apply.ts +24 -1
- package/src/control-api/operations/migration-apply.ts +10 -3
- package/src/control-api/types.ts +16 -1
- package/src/utils/cli-errors.ts +17 -0
- package/src/utils/formatters/errors.ts +11 -0
- package/src/utils/formatters/migration-graph-lane-colors.ts +194 -0
- package/src/utils/formatters/migration-graph-layout.ts +51 -7
- package/src/utils/formatters/migration-graph-rows.ts +128 -15
- package/src/utils/formatters/migration-graph-space-render.ts +138 -0
- package/src/utils/formatters/migration-graph-tree-render.ts +405 -77
- package/src/utils/formatters/migration-list-data-column.ts +4 -91
- package/src/utils/formatters/migration-list-graph-topology.ts +68 -90
- package/src/utils/formatters/migration-list-render.ts +122 -70
- package/src/utils/formatters/migration-list-styler.ts +48 -5
- package/src/utils/formatters/migration-log-table.ts +190 -0
- package/src/utils/formatters/migrations.ts +25 -1
- package/src/utils/global-flags.ts +35 -0
- package/src/utils/legend.ts +38 -0
- package/src/utils/telemetry.ts +68 -32
- package/dist/client-KgJorIvG.mjs.map +0 -1
- package/dist/command-helpers-Bbw1GbwL.mjs.map +0 -1
- package/dist/commands/migration-list.mjs.map +0 -1
- package/dist/commands/migration-log.mjs.map +0 -1
- package/dist/commands/migration-status.mjs.map +0 -1
- package/dist/graph-render-rFAqZujX.mjs +0 -1081
- package/dist/graph-render-rFAqZujX.mjs.map +0 -1
- package/dist/init-Cv9UzWL5.mjs.map +0 -1
- package/dist/migration-graph-D7DVUElV.mjs +0 -1232
- package/dist/migration-graph-D7DVUElV.mjs.map +0 -1
- package/dist/migration-list-styler-BRwF4-gy.mjs +0 -399
- package/dist/migration-list-styler-BRwF4-gy.mjs.map +0 -1
- package/dist/migration-types-D2FW63pr.d.mts +0 -15
- package/dist/migration-types-D2FW63pr.d.mts.map +0 -1
- package/dist/migrations-Cv2jxNNK.mjs +0 -228
- package/dist/migrations-Cv2jxNNK.mjs.map +0 -1
- package/dist/types-Dt_SfqFm.d.mts.map +0 -1
- package/src/utils/formatters/graph-migration-mapper.ts +0 -235
- package/src/utils/formatters/graph-render.ts +0 -1323
- package/src/utils/formatters/graph-types.ts +0 -120
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { EMPTY_CONTRACT_HASH } from '@prisma-next/migration-tools/constants';
|
|
1
|
+
import type { LedgerEntryRecord } from '@prisma-next/contract/types';
|
|
3
2
|
import { MigrationToolsError } from '@prisma-next/migration-tools/errors';
|
|
4
|
-
import { findPath } from '@prisma-next/migration-tools/migration-graph';
|
|
5
3
|
import { notOk, ok, type Result } from '@prisma-next/utils/result';
|
|
6
|
-
import { cyan, dim } from 'colorette';
|
|
7
4
|
import { Command } from 'commander';
|
|
8
5
|
import { loadConfig } from '../config-loader';
|
|
9
6
|
import { createControlClient } from '../control-api/client';
|
|
@@ -23,7 +20,12 @@ import {
|
|
|
23
20
|
setCommandSeeAlso,
|
|
24
21
|
targetSupportsMigrations,
|
|
25
22
|
} from '../utils/command-helpers';
|
|
26
|
-
import {
|
|
23
|
+
import { createAnsiMigrationListStyler } from '../utils/formatters/migration-list-styler';
|
|
24
|
+
import {
|
|
25
|
+
MIGRATION_LOG_EMPTY_MESSAGE,
|
|
26
|
+
renderMigrationLogTable,
|
|
27
|
+
serializeLedgerEntriesForJson,
|
|
28
|
+
} from '../utils/formatters/migration-log-table';
|
|
27
29
|
import { formatStyledHeader } from '../utils/formatters/styled';
|
|
28
30
|
import type { CommonCommandOptions } from '../utils/global-flags';
|
|
29
31
|
import { type GlobalFlags, parseGlobalFlagsOrExit } from '../utils/global-flags';
|
|
@@ -33,34 +35,16 @@ import { createTerminalUI, type TerminalUI } from '../utils/terminal-ui';
|
|
|
33
35
|
interface MigrationLogOptions extends CommonCommandOptions {
|
|
34
36
|
readonly db?: string;
|
|
35
37
|
readonly config?: string;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export interface MigrationLogEntry {
|
|
39
|
-
readonly dirName: string;
|
|
40
|
-
readonly from: string;
|
|
41
|
-
readonly to: string;
|
|
42
|
-
readonly migrationHash: string;
|
|
43
|
-
readonly operationCount: number;
|
|
44
|
-
readonly createdAt: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface MigrationLogResult {
|
|
48
|
-
readonly ok: true;
|
|
49
|
-
readonly markerHash: string | null;
|
|
50
|
-
readonly applied: readonly MigrationLogEntry[];
|
|
51
|
-
readonly summary: string;
|
|
38
|
+
readonly utc?: boolean;
|
|
52
39
|
}
|
|
53
40
|
|
|
54
41
|
export async function executeMigrationLogCommand(
|
|
55
42
|
options: MigrationLogOptions,
|
|
56
43
|
flags: GlobalFlags,
|
|
57
44
|
ui: TerminalUI,
|
|
58
|
-
): Promise<Result<
|
|
45
|
+
): Promise<Result<readonly LedgerEntryRecord[], CliStructuredError>> {
|
|
59
46
|
const config = await loadConfig(options.config);
|
|
60
|
-
const { configPath
|
|
61
|
-
options.config,
|
|
62
|
-
config,
|
|
63
|
-
);
|
|
47
|
+
const { configPath } = resolveMigrationPaths(options.config, config);
|
|
64
48
|
|
|
65
49
|
const dbConnection = options.db ?? config.db?.connection;
|
|
66
50
|
if (!dbConnection) {
|
|
@@ -81,10 +65,9 @@ export async function executeMigrationLogCommand(
|
|
|
81
65
|
if (!flags.json && !flags.quiet) {
|
|
82
66
|
const header = formatStyledHeader({
|
|
83
67
|
command: 'migration log',
|
|
84
|
-
description: 'Show executed migration history',
|
|
68
|
+
description: 'Show executed migration history from the database ledger',
|
|
85
69
|
details: [
|
|
86
70
|
{ label: 'config', value: configPath },
|
|
87
|
-
{ label: 'migrations', value: appMigrationsRelative },
|
|
88
71
|
...(typeof dbConnection === 'string'
|
|
89
72
|
? [{ label: 'database', value: maskConnectionUrl(dbConnection) }]
|
|
90
73
|
: []),
|
|
@@ -94,13 +77,6 @@ export async function executeMigrationLogCommand(
|
|
|
94
77
|
ui.stderr(header);
|
|
95
78
|
}
|
|
96
79
|
|
|
97
|
-
const loaded = await buildReadAggregate(config, { migrationsDir });
|
|
98
|
-
if (!loaded.ok) {
|
|
99
|
-
return loaded;
|
|
100
|
-
}
|
|
101
|
-
const graph = loaded.value.aggregate.app.graph();
|
|
102
|
-
const bundles = loaded.value.aggregate.app.packages;
|
|
103
|
-
|
|
104
80
|
const client = createControlClient({
|
|
105
81
|
family: config.family,
|
|
106
82
|
target: config.target,
|
|
@@ -111,47 +87,8 @@ export async function executeMigrationLogCommand(
|
|
|
111
87
|
|
|
112
88
|
try {
|
|
113
89
|
await client.connect(dbConnection);
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (!markerHash) {
|
|
118
|
-
return ok({
|
|
119
|
-
ok: true,
|
|
120
|
-
markerHash: null,
|
|
121
|
-
applied: [],
|
|
122
|
-
summary: 'No migrations applied (database has no marker)',
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const appliedPath = findPath(graph, EMPTY_CONTRACT_HASH, markerHash);
|
|
127
|
-
if (appliedPath === null) {
|
|
128
|
-
return notOk(
|
|
129
|
-
errorUnexpected('Database marker is not reachable from migration history', {
|
|
130
|
-
why: `Marker hash ${markerHash} is not reachable from the root of the on-disk migration graph.`,
|
|
131
|
-
fix: 'The database may have been migrated outside this project. Use `migration status` to inspect the current state.',
|
|
132
|
-
}),
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
const pkgByDirName = new Map(bundles.map((p) => [p.dirName, p]));
|
|
136
|
-
const entries: MigrationLogEntry[] = appliedPath.map((edge) => {
|
|
137
|
-
const pkg = pkgByDirName.get(edge.dirName);
|
|
138
|
-
const ops = (pkg?.ops ?? []) as readonly MigrationPlanOperation[];
|
|
139
|
-
return {
|
|
140
|
-
dirName: edge.dirName,
|
|
141
|
-
from: edge.from,
|
|
142
|
-
to: edge.to,
|
|
143
|
-
migrationHash: edge.migrationHash,
|
|
144
|
-
operationCount: ops.length,
|
|
145
|
-
createdAt: edge.createdAt,
|
|
146
|
-
};
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
return ok({
|
|
150
|
-
ok: true,
|
|
151
|
-
markerHash,
|
|
152
|
-
applied: entries,
|
|
153
|
-
summary: `${entries.length} migration(s) applied`,
|
|
154
|
-
});
|
|
90
|
+
const ledger = await client.readLedger();
|
|
91
|
+
return ok(ledger);
|
|
155
92
|
} catch (error) {
|
|
156
93
|
if (CliStructuredError.is(error)) return notOk(error);
|
|
157
94
|
if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
|
|
@@ -170,11 +107,12 @@ export function createMigrationLogCommand(): Command {
|
|
|
170
107
|
setCommandDescriptions(
|
|
171
108
|
command,
|
|
172
109
|
'Show executed migration history',
|
|
173
|
-
'Reads the database
|
|
174
|
-
'
|
|
110
|
+
'Reads the database ledger and displays every applied migration edge\n' +
|
|
111
|
+
'in chronological order, including rollbacks and re-applies.',
|
|
175
112
|
);
|
|
176
113
|
setCommandExamples(command, [
|
|
177
114
|
'prisma-next migration log --db $DATABASE_URL',
|
|
115
|
+
'prisma-next migration log --utc --db $DATABASE_URL',
|
|
178
116
|
'prisma-next migration log --json --db $DATABASE_URL',
|
|
179
117
|
]);
|
|
180
118
|
setCommandSeeAlso(command, [
|
|
@@ -186,24 +124,20 @@ export function createMigrationLogCommand(): Command {
|
|
|
186
124
|
addGlobalOptions(command)
|
|
187
125
|
.option('--db <url>', 'Database connection string')
|
|
188
126
|
.option('--config <path>', 'Path to prisma-next.config.ts')
|
|
127
|
+
.option('--utc', 'Render human timestamps in UTC instead of local time')
|
|
189
128
|
.action(async (options: MigrationLogOptions) => {
|
|
190
129
|
const flags = parseGlobalFlagsOrExit(options);
|
|
191
130
|
const ui = createTerminalUI(flags);
|
|
192
131
|
const result = await executeMigrationLogCommand(options, flags, ui);
|
|
193
|
-
const exitCode = handleResult(result, flags, ui, (
|
|
132
|
+
const exitCode = handleResult(result, flags, ui, (entries) => {
|
|
194
133
|
if (flags.json) {
|
|
195
|
-
ui.output(JSON.stringify(
|
|
134
|
+
ui.output(JSON.stringify(serializeLedgerEntriesForJson(entries), null, 2));
|
|
196
135
|
} else if (!flags.quiet) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
ui.log(logResult.summary);
|
|
136
|
+
if (entries.length === 0) {
|
|
137
|
+
ui.output(MIGRATION_LOG_EMPTY_MESSAGE);
|
|
200
138
|
} else {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
`${c(cyan, '✓')} ${entry.dirName} ${c(dim, entry.migrationHash.slice(0, 16) + '…')} ${entry.operationCount} op(s)`,
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
ui.log(`\n${logResult.summary}`);
|
|
139
|
+
const styler = createAnsiMigrationListStyler({ useColor: ui.useColor });
|
|
140
|
+
ui.output(renderMigrationLogTable(entries, { utc: options.utc === true, styler }));
|
|
207
141
|
}
|
|
208
142
|
}
|
|
209
143
|
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { MigrationGraph } from '@prisma-next/migration-tools/graph';
|
|
2
|
+
import { findPath } from '@prisma-next/migration-tools/migration-graph';
|
|
3
|
+
import type { MigrationEdgeAnnotation } from '../utils/formatters/migration-graph-tree-render';
|
|
4
|
+
|
|
5
|
+
export interface DeriveStatusEdgeAnnotationsInput {
|
|
6
|
+
readonly graph: MigrationGraph;
|
|
7
|
+
readonly targetHash: string;
|
|
8
|
+
readonly originHash: string;
|
|
9
|
+
readonly appliedMigrationHashes: ReadonlySet<string>;
|
|
10
|
+
readonly showAppliedOverlay: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function deriveStatusEdgeAnnotations(
|
|
14
|
+
input: DeriveStatusEdgeAnnotationsInput,
|
|
15
|
+
): ReadonlyMap<string, MigrationEdgeAnnotation> {
|
|
16
|
+
const annotations = new Map<string, MigrationEdgeAnnotation>();
|
|
17
|
+
|
|
18
|
+
if (input.showAppliedOverlay) {
|
|
19
|
+
for (const edge of input.graph.migrationByHash.values()) {
|
|
20
|
+
if (input.appliedMigrationHashes.has(edge.migrationHash)) {
|
|
21
|
+
annotations.set(edge.migrationHash, { status: 'applied' });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!input.graph.nodes.has(input.originHash)) {
|
|
27
|
+
return annotations;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const pendingPath = findPath(input.graph, input.originHash, input.targetHash);
|
|
31
|
+
if (!pendingPath) {
|
|
32
|
+
return annotations;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
for (const edge of pendingPath) {
|
|
36
|
+
if (input.appliedMigrationHashes.has(edge.migrationHash)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const existing = annotations.get(edge.migrationHash);
|
|
40
|
+
if (existing?.status === 'applied') {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
annotations.set(edge.migrationHash, { status: 'pending' });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return annotations;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function appliedHashesFromLedger(
|
|
50
|
+
ledgerEntries: ReadonlyArray<{ readonly migrationHash: string }>,
|
|
51
|
+
): ReadonlySet<string> {
|
|
52
|
+
return new Set(ledgerEntries.map((entry) => entry.migrationHash));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function statusForMigrationHash(
|
|
56
|
+
migrationHash: string,
|
|
57
|
+
annotations: ReadonlyMap<string, MigrationEdgeAnnotation>,
|
|
58
|
+
): 'applied' | 'pending' | null {
|
|
59
|
+
const status = annotations.get(migrationHash)?.status;
|
|
60
|
+
return status ?? null;
|
|
61
|
+
}
|