I have a new Java development project attempting to use the Java Spring api to seed a MySQL 5.7, 8.0 database.
I cannot use the auto configuration (spring.liquibase.enabled=false
) but am still running in spring and attempting to use that implementation through the following code:
public void update(DataSource dataSource, ResourceLoader resourceLoader, @Nullable Map<String, String> parameters) {
Scope.setScopeManager(new ThreadLocalScopeManager());
var springLiquibase = new SpringLiquibase();
springLiquibase.setShouldRun(true);
springLiquibase.setTestRollbackOnUpdate(false);
springLiquibase.setDatabaseChangeLogTable(LOG_TABLE_NAME);
springLiquibase.setDatabaseChangeLogLockTable(LOCK_TABLE_NAME);
springLiquibase.setChangeLog(dbChangeLog);
springLiquibase.setDataSource(dataSource);
springLiquibase.setResourceLoader(resourceLoader);
if (parameters != null) {
springLiquibase.setChangeLogParameters(parameters);
}
try {
springLiquibase.afterPropertiesSet();
} catch (LiquibaseException e) {
throw new RuntimeException(e);
}
}
Things seem to be mostly working well but I have seen a number situations where it does not appear to apply change sets even though the change log table is empty.
However, what I am trying to debug right now is a situation where a custom change set is never re-run after the initial seeding:
<changeSet author="ben.self" id="1687307709350-LAST" runOrder="last" runAlways=true>
<customChange class="my.package.CustomChangeSet">
<param name="tenant" value="${tenant}"/>
</customChange>
</changeSet>
I know the above works and see it run if all the tables and databases have been dropped. But it never seems to run again and always outputs the following:
Database is up to date, no changesets to execute
...
UPDATE SUMMARY
Run: 1
Previously run: 11
Filtered out: 0
-------------------------------
Total change sets: 12
Does anyone have any ideas how to fix this?