Clear Liquibase checksum on upgrade

Table of Contents

overview

Recently, I upgraded from spring 3.5 to 4. It went quite smoothly thanks to openrewrite script. There are some hiccups of course (with jackson objectmapper, custom deserializer) but thanks to Claude, those are solved quite quickly.

One strange thing is that liquibase checksum changed. Many past migrations failed due to this error (I don’t change those files at all).

Caused by: liquibase.exception.LiquibaseException: liquibase.exception.CommandExecutionException: liquibase.exception.ValidationFailedException: Validation Failed:
     1 changesets check sum
          db/changelog/changes/2026-03-01-01.xml::2026-03-01-01-2::dat was: 9:0b9c884851fa9e1ce36f4417008f9351 but is now: 9:6f974304da8b4b864de9f05a62c49c40

	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:289)
	at org.springframework.boot.liquibase.autoconfigure.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1862)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1811)
	... 93 common frames omitted
Caused by: liquibase.exception.CommandExecutionException: liquibase.exception.ValidationFailedException: Validation Failed:
     1 changesets check sum
          db/changelog/changes/2026-03-01-01.xml::2026-03-01-01-2::dat was: 9:0b9c884851fa9e1ce36f4417008f9351 but is now: 9:6f974304da8b4b864de9f05a62c49c40

	at liquibase.command.CommandScope.lambda$execute$5(CommandScope.java:325)
	at liquibase.Scope.child(Scope.java:252)
	at liquibase.Scope.child(Scope.java:228)
	at liquibase.command.CommandScope.execute(CommandScope.java:257)
	at liquibase.Liquibase.lambda$update$0(Liquibase.java:216)
	at liquibase.Scope.lambda$child$0(Scope.java:243)
	at liquibase.Scope.child(Scope.java:252)
	at liquibase.Scope.child(Scope.java:242)
	at liquibase.Scope.child(Scope.java:221)
	at liquibase.Liquibase.runInScope(Liquibase.java:1366)
	at liquibase.Liquibase.update(Liquibase.java:205)
	at liquibase.Liquibase.update(Liquibase.java:188)
	at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:327)
	at liquibase.integration.spring.SpringLiquibase.lambda$afterPropertiesSet$0(SpringLiquibase.java:279)
	at liquibase.Scope.lambda$child$0(Scope.java:243)
	at liquibase.Scope.child(Scope.java:252)
	at liquibase.Scope.child(Scope.java:242)
	at liquibase.Scope.child(Scope.java:221)
	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:272)
	... 96 common frames omitted
Caused by: liquibase.exception.ValidationFailedException: Validation Failed:
     1 changesets check sum
          db/changelog/changes/2026-03-01-01.xml::2026-03-01-01-2::dat was: 9:0b9c884851fa9e1ce36f4417008f9351 but is now: 9:6f974304da8b4b864de9f05a62c49c40

	at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:392)
	at liquibase.command.core.helpers.DatabaseChangelogCommandStep.run(DatabaseChangelogCommandStep.java:89)
	at liquibase.command.CommandScope.lambda$execute$5(CommandScope.java:269)
	... 114 common frames omitted
01:26:01,133 |-WARN in ch.qos.logback.classic.model.processor.ConfigurationModelHandlerFull - Missing watchable .xml or .properties files.
01:26:01,134 |-WARN in ch.qos.logback.classic.model.processor.ConfigurationModelHandlerFull - Watching .xml files requires that the main configuration file is reachable as a URL

The fix

If you can connect to your database from your local machine where you have your code, that’s quite simple, you can just run:
mvn liquibase:clearCheckSums

and that’s it, given you configure your liquibase and provide it with your configurations to database:

            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>${liquibase-hibernate.version}</version>
                <configuration>
                    <driver>org.postgresql.Driver</driver>
                    <url>${env.DB_URL}</url>
                    <username>${env.DB_USERNAME}</username>
                    <password>${env.DB_PASSWORD}</password>
                    <outputFile>src/main/resources/db/changelog/changes/${maven.build.timestamp}.xml</outputFile>
                    <logging>info</logging>
                    <verbose>true</verbose>
                </configuration>
              .....
			</plugin>

However, on your production container, things are not that easy, you don’t have maven, you don’t have liquibase and also your code. Here are the commands to use

curl -L -s -o liquibase-4.25.0.zip https://github.com/liquibase/liquibase/releases/download/v4.25.0/liquibase-4.25.0.zip


docker cp /tmp/liquibase_extracted/. vp3_api:/tmp/liquibase/ && docker exec YOUR_CONTAINER_NAME_OR_ID bash -c '
# Find the application jar to use its internal database drivers
APP_JAR=$(find / -name "*.jar" ! -path "/tmp/*" | head -n 1)

# Execute Liquibase directly using Java with logging enabled
java -cp "/tmp/liquibase/internal/lib/*:/tmp/liquibase/liquibase.jar:$APP_JAR" \
  liquibase.integration.commandline.LiquibaseCommandLine \
  --log-level=INFO \
  --url="jdbc:postgresql://DB_HOST:DB_PORT/DB_NAME" \
  --username="DB_USERNAME" \
  --password="DB_PASSWORD" \
  clear-checksums
'

As you can see, I use postresql, you need to update the configuration that you use.

You should see liquibase command run successfully.

That’s it! Your app can run again.

Leave a Comment