From 5f02bae2f14607a41db702d733370bcdad76cb23 Mon Sep 17 00:00:00 2001 From: joeydebreuk Date: Wed, 8 Jul 2026 22:24:33 +0200 Subject: [PATCH] make migrations:run output explicit about dry runs With --dry-run, the fork, model creation and migration steps log the same messages as a real run, so it looks like changes were applied. Mark each message with the dry-run state instead. --- packages/cli/src/commands/migrations/run.ts | 26 +++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/migrations/run.ts b/packages/cli/src/commands/migrations/run.ts index 38e1e10..6235153 100644 --- a/packages/cli/src/commands/migrations/run.ts +++ b/packages/cli/src/commands/migrations/run.ts @@ -130,7 +130,9 @@ export default class Command extends CmaClientCommand { !!primaryEnv && primaryEnv.id === destinationEnvId; this.log( - `Migrations will be run in "${destinationEnvId}" ${ + `Migrations will be ${ + dryRun ? 'simulated (dry run)' : 'run' + } in "${destinationEnvId}" ${ destinationIsPrimary ? 'primary' : 'sandbox' } environment`, ); @@ -217,7 +219,9 @@ export default class Command extends CmaClientCommand { this.log( migrationScriptsToRun.length === 0 ? 'No new migration scripts to run, skipping operation' - : `Successfully run ${migrationScriptsToRun.length} migration scripts`, + : dryRun + ? `Successfully simulated ${migrationScriptsToRun.length} migration scripts (dry run, no changes were made)` + : `Successfully run ${migrationScriptsToRun.length} migration scripts`, ); return { @@ -237,7 +241,11 @@ export default class Command extends CmaClientCommand { ) { const relativePath = relative(migrationsDir, script.path); - this.startSpinner(`Running migration "${relativePath}"`); + this.startSpinner( + dryRun + ? `Simulating migration "${relativePath}" (dry run)` + : `Running migration "${relativePath}"`, + ); try { if (!dryRun) { @@ -337,7 +345,11 @@ export default class Command extends CmaClientCommand { ) { try { this.startSpinner( - `Creating a fork of "${sourceEnv.id}" environment called "${destinationEnvId}"`, + `Creating a fork of "${ + sourceEnv.id + }" environment called "${destinationEnvId}"${ + dryRun ? ' (dry run, skipped)' : '' + }`, ); const existingEnvironment = allEnvironments.find( @@ -412,7 +424,11 @@ export default class Command extends CmaClientCommand { return await client.itemTypes.find(migrationModelApiKey); } catch (e) { if (e instanceof CmaClient.ApiError && e.response.status === 404) { - this.startSpinner(`Creating "${migrationModelApiKey}" model`); + this.startSpinner( + `Creating "${migrationModelApiKey}" model${ + dryRun ? ' (dry run, skipped)' : '' + }`, + ); let migrationItemType: CmaClient.ApiTypes.ItemType | null = null;