use of org.flywaydb.core.internal.util.jdbc.TransactionTemplate in project flyway by flyway.
the class Flyway method info.
/**
* <p>Retrieves the complete information about all the migrations including applied, pending and current migrations with
* details and status.</p>
* <img src="https://flywaydb.org/assets/balsamiq/command-info.png" alt="info">
*
* @return All migrations sorted by version, oldest first.
* @throws FlywayException when the info retrieval failed.
*/
public MigrationInfoService info() {
return execute(new Command<MigrationInfoService>() {
public MigrationInfoService execute(final Connection connectionMetaDataTable, MigrationResolver migrationResolver, MetaDataTable metaDataTable, final DbSupport dbSupport, final Schema[] schemas, FlywayCallback[] flywayCallbacks) {
try {
for (final FlywayCallback callback : flywayCallbacks) {
new TransactionTemplate(connectionMetaDataTable).execute(new Callable<Object>() {
@Override
public Object call() throws SQLException {
dbSupport.changeCurrentSchemaTo(schemas[0]);
callback.beforeInfo(connectionMetaDataTable);
return null;
}
});
}
MigrationInfoServiceImpl migrationInfoService = new MigrationInfoServiceImpl(migrationResolver, metaDataTable, target, outOfOrder, true, true, true);
migrationInfoService.refresh();
for (final FlywayCallback callback : flywayCallbacks) {
new TransactionTemplate(connectionMetaDataTable).execute(new Callable<Object>() {
@Override
public Object call() throws SQLException {
dbSupport.changeCurrentSchemaTo(schemas[0]);
callback.afterInfo(connectionMetaDataTable);
return null;
}
});
}
return migrationInfoService;
} finally {
dbSupport.restoreCurrentSchema();
}
}
});
}
Aggregations