code: func getCurrentVersion(db *sql.Tx, catalog string) (int64, error) {
  	query := `SELECT EXISTS(
  				SELECT 1 FROM information_schema.tables
  				WHERE table_catalog=$1
  				AND table_name='version')`
  	row := db.QueryRow(query, catalog)
  
  	var exists bool
  	if err := row.Scan(&exists); err != nil {
  		return -1, errs.Errorf(`failed to scan if table "version" exists: %s\n`, err)
  	}
  
  	if !exists {
  		// table doesn't exist
  		return -1, nil
  	}
  
  	row = db.QueryRow("SELECT max(version) as current FROM version")
  
  	var current int64 = -1
  	if err := row.Scan(&current); err != nil {
  		return -1, errs.Errorf(`failed to scan max version in table "version": %s\n`, err)
  	}
  
  	return current, nil
  }
docs: // getCurrentVersion returns the highest version from the version
  // table or -1 if that table does not exist.
  //
  // Returning -1 simplifies the logic of the migration process because
  // the next version is always the current version + 1 which results
  // in -1 + 1 = 0 which is exactly what we want as the first version.