Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiTenantSpringLiquibase doesn't support applying it multiple database if jndi is not specified #5847

Open
1 of 2 tasks
abhiptl opened this issue Apr 25, 2024 · 0 comments

Comments

@abhiptl
Copy link

abhiptl commented Apr 25, 2024

Search first

  • I searched and no similar issues were found

Description

I am trying to use Spring Liquibase integration. Our API service is accessing multiple data sources according to HTTP request. When there is new database change(ex. add new column to table), we need to apply that change in all datasources.

It seems "MultiTenantSpringLiquibase" only works with database per tenant model only if jndi is specified with multiple datasources. In our case, all data sources are retrieved dynamically and liquibase has to apply the changes in all datasources.

Is there any way?

Below bean in used. We set dataSource explicitly null otherwise it uses schema per tenant model, We have database per tenant model. We don't want to statically specify jndi as we wanted to apply it dynamically.

@Bean
    public MultiTenantSpringLiquibase liquibase(DataSource dataSource) {
        MultiTenantSpringLiquibase multiTenantSpringLiquibase = new MultiTenantSpringLiquibase();
        multiTenantSpringLiquibase.setDataSource(null);

        multiTenantSpringLiquibase.setLiquibaseSchema("liquibase");
      
        multiTenantSpringLiquibase.setChangeLog("classpath:db.changelog/service-changelog.yaml");

        multiTenantSpringLiquibase.setShouldRun(true);

        return multiTenantSpringLiquibase;
    }

Steps To Reproduce

  • Inject above bean
  • Disable default auto configuration @SpringBootApplication(exclude={LiquibaseAutoConfiguration.class})
  • Use MultiClientDataSource class which is datasource given to liquibase bean. That datasource has multiple datasources(targetDataSources)

Expected/Desired Behavior

Find a way to extract multiple datasources instead of finding it from jndi

Liquibase Version

4.27.0

Database Vendor & Version

No response

Liquibase Integration

No response

Liquibase Extensions

No response

OS and/or Infrastructure Type/Provider

No response

Additional Context

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR (Thank you!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Planned
Development

No branches or pull requests

2 participants