Search in sources :

Example 26 with ClassLoaderResourceAccessor

use of liquibase.resource.ClassLoaderResourceAccessor in project microservice_framework by CJSCommonPlatform.

the class EventBufferAndFilterChainIT method initDatabase.

private void initDatabase() throws Exception {
    Liquibase liquibase = new Liquibase(LIQUIBASE_STREAM_STATUS_CHANGELOG_XML, new ClassLoaderResourceAccessor(), new JdbcConnection(dataSource.getConnection()));
    liquibase.dropAll();
    liquibase.update("");
}
Also used : Liquibase(liquibase.Liquibase) JdbcConnection(liquibase.database.jvm.JdbcConnection) ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor)

Example 27 with ClassLoaderResourceAccessor

use of liquibase.resource.ClassLoaderResourceAccessor in project microservice_framework by CJSCommonPlatform.

the class EventStreamPageIT method initEventDatabase.

private void initEventDatabase() throws Exception {
    Liquibase eventStoreLiquibase = new Liquibase(LIQUIBASE_EVENT_STORE_CHANGELOG_XML, new ClassLoaderResourceAccessor(), new JdbcConnection(dataSource.getConnection()));
    eventStoreLiquibase.dropAll();
    eventStoreLiquibase.update("");
}
Also used : Liquibase(liquibase.Liquibase) JdbcConnection(liquibase.database.jvm.JdbcConnection) ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor)

Example 28 with ClassLoaderResourceAccessor

use of liquibase.resource.ClassLoaderResourceAccessor in project activityinfo by bedatadriven.

the class TestConnectionProvider method initializeDatabase.

private static void initializeDatabase() throws SQLException, LiquibaseException {
    Connection connection;
    try {
        connection = DriverManager.getConnection(connectionUrl(DATABASE_NAME), USERNAME, PASSWORD);
        Statement stmt = connection.createStatement();
        stmt.execute("DROP DATABASE IF EXISTS " + DATABASE_NAME);
        stmt.execute("CREATE DATABASE " + DATABASE_NAME);
        stmt.execute("USE " + DATABASE_NAME);
    } catch (SQLException e) {
        // Database probably doesn't exist yet
        connection = DriverManager.getConnection(connectionUrl(""), USERNAME, PASSWORD);
        Statement stmt = connection.createStatement();
        stmt.execute("CREATE DATABASE " + DATABASE_NAME);
        stmt.close();
        connection.close();
        // Re-open specifically for this database
        connection = DriverManager.getConnection(connectionUrl(DATABASE_NAME), USERNAME, PASSWORD);
    }
    Liquibase liquibase = new Liquibase("org/activityinfo/database/changelog/db.changelog-master.xml", new ClassLoaderResourceAccessor(), new JdbcConnection(connection));
    liquibase.update(new Contexts());
    connection.close();
}
Also used : Liquibase(liquibase.Liquibase) SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) JdbcConnection(liquibase.database.jvm.JdbcConnection) JdbcConnection(liquibase.database.jvm.JdbcConnection) ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor) Contexts(liquibase.Contexts)

Example 29 with ClassLoaderResourceAccessor

use of liquibase.resource.ClassLoaderResourceAccessor in project cals-api by ca-cwds.

the class DatabaseHelper method runScript.

public void runScript(String script, Map<String, Object> parameters, String schema) throws LiquibaseException {
    try {
        String defaultSchema = getDatabase().getDefaultSchemaName();
        getDatabase().setDefaultSchemaName(schema);
        Liquibase liquibase = new Liquibase(script, new ClassLoaderResourceAccessor(), getDatabase());
        parameters.forEach(liquibase::setChangeLogParameter);
        liquibase.update((String) null);
        getDatabase().setDefaultSchemaName(defaultSchema);
    } catch (Exception e) {
        throw new LiquibaseException(e);
    }
}
Also used : Liquibase(liquibase.Liquibase) LiquibaseException(liquibase.exception.LiquibaseException) ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor) SQLException(java.sql.SQLException) LiquibaseException(liquibase.exception.LiquibaseException) DatabaseException(liquibase.exception.DatabaseException)

Example 30 with ClassLoaderResourceAccessor

use of liquibase.resource.ClassLoaderResourceAccessor in project liquibase by liquibase.

the class Scope method getCurrentScope.

public static Scope getCurrentScope() {
    if (scopeManager == null) {
        scopeManager = new SingletonScopeManager();
    }
    if (scopeManager.getCurrentScope() == null) {
        Scope rootScope = new Scope();
        scopeManager.setCurrentScope(rootScope);
        rootScope.values.put(Attr.logService.name(), new JavaLogService());
        rootScope.values.put(Attr.resourceAccessor.name(), new ClassLoaderResourceAccessor());
        rootScope.values.put(Attr.serviceLocator.name(), new StandardServiceLocator());
        rootScope.values.put(Attr.ui.name(), new ConsoleUIService());
        rootScope.getSingleton(LiquibaseConfiguration.class).init(rootScope);
        LogService overrideLogService = rootScope.getSingleton(LogServiceFactory.class).getDefaultLogService();
        if (overrideLogService == null) {
            throw new UnexpectedLiquibaseException("Cannot find default log service");
        }
        rootScope.values.put(Attr.logService.name(), overrideLogService);
        // check for higher-priority serviceLocator
        ServiceLocator serviceLocator = rootScope.getServiceLocator();
        for (ServiceLocator possibleLocator : serviceLocator.findInstances(ServiceLocator.class)) {
            if (possibleLocator.getPriority() > serviceLocator.getPriority()) {
                serviceLocator = possibleLocator;
            }
        }
        rootScope.values.put(Attr.serviceLocator.name(), serviceLocator);
        rootScope.values.put(Attr.osgiPlatform.name(), Activator.OSGIContainerChecker.isOsgiPlatform());
    }
    return scopeManager.getCurrentScope();
}
Also used : StandardServiceLocator(liquibase.servicelocator.StandardServiceLocator) ServiceLocator(liquibase.servicelocator.ServiceLocator) ConsoleUIService(liquibase.ui.ConsoleUIService) StandardServiceLocator(liquibase.servicelocator.StandardServiceLocator) JavaLogService(liquibase.logging.core.JavaLogService) LiquibaseConfiguration(liquibase.configuration.LiquibaseConfiguration) ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor) LogServiceFactory(liquibase.logging.core.LogServiceFactory) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) LogService(liquibase.logging.LogService) JavaLogService(liquibase.logging.core.JavaLogService)

Aggregations

ClassLoaderResourceAccessor (liquibase.resource.ClassLoaderResourceAccessor)38 Liquibase (liquibase.Liquibase)25 JdbcConnection (liquibase.database.jvm.JdbcConnection)20 SQLException (java.sql.SQLException)11 CompositeResourceAccessor (liquibase.resource.CompositeResourceAccessor)9 Database (liquibase.database.Database)8 LiquibaseException (liquibase.exception.LiquibaseException)8 Connection (java.sql.Connection)7 DatabaseException (liquibase.exception.DatabaseException)7 FileSystemResourceAccessor (liquibase.resource.FileSystemResourceAccessor)7 ResourceAccessor (liquibase.resource.ResourceAccessor)7 File (java.io.File)6 ArrayList (java.util.ArrayList)3 Contexts (liquibase.Contexts)3 FileOutputStream (java.io.FileOutputStream)2 DataSource (javax.sql.DataSource)2 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)2 ChangeSet (liquibase.changelog.ChangeSet)2 DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)2 DatabaseConnection (liquibase.database.DatabaseConnection)2