async validateMigrations(databaseVersion) {
    const migrations = await this.getMigrations();

    const validateMigrations = migrations.filter(
      (migration) =>
        migration.action === "do" &&
        migration.version > 0 &&
        migration.version <= databaseVersion
    );

    for (const migration of validateMigrations) {
      this.emit("validation-started", migration);
      const sql = this.commonClient.getMd5Sql(migration);
      const results = await this.commonClient.runQuery(sql);
      const md5 = results.rows && results.rows[0] && results.rows[0].md5;
      // IF md5 exists in DB and on migration, it means we should validate the md5
      // (JS migrations no longer generate an md5 because they can be so dynamic.
      // Deleting an md5 from database could be useful for skipping a problematic check)
      if (md5 && migration.md5 && md5 !== migration.md5) {
        const msg = `MD5 checksum failed for migration [${migration.version}]`;
        throw new Error(msg);
      }
      this.emit("validation-finished", migration);
    }

    return validateMigrations;
  }
/**
   * Validate md5 checksums for applied migrations
   *
   * @returns {Promise}
   * @param {Number} databaseVersion
   */
Validate md5 checksums for applied migrations
@returns {Promise}
@param {Number} databaseVersion
Validate md5 checksums for applied migrations @returns { Promise } @param { Number } databaseVersion
async validateMigrations(databaseVersion) {
    const migrations = await this.getMigrations();
    const validateMigrations = migrations.filter(
      (migration) =>
        migration.action === "do" &&
        migration.version > 0 &&
        migration.version <= databaseVersion
    );
    for (const migration of validateMigrations) {
      this.emit("validation-started", migration);
      const sql = this.commonClient.getMd5Sql(migration);
      const results = await this.commonClient.runQuery(sql);
      const md5 = results.rows && results.rows[0] && results.rows[0].md5;
      if (md5 && migration.md5 && md5 !== migration.md5) {
        const msg = `MD5 checksum failed for migration [${migration.version}]`;
        throw new Error(msg);
      }
      this.emit("validation-finished", migration);
    }
    return validateMigrations;
  }
async validateMigrations ( databaseVersion ) { const migrations = await this . getMigrations ( ) ; const validateMigrations = migrations . filter ( ( migration ) => migration . action === "do" && migration . version > 0 && migration . version <= databaseVersion ) ; for ( const migration of validateMigrations ) { this . emit ( "validation-started" , migration ) ; const sql = this . commonClient . getMd5Sql ( migration ) ; const results = await this . commonClient . runQuery ( sql ) ; const md5 = results . rows && results . rows [ 0 ] && results . rows [ 0 ] . md5 ; if ( md5 && migration . md5 && md5 !== migration . md5 ) { const msg = ` ${ migration . version } ` ; throw new Error ( msg ) ; } this . emit ( "validation-finished" , migration ) ; } return validateMigrations ; }
Validate md5 checksums for applied migrations
 @returns {Promise}
 @param {Number} databaseVersion
Validate md5 checksums for applied migrations @returns { Promise } @param { Number } databaseVersion
// IF md5 exists in DB and on migration, it means we should validate the md5 // (JS migrations no longer generate an md5 because they can be so dynamic. // Deleting an md5 from database could be useful for skipping a problematic check)