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(); }
@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 ); } }
/** * 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(); }
SpringLiquibase getSpringLiquibase() { if (springLiquibase == null) { springLiquibase = new SpringLiquibase(); springLiquibase.setChangeLog("classpath:" + liquibaseFile); springLiquibase.setContexts(contexts); springLiquibase.setDataSource(dataSource); springLiquibase.setResourceLoader(new DefaultResourceLoader()); } return springLiquibase; }