From e68538ab0dd63c23d24ccf93bb8c5cd3be525de6 Mon Sep 17 00:00:00 2001 From: Gints Polis Date: Fri, 31 Aug 2018 19:55:41 +0300 Subject: [PATCH] FIX #2719 check provided name and give feedback if not. --- src/commands/MigrationGenerateCommand.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/commands/MigrationGenerateCommand.ts b/src/commands/MigrationGenerateCommand.ts index 5856838c67..cdf52278c9 100644 --- a/src/commands/MigrationGenerateCommand.ts +++ b/src/commands/MigrationGenerateCommand.ts @@ -85,12 +85,15 @@ export class MigrationGenerateCommand { } if (upSqls.length) { - const fileContent = MigrationGenerateCommand.getTemplate(argv.name, timestamp, upSqls, downSqls.reverse()); - const path = process.cwd() + "/" + (directory ? (directory + "/") : "") + filename; - await CommandUtils.createFile(path, fileContent); - - console.log(chalk.green(`Migration ${chalk.blue(path)} has been generated successfully.`)); - + if (argv.name) { + const fileContent = MigrationGenerateCommand.getTemplate(argv.name, timestamp, upSqls, downSqls.reverse()); + const path = process.cwd() + "/" + (directory ? (directory + "/") : "") + filename; + await CommandUtils.createFile(path, fileContent); + + console.log(chalk.green(`Migration ${chalk.blue(path)} has been generated successfully.`)); + } else { + console.log(chalk.yellow("Please specify migration name")); + } } else { console.log(chalk.yellow(`No changes in database schema were found - cannot generate a migration. To create a new empty migration use "typeorm migration:create" command`)); }