use of org.flywaydb.core.Flyway in project flyway by flyway.
the class PostgreSQLSuperUserMigrationMediumTest method setUp.
@Before
public void setUp() throws Exception {
File customPropertiesFile = new File(System.getProperty("user.home") + "/flyway-mediumtests.properties");
Properties customProperties = new Properties();
if (customPropertiesFile.canRead()) {
customProperties.load(new FileInputStream(customPropertiesFile));
}
String password = customProperties.getProperty("postgresql.password", "flyway");
String url = customProperties.getProperty("postgresql.url", "jdbc:postgresql://localhost/flyway_db");
flyway = new Flyway();
flyway.setSchemas("super_user_test");
flyway.setDataSource(new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, url, "postgres", password, null));
flyway.setValidateOnMigrate(true);
flyway.clean();
}
use of org.flywaydb.core.Flyway in project flyway by flyway.
the class RedshiftMigrationMediumTest method emptySearchPath.
@Test
public void emptySearchPath() {
Flyway flyway1 = new Flyway();
DriverDataSource driverDataSource = (DriverDataSource) dataSource;
flyway1.setDataSource(new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, driverDataSource.getUrl(), driverDataSource.getUser(), driverDataSource.getPassword(), null) {
@Override
public Connection getConnection() throws SQLException {
Connection connection = super.getConnection();
Statement statement = null;
try {
statement = connection.createStatement();
statement.execute("SELECT set_config('search_path', '', false)");
} finally {
JdbcUtils.closeStatement(statement);
}
return connection;
}
});
flyway1.setLocations(getBasedir());
flyway1.setSchemas("public");
flyway1.migrate();
}
use of org.flywaydb.core.Flyway in project ninja by ninjaframework.
the class MigrationEngineFlyway method migrate.
@Override
public void migrate() {
// Get the connection credentials from application.conf
String connectionUrl = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_URL);
String connectionUsername = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_USERNAME);
String connectionPassword = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_PASSWORD);
// We migrate automatically => if you do not want that (eg in production)
// set ninja.migration.run=false in application.conf
Flyway flyway = new Flyway();
flyway.setDataSource(connectionUrl, connectionUsername, connectionPassword);
// get a fresh database.
if (ninjaProperties.getBooleanWithDefault(NinjaConstant.NINJA_MIGRATION_DROP_SCHEMA, ninjaProperties.isTest() ? true : false)) {
flyway.clean();
}
flyway.migrate();
}
use of org.flywaydb.core.Flyway in project keywhiz by square.
the class MigrationsRule method apply.
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
File yamlFile = new File(Resources.getResource("keywhiz-test.yaml").getFile());
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
ObjectMapper objectMapper = KeywhizService.customizeObjectMapper(Jackson.newObjectMapper());
KeywhizConfig config = new ConfigurationFactory<>(KeywhizConfig.class, validator, objectMapper, "dw").build(yamlFile);
DataSource dataSource = config.getDataSourceFactory().build(new MetricRegistry(), "db-migrations");
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations(config.getMigrationsDir());
flyway.clean();
flyway.migrate();
DSLContext dslContext = DSLContexts.databaseAgnostic(dataSource);
DbSeedCommand.doImport(dslContext);
base.evaluate();
}
};
}
use of org.flywaydb.core.Flyway in project spring-boot by spring-projects.
the class FlywayAutoConfigurationTests method callbacksAreConfiguredAndOrdered.
@Test
public void callbacksAreConfiguredAndOrdered() throws Exception {
registerAndRefresh(EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, CallbackConfiguration.class);
assertThat(this.context.getBeansOfType(Flyway.class)).hasSize(1);
Flyway flyway = this.context.getBean(Flyway.class);
FlywayCallback callbackOne = this.context.getBean("callbackOne", FlywayCallback.class);
FlywayCallback callbackTwo = this.context.getBean("callbackTwo", FlywayCallback.class);
assertThat(flyway.getCallbacks()).containsExactly(callbackTwo, callbackOne);
InOrder orderedCallbacks = inOrder(callbackOne, callbackTwo);
orderedCallbacks.verify(callbackTwo).beforeMigrate(any(Connection.class));
orderedCallbacks.verify(callbackOne).beforeMigrate(any(Connection.class));
}
Aggregations