Search in sources :

Example 36 with LiquibaseException

use of liquibase.exception.LiquibaseException in project liquibase by liquibase.

the class Liquibase method update.

public void update(Contexts contexts, LabelExpression labelExpression, Writer output, boolean checkLiquibaseTables) throws LiquibaseException {
    changeLogParameters.setContexts(contexts);
    changeLogParameters.setLabels(labelExpression);
    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    LoggingExecutor loggingExecutor = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), output, database);
    ExecutorService.getInstance().setExecutor(database, loggingExecutor);
    outputHeader("Update Database Script");
    LockService lockService = LockServiceFactory.getInstance().getLockService(database);
    lockService.waitForLock();
    try {
        update(contexts, labelExpression, checkLiquibaseTables);
        output.flush();
    } catch (IOException e) {
        throw new LiquibaseException(e);
    }
    ExecutorService.getInstance().setExecutor(database, oldTemplate);
}
Also used : Executor(liquibase.executor.Executor) LoggingExecutor(liquibase.executor.LoggingExecutor) LockService(liquibase.lockservice.LockService) LoggingExecutor(liquibase.executor.LoggingExecutor) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) LiquibaseException(liquibase.exception.LiquibaseException)

Example 37 with LiquibaseException

use of liquibase.exception.LiquibaseException in project liquibase by liquibase.

the class Liquibase method changeLogSync.

public void changeLogSync(Contexts contexts, LabelExpression labelExpression, Writer output) throws LiquibaseException {
    changeLogParameters.setContexts(contexts);
    changeLogParameters.setLabels(labelExpression);
    LoggingExecutor outputTemplate = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), output, database);
    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    ExecutorService.getInstance().setExecutor(database, outputTemplate);
    outputHeader("SQL to add all changesets to database history table");
    changeLogSync(contexts, labelExpression);
    try {
        output.flush();
    } catch (IOException e) {
        throw new LiquibaseException(e);
    }
    ExecutorService.getInstance().setExecutor(database, oldTemplate);
    resetServices();
}
Also used : Executor(liquibase.executor.Executor) LoggingExecutor(liquibase.executor.LoggingExecutor) LoggingExecutor(liquibase.executor.LoggingExecutor) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) LiquibaseException(liquibase.exception.LiquibaseException)

Example 38 with LiquibaseException

use of liquibase.exception.LiquibaseException in project liquibase by liquibase.

the class CDILiquibase method onStartup.

@PostConstruct
public void onStartup() {
    log.info("Booting Liquibase " + LiquibaseUtil.getBuildVersion());
    String hostName;
    try {
        hostName = NetUtil.getLocalHostName();
    } catch (Exception e) {
        log.warning("Cannot find hostname: " + e.getMessage());
        log.debug("", e);
        return;
    }
    LiquibaseConfiguration liquibaseConfiguration = LiquibaseConfiguration.getInstance();
    if (!liquibaseConfiguration.getConfiguration(GlobalConfiguration.class).getShouldRun()) {
        log.info("Liquibase did not run on " + hostName + " because " + liquibaseConfiguration.describeValueLookupLogic(GlobalConfiguration.class, GlobalConfiguration.SHOULD_RUN) + " was set to false");
        return;
    }
    initialized = true;
    try {
        performUpdate();
    } catch (LiquibaseException e) {
        throw new UnexpectedLiquibaseException(e);
    }
}
Also used : GlobalConfiguration(liquibase.configuration.GlobalConfiguration) LiquibaseConfiguration(liquibase.configuration.LiquibaseConfiguration) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) LiquibaseException(liquibase.exception.LiquibaseException) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) SQLException(java.sql.SQLException) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) DatabaseException(liquibase.exception.DatabaseException) LiquibaseException(liquibase.exception.LiquibaseException) PostConstruct(javax.annotation.PostConstruct)

Aggregations

LiquibaseException (liquibase.exception.LiquibaseException)38 UnexpectedLiquibaseException (liquibase.exception.UnexpectedLiquibaseException)23 Executor (liquibase.executor.Executor)12 Liquibase (liquibase.Liquibase)10 LoggingExecutor (liquibase.executor.LoggingExecutor)10 BuildException (org.apache.tools.ant.BuildException)8 IOException (java.io.IOException)7 Database (liquibase.database.Database)7 Contexts (liquibase.Contexts)6 DatabaseException (liquibase.exception.DatabaseException)5 ArrayList (java.util.ArrayList)4 ResourceAccessor (liquibase.resource.ResourceAccessor)4 FileResource (org.apache.tools.ant.types.resources.FileResource)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 Writer (java.io.Writer)3 CatalogAndSchema (liquibase.CatalogAndSchema)3 OracleDatabase (liquibase.database.core.OracleDatabase)3 DiffOutputControl (liquibase.diff.output.DiffOutputControl)3 Test (org.junit.Test)3 File (java.io.File)2