liquibase / liquibase

Main Liquibase Source
https://www.liquibase.org
Apache License 2.0
4.65k stars 1.85k forks source link

LiquibaseConfiguration multi database not update #4501

Open zeje opened 1 year ago

zeje commented 1 year ago

Search first

Description

LiquibaseConfiguration multi database not update

I have multi database in a project,so i init multi SpringLiquibase.

SpringLiquibase(baseLiquibase) Bean init first SpringLiquibase(codegenLiquibase) Bean init second

base database has no any update(or it has update) codegen database has some update

then I debug the springboot application, codegen database not update.

after that,i delete the baseLiquibase Bean

then I debug again.

the codegen database updated.

Steps To Reproduce

`package com.pig4cloud.pigx.db;

import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider; import liquibase.integration.spring.SpringLiquibase; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.DependsOn; import org.springframework.core.io.DefaultResourceLoader;

import javax.sql.DataSource; import java.util.List;

@Configuration public class LiquibaseConfiguration {

@Autowired
private List<DynamicDataSourceProvider> providers;

@Bean
public SpringLiquibase baseLiquibase() {
    return buildLiquibase("base");
}

@Bean
@DependsOn("baseLiquibase")
public SpringLiquibase codegenLiquibase() {
    return buildLiquibase("codegen");
}

private SpringLiquibase buildLiquibase(String module) {
    DataSource dataSource = providers.get(0).loadDataSources().get(module);

    SpringLiquibase liquibase = new SpringLiquibase();
    // 模块Liquibase文件路径
    liquibase.setChangeLog("classpath:liquibase/" + module + "/db.changelog.xml");
    liquibase.setDataSource(dataSource);
    liquibase.setShouldRun(true);
    liquibase.setResourceLoader(new DefaultResourceLoader());
    // 覆盖Liquibase changelog表名
    liquibase.setDatabaseChangeLogTable(module + "_changelog_table");
    liquibase.setDatabaseChangeLogLockTable(module + "_changelog_lock_table");
    return liquibase;
}

}`

Expected/Desired Behavior

mutli SpringLiquibase @Bean can run normal.

Liquibase Version

4.23.0

Database Vendor & Version

MySql 8.x

Liquibase Integration

spring boot

Liquibase Extensions

No response

OS and/or Infrastructure Type/Provider

windows 11

Additional Context

No response

Are you willing to submit a PR?

zeje commented 1 year ago

2023-07-19 23:23:57.906 INFO 32312 --- [ main] liquibase.util : UPDATE SUMMARY 2023-07-19 23:23:57.906 INFO 32312 --- [ main] liquibase.util : Run: 7 2023-07-19 23:23:57.906 INFO 32312 --- [ main] liquibase.util : Previously run: 0 2023-07-19 23:23:57.906 INFO 32312 --- [ main] liquibase.util : Filtered out: 0 2023-07-19 23:23:57.906 INFO 32312 --- [ main] liquibase.util : ------------------------------- 2023-07-19 23:23:57.906 INFO 32312 --- [ main] liquibase.util : Total change sets: 7

UPDATE SUMMARY Run: 7 Previously run: 0 Filtered out: 0

Total change sets: 7

2023-07-19 23:23:57.906 INFO 32312 --- [ main] liquibase.util : Update summary generated 2023-07-19 23:23:57.906 DEBUG 32312 --- [ main] liquibase.executor : Release Database Lock 2023-07-19 23:23:57.911 DEBUG 32312 --- [ main] liquibase.executor : Changelog query completed. 2023-07-19 23:23:57.915 INFO 32312 --- [ main] liquibase.lockservice : Successfully released change log lock 2023-07-19 23:23:57.916 DEBUG 32312 --- [ main] liquibase.servicelocator : Loaded liquibase.lockservice.LockService instance liquibase.lockservice.LockServiceImpl 2023-07-19 23:23:57.916 DEBUG 32312 --- [ main] liquibase.servicelocator : Loaded liquibase.lockservice.LockService instance liquibase.lockservice.MockLockService 2023-07-19 23:23:57.916 DEBUG 32312 --- [ main] liquibase.servicelocator : Loaded liquibase.lockservice.LockService instance liquibase.lockservice.OfflineLockService 2023-07-19 23:23:57.916 DEBUG 32312 --- [ main] liquibase.servicelocator : Loaded liquibase.lockservice.LockService instance liquibase.lockservice.StandardLockService 2023-07-19 23:23:57.919 DEBUG 32312 --- [ main] liquibase.executor : Release Database Lock 2023-07-19 23:23:57.922 DEBUG 32312 --- [ main] liquibase.executor : Changelog query completed. 2023-07-19 23:23:57.924 INFO 32312 --- [ main] liquibase.lockservice : Successfully released change log lock