Flyway Validate: Cannot determine latest applied migration. Was the metadata table manually modified?
Siendo un proyecto Open Source me encontré el código con facilidad y pude ver qué tipo de consulta estaba tratando de ejecutar. Podemos ver en el código que busca por la columna "CURRENT_VERSION":
/**
* @return The latest migration applied on the schema. {@code null} if no migration has been applied so far.
*/
public MetaDataTableRow latestAppliedMigration() {
if (!hasRows()) {
return null;
}
String query = getSelectStatement() + " where current_version=" + dbSupport.getBooleanTrue();
@SuppressWarnings({"unchecked"})
final List metaDataTableRows = jdbcTemplate.query(query, new MetaDataTableRowMapper());
if (metaDataTableRows.isEmpty()) {
if (hasRows()) {
throw new FlywayException("Cannot determine latest applied migration. Was the metadata table manually modified?");
}
return null;
}
return metaDataTableRows.get(0);
}
...
/**
* @return The select statement for reading the metadata table.
*/
private String getSelectStatement() {
return "select VERSION, DESCRIPTION, TYPE, SCRIPT, CHECKSUM, INSTALLED_ON, EXECUTION_TIME, STATE from " + schema + "." + table;
}
Así que indetifiqué la última versión aplicada y manualmente le puse el valor de la columna en 1. Problema resuelto.