@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()) {
         @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(BASEDIR);
   flyway1.setSchemas("public");
   flyway1.migrate();
 }
 @BeforeClass
 public static void init() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   database = builder.build();
   flyway = new Flyway();
   flyway.setInitVersion("1.5.2");
   flyway.setLocations("classpath:/org/cloudfoundry/identity/uaa/db/hsqldb/");
   flyway.setDataSource(database);
   flyway.migrate();
 }
  public static void main(String[] args) throws Exception {
    AppSetup appSetup = new AppSetup();

    /** Fetches database parameters form environment variables. */
    Map<String, String> params = appSetup.getParamsFromDBURL(appSetup.getDatabaseURL());

    /**
     * Uses Flyway to run database migrations. Migration files are located in resources/db/migration
     * directory.
     */
    Flyway flyway = new Flyway();
    flyway.setDataSource(params.get("url"), params.get("username"), params.get("password"));
    flyway.migrate();
  }
  @Override
  public void start() throws Exception {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();

    Database database = new Database(new AppConfiguration("events.properties"));
    Flyway flyway = new Flyway();
    flyway.setDataSource(database.getDataSource());
    flyway.migrate();

    addHandler(shutdownHandler());
    addHandler(createWebAppContext("/events"));
    addHandler(createRedirectContextHandler("/", "/events"));
    super.start();
  }
Esempio n. 5
0
 public void migrate() {
   Flyway flyway = new Flyway();
   flyway.setDataSource(DB_URL, null, null);
   flyway.migrate();
 }
 // Init DB and create table if required
 public LogService() throws SQLException {
   Flyway flyway = new Flyway();
   flyway.setDataSource(getConnectionUrl(), "postgres", null);
   flyway.migrate();
 }