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(); }
public void dynamicAfterPropertiesSet(List<String> schemas) throws Exception { super.setSchemas(schemas); super.afterPropertiesSet(); } }
@Bean @DependsOn("dataSource") public SpringLiquibase liquibase() { SpringLiquibase liquibase = new SpringLiquibase(); liquibase.setDataSource(dataSource); liquibase.setChangeLog("classpath:META-INF/liquibase/application-changes.xml"); liquibase.setContexts("default"); liquibase.setDefaultSchema(databaseProperties.getJdbcSchema()); liquibase.setChangeLogParameters(createChangeLogParameters()); return liquibase;
@Configuration public class LiquibaseConfiguration { @Autowired private DataSource dataSource; //define this property in your embedded properties file or use spring's default @Value("${liquibase.change-log}") private String defaultLiquibaseChangelog; @Bean public SpringLiquibase liquibase() { SpringLiquibase liquibase = new SpringLiquibase(); liquibase.setDataSource(dataSource); liquibase.setChangeLog(defaultLiquibaseChangelog); // Configure rest of liquibase here... // ... return liquibase; } }
SpringLiquibase getSpringLiquibase() { if (springLiquibase == null) { springLiquibase = new SpringLiquibase(); springLiquibase.setChangeLog("classpath:" + liquibaseFile); springLiquibase.setContexts(contexts); springLiquibase.setDataSource(dataSource); springLiquibase.setResourceLoader(new DefaultResourceLoader()); } return springLiquibase; }
@Bean @DependsOn ("liquibaseSchemaCommonTables") public SpringLiquibase liquibasePublicSchema() { SpringLiquibase liquibase = new SpringLiquibase(); liquibase.setDataSource(dataSource); liquibase.setDefaultSchema("public"); liquibase.setChangeLog("classpath:migration/publicSchemaOnly/release.xml"); return liquibase; }
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 process(Exchange exchange) throws Exception { getSpringLiquibase().afterPropertiesSet(); }
/** * 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(); }
private LiquibaseBean createReport(SpringLiquibase liquibase, ChangeLogHistoryService service, DatabaseFactory factory) { try { DataSource dataSource = liquibase.getDataSource(); JdbcConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = null; try { database = factory.findCorrectDatabaseImplementation(connection); String defaultSchema = liquibase.getDefaultSchema(); if (StringUtils.hasText(defaultSchema)) { database.setDefaultSchemaName(defaultSchema); } service.setDatabase(database); return new LiquibaseBean(service.getRanChangeSets().stream() .map(ChangeSet::new).collect(Collectors.toList())); } finally { if (database != null) { database.close(); } else { connection.close(); } } } catch (Exception ex) { throw new IllegalStateException("Unable to get Liquibase change sets", ex); } }
@Configuration public class LiquibaseConfiguration2 { @Autowired private DataSource dataSource; //optional, define it in external configuration or through command line param @Value("${liquibase.change-log-additional:#{null}}") private String additionalLiquibaseChangelog; @Bean(name = "additionalLiquibase") public SpringLiquibase liquibase() { if (additionalLiquibaseChangelog != null) { SpringLiquibase liquibase = new SpringLiquibase(); liquibase.setDataSource(dataSource); liquibase.setChangeLog(additionalLiquibaseChangelog); // Configure rest of liquibase here... // ... return liquibase; } return null; } }
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); } } }
@Bean public SpringLiquibase liquibase() { SpringLiquibase liquibase = new SpringLiquibase(); liquibase.setDataSource(dataSource); liquibase.setChangeLog(liquibaseChangelog); return liquibase; } }
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); } } }
@Bean public SpringLiquibase liquibase(DataSource dataSource) { final SpringLiquibase liquibase = new SpringLiquibase(); liquibase.setDataSource(dataSource); liquibase.setChangeLog("classpath:liquibase/master.yml"); return liquibase; } }
@Bean @ConditionalOnBean(DataSource.class) public SpringLiquibase liquibaseSetup(DataSource dataSource) { final SpringLiquibase springLiquibase = new SpringLiquibase(); springLiquibase.setDataSource(dataSource); springLiquibase.setChangeLog("classpath:liquibase/db-changelog.xml"); return springLiquibase; }
@Bean SpringLiquibase liquibase() { SpringLiquibase springLiquibase = new SpringLiquibase(); springLiquibase.setDataSource(dataSource()); springLiquibase.setChangeLog("classpath:/META-INF/database/score.changes.xml"); return springLiquibase; }
@Bean SpringLiquibase liquibase() { SpringLiquibase springLiquibase = new SpringLiquibase(); springLiquibase.setDataSource(dataSource()); springLiquibase.setChangeLog("classpath:/META-INF/database/score.changes.xml"); return springLiquibase; }
@Bean SpringLiquibase springLiquibase(DataSource dataSource, Environment env) { SpringLiquibase liquibase = new SpringLiquibase(); liquibase.setDataSource(dataSource); liquibase.setChangeLog(env.getRequiredProperty(PROPERTY_NAME_LIQUIBASE_CHANGE_LOG)); return liquibase; } }
@Bean SpringLiquibase liquibase() { SpringLiquibase springLiquibase = new SpringLiquibase(); springLiquibase.setDataSource(dataSource()); springLiquibase.setChangeLog("classpath:/META-INF/database/score.changes.xml"); return springLiquibase; }