async migrate(target = "") {
    const { commonClient, config } = this;
    const data = {};
    try {
      await commonClient.ensureTable();
      await this.getMigrations();
      let targetVersion;
      const cleaned = target.toLowerCase().trim();
      if (cleaned === "max" || cleaned === "") {
        targetVersion = await this.getMaxVersion();
      } else {
        targetVersion = Number(target);
      }
      data.targetVersion = targetVersion;
      if (target === undefined) {
        throw new Error("targetVersion undefined");
      }
      const databaseVersion = await this.getDatabaseVersion();
      data.databaseVersion = databaseVersion;
      if (config.validateChecksums && data.targetVersion >= databaseVersion) {
        await this.validateMigrations(databaseVersion);
      }
      const runnableMigrations = await this.getRunnableMigrations(
        data.databaseVersion,
        data.targetVersion
      );
      const migrations = await this.runMigrations(runnableMigrations);
      return migrations;
    } catch (error) {
      // Decorate error with empty appliedMigrations if not yet exist
      // Rethrow error to module user
      if (!error.appliedMigrations) {
        error.appliedMigrations = [];
      }
      throw error;
    }
  }
/**
   * Main method to move a schema to a particular version.
   * A target must be specified, otherwise nothing is run.
   *
   * @returns {Promise}
   * @param {String} target - version to migrate as string or number (handled as  numbers internally)
   */
Main method to move a schema to a particular version.
A target must be specified, otherwise nothing is run.

@returns {Promise}
@param {String} target - version to migrate as string or number (handled as  numbers internally)
Main method to move a schema to a particular version . A target must be specified otherwise nothing is run . @returns { Promise } @param { String } target - version to migrate as string or number ( handled as numbers internally )
async migrate(target = "") {
    const { commonClient, config } = this;
    const data = {};
    try {
      await commonClient.ensureTable();
      await this.getMigrations();
      let targetVersion;
      const cleaned = target.toLowerCase().trim();
      if (cleaned === "max" || cleaned === "") {
        targetVersion = await this.getMaxVersion();
      } else {
        targetVersion = Number(target);
      }
      data.targetVersion = targetVersion;
      if (target === undefined) {
        throw new Error("targetVersion undefined");
      }
      const databaseVersion = await this.getDatabaseVersion();
      data.databaseVersion = databaseVersion;
      if (config.validateChecksums && data.targetVersion >= databaseVersion) {
        await this.validateMigrations(databaseVersion);
      }
      const runnableMigrations = await this.getRunnableMigrations(
        data.databaseVersion,
        data.targetVersion
      );
      const migrations = await this.runMigrations(runnableMigrations);
      return migrations;
    } catch (error) {
      if (!error.appliedMigrations) {
        error.appliedMigrations = [];
      }
      throw error;
    }
  }
async migrate ( target = "" ) { const { commonClient , config } = this ; const data = { } ; try { await commonClient . ensureTable ( ) ; await this . getMigrations ( ) ; let targetVersion ; const cleaned = target . toLowerCase ( ) . trim ( ) ; if ( cleaned === "max" || cleaned === "" ) { targetVersion = await this . getMaxVersion ( ) ; } else { targetVersion = Number ( target ) ; } data . targetVersion = targetVersion ; if ( target === undefined ) { throw new Error ( "targetVersion undefined" ) ; } const databaseVersion = await this . getDatabaseVersion ( ) ; data . databaseVersion = databaseVersion ; if ( config . validateChecksums && data . targetVersion >= databaseVersion ) { await this . validateMigrations ( databaseVersion ) ; } const runnableMigrations = await this . getRunnableMigrations ( data . databaseVersion , data . targetVersion ) ; const migrations = await this . runMigrations ( runnableMigrations ) ; return migrations ; } catch ( error ) { if ( ! error . appliedMigrations ) { error . appliedMigrations = [ ] ; } throw error ; } }
Main method to move a schema to a particular version.
Main method to move a schema to a particular version .
// Decorate error with empty appliedMigrations if not yet exist // Rethrow error to module user