Examples of DbDeploy


Examples of com.dbdeploy.DbDeploy

    @Test
    public void shouldSuccessfullyApplyAValidSetOfDeltasIncludingMutliStatementDeltas() throws Exception {
        Database db = new Database("todb_multistatement_test");
        db.createSchemaVersionTable();

        DbDeploy dbDeploy = new DbDeploy();
        db.applyDatabaseSettingsTo(dbDeploy);
        dbDeploy.setScriptdirectory(findScriptDirectory("src/it/db/multi_statement_deltas"));
        dbDeploy.go();

        assertThat(db.getChangelogEntries(), hasItems(1L, 2L));

        List<Object[]> results = db.executeQuery("select id from Test");
        assertThat(results.size(), is(2));
View Full Code Here

Examples of com.dbdeploy.DbDeploy

  @Test
  public void shouldBeAbleToRecoverFromBadScriptsJustByRunningCorrectedScriptsAgain() throws Exception {
    Database db = new Database("todb_failure_recovery_test");
    db.createSchemaVersionTable();

    DbDeploy dbDeploy = new DbDeploy();
    db.applyDatabaseSettingsTo(dbDeploy);
    dbDeploy.setScriptdirectory(findScriptDirectory("src/it/db/invalid_deltas"));
    try {
      dbDeploy.go();
    } catch (Exception ex) {
      //expected
      assertThat(ex.getMessage(), containsString("Column count does not match in statement"));
    }

    // script 2 failed, so it should not be considered applied to the database
    assertThat(db.getChangelogEntries(), hasItems(1L));
    assertThat(db.getChangelogEntries(), not(hasItems(2L)));

    List<Object[]> results = db.executeQuery("select id from Test");
    assertThat(results.size(), is(0));

    // now run dbdeploy again with valid scripts, should recover
    dbDeploy.setScriptdirectory(findScriptDirectory("src/it/db/deltas"));
    dbDeploy.go();

    assertThat(db.getChangelogEntries(), hasItems(1L, 2L));

    results = db.executeQuery("select id from Test");
    assertThat(results.size(), is(1));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.