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

No changesets run when having multiple changelogs against the same DB #4891

Closed
1 of 2 tasks
vladimirivanov91 opened this issue Sep 12, 2023 · 1 comment · Fixed by #5039
Closed
1 of 2 tasks

No changesets run when having multiple changelogs against the same DB #4891

vladimirivanov91 opened this issue Sep 12, 2023 · 1 comment · Fixed by #5039

Comments

@vladimirivanov91
Copy link

Search first

  • I searched and no similar issues were found

Description

I have a Spring Boot microservice application. Each microservice has its own database with one schema managed by Liquibase with Spring Boot. Each Spring Boot application depends on an internal library which adds functionality based on additional database objects which are managed in a separate changelog file part of the library and a separate changelog table. Each changelog is handled by a dedicated SpringLiquibase bean configured with the corresponding changelog file and changelog table ending up in something like:

springLiquibaseBean1: 
  DataSource: "dataSource1"
  ChangeLog:  "changeLog1.xml"
  . . .

springLiquibaseBean2: 
  DataSource: "dataSource1"
  ChangeLog: "changeLog2.xml"
  . . .

Because of the changes introduced with version 4.21.0 regarding update fast check, Liquibase is checking for updates based on the first changelog and caches the result under the same key that would be used for the second changelog, hence might ignore updates by the second changelog. # 4427 is solving some issues in that regard by extending the cache key with default schema name, default catalog name and connection URL, but this is not enough in my case as those would be the same but the changelog files and tables are different.

Steps To Reproduce

Create Spring Boot application with two changelog files (e.g. changelog1.xml, changelog2.xml). Register two SpringLiquibase beans and configure them to handle the changelog files:

    @Bean
    public SpringLiquibase liquibase1(
            DataSource dataSource,
            LiquibaseProperties liquibaseProperties) {

        SpringLiquibase liquibase = new SpringLiquibase();
        liquibase.setShouldRun(true);
        liquibase.setDataSource(dataSource);
        liquibase.setChangeLog("classpath:changelog1.xml");
        liquibase.setContexts(liquibaseProperties.getContexts());
        liquibase.setDefaultSchema(liquibaseProperties.getDefaultSchema());
        liquibase.setDropFirst(liquibaseProperties.isDropFirst());

        return liquibase;
    }

    @Bean
    public SpringLiquibase liquibase2(
            DataSource dataSource,
            LiquibaseProperties liquibaseProperties) {

        SpringLiquibase liquibase = new SpringLiquibase();
        liquibase.setShouldRun(true);
        liquibase.setDataSource(dataSource);
        liquibase.setChangeLog("classpath:changelog2.xml");
        liquibase.setContexts(liquibaseProperties.getContexts());
        liquibase.setDefaultSchema(liquibaseProperties.getDefaultSchema());
        liquibase.setDropFirst(liquibaseProperties.isDropFirst());

        return liquibase;
    }

Add changesets to the second changelog file (changelog2.xml) and run the application.

Expected/Desired Behavior

Changesets from both changelogs get executed.

Liquibase Version

4.21.x 4.22.x 4.23.x

Database Vendor & Version

No response

Liquibase Integration

Spring boot

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!)
@nwwerum
Copy link

nwwerum commented Sep 29, 2023

We ran into the exact same scenario with spring boot at my company. It looks to me, like this would be solved quite easily by adding databaseChangeLog.getLogicalFilePath() to the cacheKey used for the up-to-date-fast-check here:
https://github.com/liquibase/liquibase/blob/master/liquibase-standard/src/main/java/liquibase/command/core/AbstractUpdateCommandStep.java#L228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants