Reputation: 749
I have a spring boot application which connects to a Postgres SQL database which has 2 separate schemas.
Can I set up Liquidbase to be able to manage/apply changes in the tables that reside in separate shemas inside the same database?
Upvotes: 1
Views: 784
Reputation: 2123
You can create multiple SpringLiquibase beans, each with their own changelog files. For example...
@Configuration
public class DatabaseConfiguration {
@Bean
@ConfigurationProperties(prefix = "datasource.schema1")
public DataSource schema1DataSource() {
return DataSourceBuilder.create().build();
}
@Bean
@ConfigurationProperties(prefix = "datasource.schema2")
public DataSource schema2DataSource() {
return DataSourceBuilder.create().build();
}
@Bean
public SpringLiquibase schema1Liquibase() {
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setChangeLog("classpath:/META-INF/liquibase/changelog/schema1-changelog-master.xml");
liquibase.setDataSource(schema1DataSource());
return liquibase;
}
@Bean
public SpringLiquibase schema2Liquibase() {
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setChangeLog("classpath:/META-INF/liquibase/changelog/schema2-changelog-master.xml");
liquibase.setDataSource(schema2DataSource());
return liquibase;
}
}
Upvotes: 1