use of org.flywaydb.core.api.migration.MigrationInfoProvider in project flyway by flyway.
the class JdbcMigrationResolver method extractMigrationInfo.
/**
* Extracts the migration info from this migration.
*
* @param jdbcMigration The migration to analyse.
* @return The migration info.
*/
/* private -> testing */
ResolvedMigrationImpl extractMigrationInfo(JdbcMigration jdbcMigration) {
Integer checksum = null;
if (jdbcMigration instanceof MigrationChecksumProvider) {
MigrationChecksumProvider checksumProvider = (MigrationChecksumProvider) jdbcMigration;
checksum = checksumProvider.getChecksum();
}
MigrationVersion version;
String description;
if (jdbcMigration instanceof MigrationInfoProvider) {
MigrationInfoProvider infoProvider = (MigrationInfoProvider) jdbcMigration;
version = infoProvider.getVersion();
description = infoProvider.getDescription();
if (!StringUtils.hasText(description)) {
throw new FlywayException("Missing description for migration " + version);
}
} else {
String shortName = ClassUtils.getShortName(jdbcMigration.getClass());
String prefix;
if (shortName.startsWith("V") || shortName.startsWith("R")) {
prefix = shortName.substring(0, 1);
} else {
throw new FlywayException("Invalid Jdbc migration class name: " + jdbcMigration.getClass().getName() + " => ensure it starts with V or R," + " or implement org.flywaydb.core.api.migration.MigrationInfoProvider for non-default naming");
}
Pair<MigrationVersion, String> info = MigrationInfoHelper.extractVersionAndDescription(shortName, prefix, "__", "");
version = info.getLeft();
description = info.getRight();
}
ResolvedMigrationImpl resolvedMigration = new ResolvedMigrationImpl();
resolvedMigration.setVersion(version);
resolvedMigration.setDescription(description);
resolvedMigration.setScript(jdbcMigration.getClass().getName());
resolvedMigration.setChecksum(checksum);
resolvedMigration.setType(MigrationType.JDBC);
return resolvedMigration;
}
use of org.flywaydb.core.api.migration.MigrationInfoProvider in project flyway by flyway.
the class SpringJdbcMigrationResolver method extractMigrationInfo.
/**
* Extracts the migration info from this migration.
*
* @param springJdbcMigration The migration to analyse.
* @return The migration info.
*/
/* private -> testing */
ResolvedMigrationImpl extractMigrationInfo(SpringJdbcMigration springJdbcMigration) {
Integer checksum = null;
if (springJdbcMigration instanceof MigrationChecksumProvider) {
MigrationChecksumProvider checksumProvider = (MigrationChecksumProvider) springJdbcMigration;
checksum = checksumProvider.getChecksum();
}
MigrationVersion version;
String description;
if (springJdbcMigration instanceof MigrationInfoProvider) {
MigrationInfoProvider infoProvider = (MigrationInfoProvider) springJdbcMigration;
version = infoProvider.getVersion();
description = infoProvider.getDescription();
if (!StringUtils.hasText(description)) {
throw new FlywayException("Missing description for migration " + version);
}
} else {
String shortName = ClassUtils.getShortName(springJdbcMigration.getClass());
String prefix;
if (shortName.startsWith("V") || shortName.startsWith("R")) {
prefix = shortName.substring(0, 1);
} else {
throw new FlywayException("Invalid Jdbc migration class name: " + springJdbcMigration.getClass().getName() + " => ensure it starts with V or R," + " or implement org.flywaydb.core.api.migration.MigrationInfoProvider for non-default naming");
}
Pair<MigrationVersion, String> info = MigrationInfoHelper.extractVersionAndDescription(shortName, prefix, "__", "");
version = info.getLeft();
description = info.getRight();
}
ResolvedMigrationImpl resolvedMigration = new ResolvedMigrationImpl();
resolvedMigration.setVersion(version);
resolvedMigration.setDescription(description);
resolvedMigration.setScript(springJdbcMigration.getClass().getName());
resolvedMigration.setChecksum(checksum);
resolvedMigration.setType(MigrationType.SPRING_JDBC);
return resolvedMigration;
}
Aggregations