예제 #1
0
  @Test(expected = FlywayException.class)
  public void initAgainWithDifferentVersion() throws Exception {
    DriverDataSource dataSource =
        new DriverDataSource(
            null, "jdbc:h2:mem:flyway_db_init_different;DB_CLOSE_DELAY=-1", "sa", "");

    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.init();

    flyway.setInitVersion("2");
    flyway.init();
  }
예제 #2
0
  @Test
  public void infoInit() throws Exception {
    DriverDataSource dataSource =
        new DriverDataSource(null, "jdbc:h2:mem:flyway_db_info_init;DB_CLOSE_DELAY=-1", "sa", "");

    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.init();

    flyway.setLocations();
    assertEquals(1, flyway.info().all().length);
    assertEquals("1", flyway.info().current().getVersion().toString());
    assertEquals(MigrationState.SUCCESS, flyway.info().current().getState());
  }
예제 #3
0
  @Test
  public void initAgainWithSameVersion() throws Exception {
    DriverDataSource dataSource =
        new DriverDataSource(null, "jdbc:h2:mem:flyway_db_init_same;DB_CLOSE_DELAY=-1", "sa", "");

    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.setLocations("migration/sql");
    flyway.setInitVersion("0.5");
    flyway.init();
    flyway.init();

    assertEquals(1, flyway.info().applied().length);
    MigrationInfo current = flyway.info().current();
    assertEquals("0.5", current.getVersion().toString());
    assertEquals(MigrationType.INIT, current.getType());
    assertEquals(MigrationState.SUCCESS, current.getState());
  }