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

LiquibaseConfiguration multi database not update #4501

Open
1 of 2 tasks
zeje opened this issue Jul 17, 2023 · 1 comment
Open
1 of 2 tasks

LiquibaseConfiguration multi database not update #4501

zeje opened this issue Jul 17, 2023 · 1 comment

Comments

@zeje
Copy link

zeje commented Jul 17, 2023

Search first

  • I searched and no similar issues were found

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?

  • I'm willing to submit a PR (Thank you!)
@zeje zeje closed this as completed Jul 18, 2023
@zeje zeje reopened this Jul 19, 2023
@zeje
Copy link
Author

zeje commented Jul 19, 2023

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

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

No branches or pull requests

2 participants