use of liquibase.resource.ClassLoaderResourceAccessor in project microservice_framework by CJSCommonPlatform.
the class EventsPageIT 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("");
}
use of liquibase.resource.ClassLoaderResourceAccessor in project microservice_framework by CJSCommonPlatform.
the class CakeShopPostgresIT method initDatabase.
private static DataSource initDatabase(final String dbUrlPropertyName, final String dbUserNamePropertyName, final String dbPasswordPropertyName, final String... liquibaseChangeLogXmls) throws Exception {
final BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(POSTGRES_DRIVER);
dataSource.setUrl(TEST_PROPERTIES.value(dbUrlPropertyName));
dataSource.setUsername(TEST_PROPERTIES.value(dbUserNamePropertyName));
dataSource.setPassword(TEST_PROPERTIES.value(dbPasswordPropertyName));
boolean dropped = false;
final JdbcConnection jdbcConnection = new JdbcConnection(dataSource.getConnection());
for (String liquibaseChangeLogXml : liquibaseChangeLogXmls) {
Liquibase liquibase = new Liquibase(liquibaseChangeLogXml, new ClassLoaderResourceAccessor(), jdbcConnection);
if (!dropped) {
liquibase.dropAll();
dropped = true;
}
liquibase.update("");
}
return dataSource;
}
use of liquibase.resource.ClassLoaderResourceAccessor 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.resource.ClassLoaderResourceAccessor 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.resource.ClassLoaderResourceAccessor 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");
}
Aggregations