hunk.code_window:  * Generates a new migration file with sql needs to be executed to update schema.
    */
   export class MigrationGenerateCommand {
       command = "migrations:generate";
       describe = "Generates a new migration file with sql needs to be executed to update schema.";
       builder(yargs: any) {
           return yargs
  
hunk.labels: keep keep keep keep replace keep keep keep keep
hunk.after_edit:     command = "migration:generate";
  
hunk.file_path: src/commands/MigrationGenerateCommand.ts
hunk.type: replace
file: import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader";
  import {CommandUtils} from "./CommandUtils";
  const chalk = require("chalk");
  
  /**
   * Creates a new migration file.
   */
  export class MigrationCreateCommand {
  
      command = "migrations:create";
      describe = "Creates a new migration file.";
  
      builder(yargs: any) {
          return yargs
              .option("c", {
                  alias: "connection",
                  default: "default",
                  describe: "Name of the connection on which run a query."
              })
              .option("n", {
                  alias: "name",
                  describe: "Name of the migration class.",
                  demand: true
              })
              .option("d", {
                  alias: "dir",
                  describe: "Directory where migration should be created."
              })
              .option("f", {
                  alias: "config",
                  default: "ormconfig",
                  describe: "Name of the file with connection configuration."
              });
      }
  
      async handler(argv: any) {
          try {
              const timestamp = new Date().getTime();
              const fileContent = MigrationCreateCommand.getTemplate(argv.name, timestamp);
              const filename = timestamp + "-" + argv.name + ".ts";
              let directory = argv.dir;
  
              // if directory is not set then try to open tsconfig and find default path there
              if (!directory) {
                  try {
                      const connectionOptionsReader = new ConnectionOptionsReader({ root: process.cwd(), configName: argv.config });
                      const connectionOptions = await connectionOptionsReader.get(argv.connection);
                      directory = connectionOptions.cli ? connectionOptions.cli.migrationsDir : undefined;
                  } catch (err) { }
              }
  
              const path = process.cwd() + "/" + (directory ? (directory + "/") : "") + filename;
              await CommandUtils.createFile(path, fileContent);
              console.log(`Migration ${chalk.blue(path)} has been generated successfully.`);
  
          } catch (err) {
              console.log(chalk.black.bgRed("Error during migration creation:"));
              console.error(err);
              process.exit(1);
          }
      }
  
      // -------------------------------------------------------------------------
      // Protected Static Methods
      // -------------------------------------------------------------------------
  
      /**
       * Gets contents of the migration file.
       */
      protected static getTemplate(name: string, timestamp: number): string {
          return `import {MigrationInterface, QueryRunner} from "typeorm";
  
  export class ${name}${timestamp} implements MigrationInterface {
  
      public async up(queryRunner: QueryRunner): Promise<any> {
      }
  
      public async down(queryRunner: QueryRunner): Promise<any> {
      }
  
  }
  `;
      }
  
  }