hunk.code_window:             if (dataSource) await dataSource.destroy()
               PlatformTools.logCmdErr("Error during migration run:", err)
               process.exit(1)
           }
       }
   }
hunk.labels: keep keep replace keep keep keep keep
hunk.file_path: src/commands/MigrationRunCommand.ts
hunk.type: replace
file: import { DataSource } from "../data-source"
  import * as process from "process"
  import * as yargs from "yargs"
  import { PlatformTools } from "../platform/PlatformTools"
  import path from "path"
  import { CommandUtils } from "./CommandUtils"
  
  /**
   * Shows all migrations and whether they have been run or not.
   */
  export class MigrationShowCommand implements yargs.CommandModule {
      command = "migration:show"
      describe = "Show all migrations and whether they have been run or not"
  
      builder(args: yargs.Argv) {
          return args.option("dataSource", {
              alias: "d",
              describe:
                  "Path to the file where your DataSource instance is defined.",
              demandOption: true,
          })
      }
  
      async handler(args: yargs.Arguments) {
          let dataSource: DataSource | undefined = undefined
          try {
              dataSource = await CommandUtils.loadDataSource(
                  path.resolve(process.cwd(), args.dataSource as string),
              )
              dataSource.setOptions({
                  subscribers: [],
                  synchronize: false,
                  migrationsRun: false,
                  dropSchema: false,
                  logging: ["schema"],
              })
              await dataSource.initialize()
              await dataSource.showMigrations()
              await dataSource.destroy()
  
              process.exit(0)
          } catch (err) {
              if (dataSource) await dataSource.destroy()
              PlatformTools.logCmdErr("Error during migration show:", err)
              process.exit(1)
          }
      }
  }
  