Java Code Examples for org.flywaydb.core.Flyway#validate()

The following examples show how to use org.flywaydb.core.Flyway#validate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Test
public void deploySchema_success() throws Exception {
  Flyway flyway =
      Flyway.configure()
          .locations("sql/flyway")
          .dataSource(
              sqlContainer.getJdbcUrl(), sqlContainer.getUsername(), sqlContainer.getPassword())
          .load();

  // flyway.migrate() returns the number of newly pushed scripts. This is a variable
  // number as our schema evolves.
  assertThat(flyway.migrate()).isGreaterThan(0);
  flyway.validate();

  Container.ExecResult execResult =
      sqlContainer.execInContainer(
          StandardCharsets.UTF_8,
          getSchemaDumpCommand(sqlContainer.getUsername(), sqlContainer.getDatabaseName()));
  if (execResult.getExitCode() != 0) {
    throw new RuntimeException(execResult.toString());
  }

  URL dumpedSchema =
      Resources.getResource(
          Joiner.on(File.separatorChar).join(MOUNTED_RESOURCE_PATH, DUMP_OUTPUT_FILE));

  assertThat(dumpedSchema)
      .hasSameContentAs(Resources.getResource("sql/schema/nomulus.golden.sql"));
}
 
Example 2
Source File: KeywhizService.java    From keywhiz with Apache License 2.0 5 votes vote down vote up
private void validateDatabase(KeywhizConfig config) {
  logger.debug("Validating database state");
  DataSource dataSource = config.getDataSourceFactory()
      .build(new MetricRegistry(), "flyway-validation-datasource");
  Flyway flyway = Flyway.configure().dataSource(dataSource).locations(config.getMigrationsDir()).table(config.getFlywaySchemaTable()).load();
  flyway.validate();
}
 
Example 3
Source File: DbValidateCommand.java    From dropwizard-flyway with Apache License 2.0 4 votes vote down vote up
@Override
protected void run(final Namespace namespace, final Flyway flyway) throws Exception {
    flyway.validate();
}