Skip to content

Commit

Permalink
Merge pull request #2752 from gintsgints/2719
Browse files Browse the repository at this point in the history
FIX #2719 check provided name and give feedback if not.
  • Loading branch information
pleerock committed Oct 27, 2018
2 parents 79c98a0 + e68538a commit 099c654
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 099c654

Please sign in to comment.