Skip to content

Commit

Permalink
FIX #2719 check provided name and give feedback if not.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gints Polis committed Aug 31, 2018
1 parent b794d0c commit e68538a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/commands/MigrationGenerateCommand.ts
Expand Up @@ -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`));
}
Expand Down

0 comments on commit e68538a

Please sign in to comment.