示例#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 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());
  }