use of org.flywaydb.core.api.MigrationInfo in project flyway by flyway.
the class DbRepair method deleteMissingMigrations.
private boolean deleteMissingMigrations() {
boolean removed = false;
for (MigrationInfo migrationInfo : migrationInfoService.all()) {
MigrationInfoImpl migrationInfoImpl = (MigrationInfoImpl) migrationInfo;
if (migrationInfo.getType().isSynthetic()) {
continue;
}
AppliedMigration applied = migrationInfoImpl.getAppliedMigration();
MigrationState state = migrationInfoImpl.getState();
boolean isMigrationMissing = state == MigrationState.MISSING_SUCCESS || state == MigrationState.MISSING_FAILED || state == MigrationState.FUTURE_SUCCESS || state == MigrationState.FUTURE_FAILED;
boolean isMigrationIgnored = Arrays.stream(configuration.getIgnoreMigrationPatterns()).anyMatch(p -> p.matchesMigration(migrationInfoImpl.getVersion() != null, state));
if (isMigrationMissing && !isMigrationIgnored) {
schemaHistory.delete(applied);
removed = true;
repairResult.migrationsDeleted.add(CommandResultFactory.createRepairOutput(migrationInfo));
}
}
return removed;
}
use of org.flywaydb.core.api.MigrationInfo in project flyway by flyway.
the class MigrateMojo method doExecute.
@Override
protected void doExecute(Flyway flyway) {
flyway.migrate();
MigrationInfo current = flyway.info().current();
if (current != null && current.getVersion() != null) {
mavenProject.getProperties().setProperty("flyway.current", current.getVersion().toString());
}
}
use of org.flywaydb.core.api.MigrationInfo in project flyway by flyway.
the class InfoMojo method doExecute.
@Override
protected void doExecute(Flyway flyway) {
MigrationInfoService info = flyway.info();
MigrationInfo current = info.current();
MigrationVersion currentSchemaVersion = current == null ? MigrationVersion.EMPTY : current.getVersion();
log.info("Schema version: " + currentSchemaVersion);
log.info("");
log.info(MigrationInfoDumper.dumpToAsciiTable(info.all()));
}
use of org.flywaydb.core.api.MigrationInfo in project flyway by flyway.
the class MigrationInfoDumper method dumpToAsciiTable.
/**
* Dumps the info about all migrations into an ascii table.
*
* @param migrationInfos The list of migrationInfos to dump.
* @return The ascii table, as one big multi-line string.
*/
public static String dumpToAsciiTable(MigrationInfo[] migrationInfos) {
List<String> columns = Arrays.asList("Category", "Version", "Description", "Type", "Installed On", "State");
List<List<String>> rows = new ArrayList<>();
for (MigrationInfo migrationInfo : migrationInfos) {
List<String> row = Arrays.asList(getCategory(migrationInfo), getVersionStr(migrationInfo), migrationInfo.getDescription(), migrationInfo.getType().name(), DateUtils.formatDateAsIsoString(migrationInfo.getInstalledOn()), migrationInfo.getState().getDisplayName());
rows.add(row);
}
return new AsciiTable(columns, rows, true, "", "No migrations found").render();
}
Aggregations