public static void setupTestData(final DataSource dataSource) throws LiquibaseException { log.info("Setting up database for testing"); SpringLiquibase liquibase = new SpringLiquibase(); liquibase.setChangeLog("classpath:liquibase.xml"); liquibase.setDataSource(dataSource); liquibase.setResourceLoader(new DefaultResourceLoader()); liquibase.setDropFirst(true); liquibase.afterPropertiesSet(); }
@Override public void process(Exchange exchange) throws Exception { getSpringLiquibase().afterPropertiesSet(); }
private void loadInitialData() { try { springLiquibase.setDropFirst(false); springLiquibase.setChangeLog(changelogData); springLiquibase.afterPropertiesSet(); } catch (LiquibaseException e) { log.error("Failed to load initial data into registry", e); } }
@Override public void afterPropertiesSet() throws LiquibaseException { HashMap<String,String> parameters = new HashMap<>(); parameters.put("dbUser", CoreResources.getField("dbUser")); parameters.put("dbPass", CoreResources.getField("dbPass")); parameters.put("db", CoreResources.getField("db")); parameters.put("dbHost", CoreResources.getField("dbHost")); // replace all dashes with underscores to comply with app server criteria where no dashes are allowed String dbName = CoreResources.getField("db").replaceAll("-", "_"); parameters.put("mappingServer", "mapping_server_" + dbName); super.setChangeLogParameters(parameters); super.afterPropertiesSet(); } }
protected void initDb() throws LiquibaseException { StopWatch watch = new StopWatch(); watch.start(); super.afterPropertiesSet(); watch.stop(); logger.debug(STARTED_MESSAGE, watch.getTotalTimeMillis()); if (watch.getTotalTimeMillis() > SLOWNESS_THRESHOLD * 1000L) { logger.warn(SLOWNESS_MESSAGE, SLOWNESS_THRESHOLD); } } }
protected void initDb() throws LiquibaseException { StopWatch watch = new StopWatch(); watch.start(); super.afterPropertiesSet(); watch.stop(); logger.debug(STARTED_MESSAGE, watch.getTotalTimeMillis()); if (watch.getTotalTimeMillis() > SLOWNESS_THRESHOLD * 1000L) { logger.warn(SLOWNESS_MESSAGE, SLOWNESS_THRESHOLD); } } }
@PostConstruct protected void installCoreSchema() throws LiquibaseException { int installedVersion = getInstalledVersion(); if ( installedVersion != EXPECTED_VERSION ) { LOG.info( "Installing the core schema for Across" ); SpringLiquibase liquibase = new SpringLiquibase(); liquibase.setChangeLog( "classpath:" + getClass().getName().replace( '.', '/' ) + ".xml" ); liquibase.setDataSource( dataSource ); liquibase.setResourceLoader( applicationContext ); if ( defaultSchema != null ) { liquibase.setDefaultSchema( defaultSchema ); } liquibase.afterPropertiesSet(); updateInstalledVersion( EXPECTED_VERSION ); } else { LOG.debug( "Core schema for Across already installed, version {}", EXPECTED_VERSION ); } }
super.afterPropertiesSet(); log.info("DB migration done"); } finally {
/** * This is this {@link AcrossLiquibaseInstaller}s {@link InstallerMethod} * <p> * It will create a {@link SpringLiquibase} instance based on this {@link AcrossLiquibaseInstaller}s configuration and run a liquibase update */ @InstallerMethod public void install() throws LiquibaseException { SpringLiquibase liquibase = createSpringLiquibase(); if ( liquibase.getResourceLoader() == null ) { liquibase.setResourceLoader( applicationContext ); } liquibase.afterPropertiesSet(); }