Examples of DbDeploy


Examples of com.dbdeploy.DbDeploy

     * @parameter expression="${dbdeploy.lastChange}"
     */
    protected Long lastChangeToApply;

    protected DbDeploy getConfiguredDbDeploy() {
        DbDeploy dbDeploy = new DbDeploy();
        dbDeploy.setScriptdirectory(scriptdirectory);
        dbDeploy.setDriver(driver);
        dbDeploy.setUrl(url);
        dbDeploy.setPassword(password);
        dbDeploy.setUserid(userid);

      if (encoding != null) {
          dbDeploy.setEncoding(encoding);
      }

        if (lastChangeToApply != null) {
            dbDeploy.setLastChangeToApply(lastChangeToApply);
        }

        if (changeLogTableName != null) {
            dbDeploy.setChangeLogTableName(changeLogTableName);
        }

        if (delimiter != null) {
            dbDeploy.setDelimiter(delimiter);
        }

        if (delimiterType != null) {
            dbDeploy.setDelimiterType(DelimiterType.valueOf(delimiterType));
        }

      if (lineEnding != null) {
        dbDeploy.setLineEnding(LineEnding.valueOf(lineEnding));
      }

        return dbDeploy;
    }
View Full Code Here

Examples of com.dbdeploy.DbDeploy

     * @parameter
     */
    private File templateDirectory;

    public void execute() throws MojoExecutionException {
        DbDeploy dbDeploy = getConfiguredDbDeploy();

        try {
            dbDeploy.go();
        } catch (Exception e) {
            getLog().error(e);
            throw new MojoExecutionException("dbdeploy change script create failed", e);
        }
    }
View Full Code Here

Examples of com.dbdeploy.DbDeploy

        }
    }

    @Override
    protected DbDeploy getConfiguredDbDeploy() {
        DbDeploy dbDeploy = super.getConfiguredDbDeploy();
        dbDeploy.setOutputfile(outputfile);
        dbDeploy.setUndoOutputfile(undoOutputfile);
        dbDeploy.setDbms(dbms);
       
        if (templateDirectory != null) {
            dbDeploy.setTemplatedir(templateDirectory);
        }

        return dbDeploy;
    }
View Full Code Here

Examples of com.dbdeploy.DbDeploy

* @goal update
*/
public class UpdateDatabaseMojo extends AbstractDbDeployMojo {

    public void execute() throws MojoExecutionException {
        DbDeploy dbDeploy = getConfiguredDbDeploy();

        try {
            dbDeploy.go();
        } catch (Exception e) {
            getLog().error(e);
            throw new MojoExecutionException("dbdeploy update failed", e);
        }
    }
View Full Code Here

Examples of com.dbdeploy.DbDeploy

public class CommandLineTarget {
  private static final DbDeployCommandLineParser commandLineParser = new DbDeployCommandLineParser();

  public static void main(String[] args) {
    try {
      DbDeploy dbDeploy = new DbDeploy();
      commandLineParser.parse(args, dbDeploy);
      dbDeploy.go();
    } catch (UsageException ex) {
      System.err.println("ERROR: " + ex.getMessage());
      commandLineParser.printUsage();
    } catch (Exception ex) {
      System.err.println("Failed to apply changes: " + ex);
View Full Code Here

Examples of com.dbdeploy.DbDeploy

    Database db = new Database("success_test");
    db.createSchemaVersionTable();

    File outputFile = File.createTempFile("success",".sql");

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

    db.applyScript(outputFile);

    assertThat(db.getChangelogEntries(), hasItems(1L, 2L));
View Full Code Here

Examples of com.dbdeploy.DbDeploy

    File outputFile = File.createTempFile("recovery",".sql");

    Database db = new Database("failure_recovery_test");
    db.createSchemaVersionTable();

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

    try {
      db.applyScript(outputFile);
    } catch (SQLException ex) {
      //expected
      assertThat(ex.getMessage(), startsWith("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.setOutputfile(outputFile);
    dbDeploy.go();

    db.applyScript(outputFile);

    assertThat(db.getChangelogEntries(), hasItems(1L, 2L));
View Full Code Here

Examples of com.dbdeploy.DbDeploy

        Database db = new Database("user_defined_changelog_test", "user_defined_changelog_table");
        db.createSchemaVersionTable();

        File outputFile = File.createTempFile("changelog_success", ".sql");

        DbDeploy dbDeploy = new DbDeploy();
        db.applyDatabaseSettingsTo(dbDeploy);
        dbDeploy.setScriptdirectory(findScriptDirectory("src/it/db/deltas"));
        dbDeploy.setOutputfile(outputFile);
        dbDeploy.setChangeLogTableName("user_defined_changelog_table");
        dbDeploy.go();

        db.applyScript(outputFile);

        assertThat(db.getChangelogEntries(), hasItems(1L, 2L));
    }
View Full Code Here

Examples of com.dbdeploy.DbDeploy

    Database db = new Database("high_number_test");
    db.createSchemaVersionTable();

    File outputFile = File.createTempFile("high_number_test",".sql");

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

    db.applyScript(outputFile);
  }
View Full Code Here

Examples of com.dbdeploy.DbDeploy

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

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

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

    List<Object[]> 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.