How to recalculate checksums without re-running the statements in liquibase?

Hi team,

We were upgrade our liquibase from 1.9.0.0 to 3.6.3. When running migration MD5SUM for 3.6.3 was updated but it was trying to re-run the previously executed changesets which were executed with liquibase 1.9.0.0. How do i run only updating checksum with without re-running the statements.

Thanks.

Hi @Dilli_Babu_S

The command you are looking for is “ClearCheckSums”. Find more about it here.

clearCheckSums clears all checksums and nullifies the MD5SUM column of the DATABASECHANGELOG table so they will be re-computed on the next database update.

changesets that have been deployed will have their checksums re-computed, and pending changesets will be deployed.

On the next database update, liquibase will run only those changesets which were not executed earlier however will calculate a new MD5 checksum value for already executed changesets.

You can give it a try. Hope this helps. Please let us know if you encounter any other issues with this.

Cheers!

Rakhi Agrawal

Hi @rakhi , Thanks a lot for your clear answer. If i clear checksum then will liquibase will only recalculate checksum or it will again run all the changeset statements of already deployed changes.

To clear your doubt, let’s imagine of a scenario.

  1. You already have run liquibase update once. Let’s assume, your chagesets were executed without any issues and the checksums were also calculated and were stored in the DATABASECHANGELOG table.
  2. Now due to some new requirements you have added few more changesets to your project and want them to run on top of the DB table resulted from step 1 above.
  3. You just do clearCheckSums and run liquibase update. This step will clear the checksum value from DATABASECHANGELOG table and recompute the value for the changestes already executed as a part of step 1. (Please note liquibase will not re-run the changesets of step 1. And will only run/execute the changesets created/added in step 2.

Note: It is expected that there is no change done in the DB state resulted from step 1.

Hope this clears your doubt. Also I hope my understanding to your doubt is correct.

Thanks,
Rakhi Agrawal

1 Like

Hey @rakhi , You exactly cleared my doubt. Thanks a lot for you clear answer with a scenario.

1 Like

Hi Rakhi ,

I updated my liquibase from 3.8.5 to 4.3.5 using spring boot . I used clearCheckSums which cleared/null the value from DATABASECHANGELOG . However running the liquibase again is NOT recalculating the checksum values for the old entries which was created using 3.8.5 , I still see the null values for those . Please advise .