When we upgrade liquibase-core from version 4.21 to 4.27 and run it against our existing database (which is set up with liquibase) it shows all the previously applied changelogs.
There’s been quite a few updates since 4.21. Namely the addition of preConditions. Should I mark all my previous changesets with preCondition MARK_RAN? If not, why are all the previously run changesets showing in my my update command?
public void init() {
if (Objects.isNull(dataSourceProperties)) {
throw new RuntimeException("DataSourceProperties is null for databaseName: " + databaseName);
}
dataSource = DataSourceBuilder
.create()
.url(dataSourceProperties.getUrl())
.username(dataSourceProperties.getUsername())
.password(dataSourceProperties.getPassword())
.build();
springLiquibase = new ActionableSpringLiquibase();
springLiquibase.setDataSource(dataSource);
springLiquibase.setChangeLog(liquibaseProperties.getChangeLog());
springLiquibase.setContexts(liquibaseProperties.getContexts());
springLiquibase.setDefaultSchema(liquibaseProperties.getDefaultSchema());
springLiquibase.setDropFirst(liquibaseProperties.isDropFirst());
springLiquibase.setShouldRun(liquibaseProperties.isEnabled());
springLiquibase.setLabelFilter(liquibaseProperties.getLabelFilter());
springLiquibase.setChangeLogParameters(liquibaseProperties.getParameters());
springLiquibase.setRollbackFile(liquibaseProperties.getRollbackFile());
}
private Liquibase getLiquibase() throws SQLException, LiquibaseException {
return springLiquibase.createLiquibase(dataSource.getConnection());
}
public String getUpdateDiff() {
try (StringWriter out = new StringWriter();
Liquibase liquibase = this.getLiquibase() ) {
liquibase.update(new Contexts(), out);
return out.toString();
} catch (Exception e) {
throw new RuntimeException("Unable to get update diff: " + e.getMessage(), e);
}
}
public class ActionableSpringLiquibase extends DataSourceClosingSpringLiquibase {
public Liquibase createLiquibase(Connection c) throws LiquibaseException {
return super.createLiquibase(c);
}
}