use of org.flywaydb.core.Flyway in project keywhiz by square.
the class KeywhizService method validateDatabase.
private void validateDatabase(KeywhizConfig config) {
logger.debug("Validating database state");
DataSource dataSource = config.getDataSourceFactory().build(new MetricRegistry(), "flyway-validation-datasource");
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations(config.getMigrationsDir());
flyway.validate();
}
use of org.flywaydb.core.Flyway in project keywhiz by square.
the class MigrateCommand method run.
@Override
protected void run(Bootstrap<KeywhizConfig> bootstrap, Namespace namespace, KeywhizConfig config) throws Exception {
DataSource dataSource = config.getDataSourceFactory().build(new MetricRegistry(), "migration-datasource");
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations(config.getMigrationsDir());
flyway.migrate();
}
use of org.flywaydb.core.Flyway 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 = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations(config.getMigrationsDir());
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.Flyway in project flyway by flyway.
the class H2CaseSensitiveMigrationMediumTest method migrate.
@Test
public void migrate() {
Flyway flyway = new Flyway();
flyway.setDataSource("jdbc:h2:mem:flyway_db_case_sensitive;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=FALSE", "sa", "");
flyway.setLocations("migration/sql");
flyway.migrate();
flyway.clean();
}
use of org.flywaydb.core.Flyway in project flyway by flyway.
the class H2MigrationMediumTest method mysqlMode.
@Test
public void mysqlMode() throws Exception {
Flyway flyway = new Flyway();
flyway.setDataSource("jdbc:h2:mem:mysql_db;MODE=MySQL;DB_CLOSE_DELAY=-1", "sa", "");
flyway.setSchemas("mysql_schema");
flyway.baseline();
}
Aggregations