use of org.flywaydb.core.Flyway in project flyway by flyway.
the class PostgreSQLMigrationMediumTest 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 flyway by flyway.
the class MigrationTestCase method configureFlyway.
protected void configureFlyway() {
flyway = new Flyway();
flyway.setDataSource(dataSource);
}
use of org.flywaydb.core.Flyway in project flyway by flyway.
the class AbstractFlywayTask method runTask.
@TaskAction
public Object runTask() {
try {
List<URL> extraURLs = new ArrayList<URL>();
if (isJavaProject()) {
JavaPluginConvention plugin = getProject().getConvention().getPlugin(JavaPluginConvention.class);
for (SourceSet sourceSet : plugin.getSourceSets()) {
URL classesUrl = sourceSet.getOutput().getClassesDir().toURI().toURL();
getLogger().debug("Adding directory to Classpath: " + classesUrl);
extraURLs.add(classesUrl);
URL resourcesUrl = sourceSet.getOutput().getResourcesDir().toURI().toURL();
getLogger().debug("Adding directory to Classpath: " + resourcesUrl);
extraURLs.add(resourcesUrl);
}
addDependenciesWithScope(extraURLs, "compile");
addDependenciesWithScope(extraURLs, "runtime");
addDependenciesWithScope(extraURLs, "testCompile");
addDependenciesWithScope(extraURLs, "testRuntime");
}
ClassLoader classLoader = new URLClassLoader(extraURLs.toArray(new URL[extraURLs.size()]), getProject().getBuildscript().getClassLoader());
Flyway flyway = new Flyway();
flyway.setClassLoader(classLoader);
flyway.configure(createFlywayConfig());
return run(flyway);
} catch (Exception e) {
handleException(e);
return null;
}
}
use of org.flywaydb.core.Flyway in project flyway by flyway.
the class AbstractFlywayMojoSmallTest method skipExecute.
@Test
public void skipExecute() throws Exception {
AbstractFlywayMojo mojo = new AbstractFlywayMojo() {
@Override
protected void doExecute(Flyway flyway) throws Exception {
assertNull(flyway.getDataSource());
}
};
mojo.skip = true;
mojo.url = "jdbc:h2:mem:dummy";
mojo.mavenProject = new MavenProject();
mojo.execute();
}
use of org.flywaydb.core.Flyway in project flyway by flyway.
the class OsgiActivator method start.
public void start(BundleContext context) throws Exception {
System.out.println("Starting Flyway Sample OSGi");
try {
Properties properties = new Properties();
properties.setProperty("flyway.driver", "org.h2.Driver");
properties.setProperty("flyway.url", "jdbc:h2:mem:flyway_db;DB_CLOSE_DELAY=-1");
properties.setProperty("flyway.user", "sa");
properties.setProperty("flyway.password", "");
Flyway flyway = new Flyway();
flyway.configure(properties);
flyway.setLocations("db.migration", "org.flywaydb.sample.osgi.fragment");
flyway.migrate();
System.out.println("New schema version: " + flyway.info().current().getVersion());
System.exit(0);
} catch (Throwable t) {
t.printStackTrace();
// System.exit(0);
}
}
Aggregations