use of org.flywaydb.core.internal.info.MigrationInfoImpl in project killbill by killbill.
the class DbMigrateWithDryRun method dryRunMigrate.
public int dryRunMigrate() throws FlywayException {
try {
for (final FlywayCallback callback : callbacks) {
new TransactionTemplate(connectionUserObjects).execute(new TransactionCallback<Object>() {
@Override
public Object doInTransaction() throws SQLException {
dbSupportUserObjects.changeCurrentSchemaTo(schema);
callback.beforeMigrate(connectionUserObjects);
return null;
}
});
}
// PIERRE: perform a single query to the metadata table
final MigrationInfoServiceImpl infoService = new MigrationInfoServiceImpl(migrationResolver, metaDataTableForDryRun, target, outOfOrder, true, true);
infoService.refresh();
final MigrationInfoImpl[] pendingMigrations = infoService.pending();
new TransactionTemplate(connectionMetaDataTable, false).execute(new TransactionCallback<Boolean>() {
public Boolean doInTransaction() {
int i = 1;
for (final MigrationInfoImpl migrationInfo : pendingMigrations) {
applyMigration(i, migrationInfo);
i++;
}
return true;
}
});
for (final FlywayCallback callback : callbacks) {
new TransactionTemplate(connectionUserObjects).execute(new TransactionCallback<Object>() {
@Override
public Object doInTransaction() throws SQLException {
dbSupportUserObjects.changeCurrentSchemaTo(schema);
callback.afterMigrate(connectionUserObjects);
return null;
}
});
}
return pendingMigrations.length;
} finally {
dbSupportUserObjects.restoreCurrentSchema();
}
}
use of org.flywaydb.core.internal.info.MigrationInfoImpl in project flyway by flyway.
the class DbRepair method repairChecksumsAndDescriptions.
public void repairChecksumsAndDescriptions() {
migrationInfoService.refresh();
for (MigrationInfo migrationInfo : migrationInfoService.all()) {
MigrationInfoImpl migrationInfoImpl = (MigrationInfoImpl) migrationInfo;
ResolvedMigration resolved = migrationInfoImpl.getResolvedMigration();
AppliedMigration applied = migrationInfoImpl.getAppliedMigration();
if (resolved != null && applied != null && resolved.getVersion() != null) {
if (!ObjectUtils.nullSafeEquals(resolved.getChecksum(), applied.getChecksum()) || !ObjectUtils.nullSafeEquals(resolved.getDescription(), applied.getDescription())) {
metaDataTable.update(migrationInfoImpl.getVersion(), resolved.getDescription(), resolved.getChecksum());
}
}
}
}
Aggregations