001package org.avaje.dbmigration.runner;
002
003import org.avaje.dbmigration.ddl.DdlRunner;
004
005import java.sql.Connection;
006import java.sql.SQLException;
007
008/**
009 * Runs the DDL migration scripts.
010 */
011public class MigrationScriptRunner {
012
013  private final Connection connection;
014
015  /**
016   * Construct with a given connection.
017   */
018  public MigrationScriptRunner(Connection connection) {
019    this.connection = connection;
020  }
021
022  /**
023   * Execute all the DDL statements in the script.
024   */
025  int runScript(boolean expectErrors, String content, String scriptName) throws SQLException {
026
027    DdlRunner runner = new DdlRunner(expectErrors, scriptName);
028    return runner.runAll(content, connection);
029  }
030}