use of liquibase.Liquibase in project microservice_framework by CJSCommonPlatform.
the class TestDataSourceFactory method initDatabase.
private void initDatabase() throws LiquibaseException, SQLException {
final Liquibase liquibase = new Liquibase(liquibaseLocation, new ClassLoaderResourceAccessor(), new JdbcConnection(dataSource.getConnection()));
liquibase.dropAll();
liquibase.update("");
}
use of liquibase.Liquibase in project microservice_framework by CJSCommonPlatform.
the class DefaultAggregateServiceIT method initDatabase.
private void initDatabase() throws Exception {
final Liquibase snapshotLiquidBase = new Liquibase(LIQUIBASE_EVENT_STORE_CHANGELOG_XML, new ClassLoaderResourceAccessor(), new JdbcConnection(dataSource.getConnection()));
snapshotLiquidBase.dropAll();
snapshotLiquidBase.update("");
}
use of liquibase.Liquibase in project webcert by sklintyg.
the class DbChecker method checkDb.
@PostConstruct
public void checkDb() {
try {
DatabaseConnection connection = new JdbcConnection(dataSource.getConnection());
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection);
Liquibase liquibase = new Liquibase(script, new ClassLoaderResourceAccessor(), database);
LOG.info("Checking database: {} URL:{}", database.getDatabaseProductName(), database.getConnection().getURL());
List<ChangeSet> changeSets = liquibase.listUnrunChangeSets(null, liquibase.getChangeLogParameters().getLabels());
if (!changeSets.isEmpty()) {
StringBuilder errors = new StringBuilder();
for (ChangeSet changeSet : changeSets) {
errors.append('>').append(changeSet.toString()).append('\n');
}
throw new Error("Database version mismatch. Check liquibase status. Errors:\n" + errors.toString() + database.getDatabaseProductName() + ", " + database);
}
} catch (liquibase.exception.LiquibaseException | SQLException e) {
throw new Error("Database not ok, aborting startup.", e);
}
LOG.info("Liquibase ok");
}
use of liquibase.Liquibase in project cals-api by ca-cwds.
the class DatabaseHelper method runScript.
public void runScript(String script) throws LiquibaseException {
try {
Liquibase liquibase = new Liquibase(script, new ClassLoaderResourceAccessor(), getDatabase());
liquibase.update((String) null);
} catch (Exception e) {
throw new LiquibaseException(e);
}
}
use of liquibase.Liquibase in project api-core 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);
}
}
Aggregations