@Override
  protected void run(final Namespace namespace, final Flyway flyway) throws Exception {
    flyway.setOutOfOrder(namespace.getBoolean(OUT_OF_ORDER));
    flyway.setCleanOnValidationError(namespace.getBoolean(CLEAN_ON_VALIDATION_ERROR));

    flyway.validate();
  }
 @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();
 }
示例#3
0
 @Bean(initMethod = "migrate")
 public Flyway flyway() {
   Flyway flyway = new Flyway();
   flyway.setBaselineOnMigrate(true);
   flyway.setLocations("classpath:migrations");
   flyway.setSchemas("utips");
   flyway.setDataSource(dataSource());
   return flyway;
 }
 @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();
  }
 @Bean
 @ConfigurationProperties(prefix = "flyway")
 public Flyway flyway() {
   Flyway flyway = new Flyway();
   if (this.properties.isCreateDataSource()) {
     flyway.setDataSource(
         this.properties.getUrl(),
         this.properties.getUser(),
         this.properties.getPassword(),
         this.properties.getInitSqls().toArray(new String[0]));
   } else if (this.flywayDataSource != null) {
     flyway.setDataSource(this.flywayDataSource);
   } else {
     flyway.setDataSource(this.dataSource);
   }
   return flyway;
 }
示例#8
0
 public void migrate() {
   Flyway flyway = new Flyway();
   flyway.setDataSource(DB_URL, null, null);
   flyway.migrate();
 }
 @Override
 public void run(final Namespace namespace, final Flyway flyway) throws Exception {
   flyway.repair();
 }
示例#10
0
 @Override
 protected void doExecute(Flyway flyway) throws Exception {
   log.info("\n" + MigrationInfoDumper.dumpToAsciiTable(flyway.info().all()));
 }
 // Init DB and create table if required
 public LogService() throws SQLException {
   Flyway flyway = new Flyway();
   flyway.setDataSource(getConnectionUrl(), "postgres", null);
   flyway.migrate();
 }