use of org.flywaydb.core.api.MigrationInfo in project flyway by flyway.
the class FlywayInfoTask method run.
@Override
protected Object run(Flyway flyway) {
MigrationInfoService info = flyway.info();
MigrationInfo current = info.current();
MigrationVersion currentSchemaVersion = current == null ? MigrationVersion.EMPTY : current.getVersion();
System.out.println("Schema version: " + currentSchemaVersion);
System.out.println(MigrationInfoDumper.dumpToAsciiTable(info.all()));
return info;
}
use of org.flywaydb.core.api.MigrationInfo in project flyway by flyway.
the class UndoMojo method doExecute.
@Override
protected void doExecute(Flyway flyway) {
flyway.undo();
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 keywhiz by square.
the class PreviewMigrateCommand method run.
@Override
protected void run(Bootstrap<KeywhizConfig> bootstrap, Namespace namespace, KeywhizConfig config) throws Exception {
DataSource dataSource = config.getDataSourceFactory().build(new MetricRegistry(), "migration-preview-datasource");
Flyway flyway = Flyway.configure().dataSource(dataSource).locations(config.getMigrationsDir()).table(config.getFlywaySchemaTable()).load();
MigrationInfoService info = flyway.info();
MigrationInfo current = info.current();
if (current == null) {
logger.info("No migrations have been run yet.");
} else {
logger.info("Currently applied migration:");
logger.info("* {} - {}", current.getVersion(), current.getDescription());
}
if (info.pending().length > 0) {
logger.info("Pending migrations:");
for (MigrationInfo migration : info.pending()) {
logger.info("* {} - {}", migration.getVersion(), migration.getDescription());
}
} else {
logger.info("No pending migrations");
}
}
use of org.flywaydb.core.api.MigrationInfo in project flyway by flyway.
the class FlywayMediumTest method baselineAgainWithSameVersion.
@Test
public void baselineAgainWithSameVersion() throws Exception {
DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_init_same;DB_CLOSE_DELAY=-1", "sa", "", null);
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations("migration/sql");
flyway.setBaselineVersionAsString("0.5");
flyway.baseline();
flyway.baseline();
assertEquals(1, flyway.info().applied().length);
MigrationInfo current = flyway.info().current();
assertEquals("0.5", current.getVersion().toString());
assertEquals(MigrationType.BASELINE, current.getType());
assertEquals(MigrationState.BASELINE, current.getState());
}
use of org.flywaydb.core.api.MigrationInfo in project flyway by flyway.
the class FlywayMediumTest method outOfOrderInOrder.
@Test
public void outOfOrderInOrder() {
DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_out_of_order_in_order;DB_CLOSE_DELAY=-1", "sa", "", null);
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations("migration/sql");
flyway.migrate();
MigrationVersion highest = null;
for (MigrationInfo migrationInfo : flyway.info().applied()) {
assertEquals(MigrationState.SUCCESS, migrationInfo.getState());
if (highest == null) {
highest = migrationInfo.getVersion();
} else {
assertTrue(migrationInfo.getVersion().compareTo(highest) > 0);
highest = migrationInfo.getVersion();
}
}
assertEquals(MigrationVersion.fromVersion("2.0"), highest);
}
Aggregations