Flyway Validate: Cannot determine latest applied migration. Was the metadata table manually modified?
Given that Flyway is an Open Source project, it wasn't very hard to find the code and search for the error string. We can see what the code does is to look for the column "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 ListSo I just identified the last applied migration and manually set the column "CURRENT_VERSION" in 1. Problem solved!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; }
No comments:
Post a Comment