Search in sources :

Example 1 with CreateDatabaseChangeLogTableStatement

use of liquibase.statement.core.CreateDatabaseChangeLogTableStatement in project keycloak by keycloak.

the class LiquibaseJpaUpdaterProvider method outputChangeLogTableCreationScript.

private void outputChangeLogTableCreationScript(Liquibase liquibase, final Writer exportWriter) throws DatabaseException {
    Database database = liquibase.getDatabase();
    ExecutorService executorService = Scope.getCurrentScope().getSingleton(ExecutorService.class);
    Executor oldTemplate = executorService.getExecutor(LiquibaseConstants.JDBC_EXECUTOR, database);
    LoggingExecutor loggingExecutor = new LoggingExecutor(oldTemplate, exportWriter, database);
    executorService.setExecutor(LiquibaseConstants.JDBC_EXECUTOR, database, loggingExecutor);
    loggingExecutor.comment("*********************************************************************");
    loggingExecutor.comment("* Keycloak database creation script - apply this script to empty DB *");
    loggingExecutor.comment("*********************************************************************" + StreamUtil.getLineSeparator());
    loggingExecutor.execute(new CreateDatabaseChangeLogTableStatement());
    // DatabaseChangeLogLockTable is created before this code is executed and recreated if it does not exist automatically
    // in org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService.init() called indirectly from
    // KeycloakApplication constructor (search for waitForLock() call). Hence it is not included in the creation script.
    loggingExecutor.comment("*********************************************************************" + StreamUtil.getLineSeparator());
    executorService.setExecutor(LiquibaseConstants.JDBC_EXECUTOR, database, oldTemplate);
}
Also used : CreateDatabaseChangeLogTableStatement(liquibase.statement.core.CreateDatabaseChangeLogTableStatement) Executor(liquibase.executor.Executor) LoggingExecutor(liquibase.executor.LoggingExecutor) LoggingExecutor(liquibase.executor.LoggingExecutor) Database(liquibase.database.Database) ExecutorService(liquibase.executor.ExecutorService)

Example 2 with CreateDatabaseChangeLogTableStatement

use of liquibase.statement.core.CreateDatabaseChangeLogTableStatement in project liquibase by liquibase.

the class OfflineChangeLogHistoryService method init.

@Override
public void init() throws DatabaseException {
    if (!changeLogFile.exists()) {
        changeLogFile.getParentFile().mkdirs();
        try {
            changeLogFile.createNewFile();
            writeHeader(changeLogFile);
            if (isExecuteDdlAgainstDatabase()) {
                Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", getDatabase()).execute(new CreateDatabaseChangeLogTableStatement());
            }
        } catch (Exception e) {
            throw new UnexpectedLiquibaseException(e);
        }
    }
}
Also used : CreateDatabaseChangeLogTableStatement(liquibase.statement.core.CreateDatabaseChangeLogTableStatement) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) DatabaseException(liquibase.exception.DatabaseException) LiquibaseException(liquibase.exception.LiquibaseException)

Example 3 with CreateDatabaseChangeLogTableStatement

use of liquibase.statement.core.CreateDatabaseChangeLogTableStatement in project keycloak by keycloak.

the class QuarkusJpaUpdaterProvider method outputChangeLogTableCreationScript.

private void outputChangeLogTableCreationScript(Liquibase liquibase, final Writer exportWriter) throws DatabaseException {
    Database database = liquibase.getDatabase();
    ExecutorService executorService = Scope.getCurrentScope().getSingleton(ExecutorService.class);
    Executor oldTemplate = executorService.getExecutor(LiquibaseConstants.JDBC_EXECUTOR, database);
    LoggingExecutor loggingExecutor = new LoggingExecutor(executorService.getExecutor(LiquibaseConstants.JDBC_EXECUTOR, database), exportWriter, database);
    executorService.setExecutor(LiquibaseConstants.JDBC_EXECUTOR, database, loggingExecutor);
    loggingExecutor.comment("*********************************************************************");
    loggingExecutor.comment("* Keycloak database creation script - apply this script to empty DB *");
    loggingExecutor.comment("*********************************************************************" + StreamUtil.getLineSeparator());
    loggingExecutor.execute(new CreateDatabaseChangeLogTableStatement());
    // DatabaseChangeLogLockTable is created before this code is executed and recreated if it does not exist automatically
    // in org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService.init() called indirectly from
    // KeycloakApplication constructor (search for waitForLock() call). Hence it is not included in the creation script.
    loggingExecutor.comment("*********************************************************************" + StreamUtil.getLineSeparator());
    executorService.setExecutor(LiquibaseConstants.JDBC_EXECUTOR, database, oldTemplate);
}
Also used : CreateDatabaseChangeLogTableStatement(liquibase.statement.core.CreateDatabaseChangeLogTableStatement) Executor(liquibase.executor.Executor) LoggingExecutor(liquibase.executor.LoggingExecutor) LoggingExecutor(liquibase.executor.LoggingExecutor) Database(liquibase.database.Database) ExecutorService(liquibase.executor.ExecutorService)

Aggregations

CreateDatabaseChangeLogTableStatement (liquibase.statement.core.CreateDatabaseChangeLogTableStatement)3 Database (liquibase.database.Database)2 Executor (liquibase.executor.Executor)2 ExecutorService (liquibase.executor.ExecutorService)2 LoggingExecutor (liquibase.executor.LoggingExecutor)2 DatabaseException (liquibase.exception.DatabaseException)1 LiquibaseException (liquibase.exception.LiquibaseException)1 UnexpectedLiquibaseException (liquibase.exception.UnexpectedLiquibaseException)1