How to fix ValidationFailedException in liquibase checksum?

I am using liquibase with spring boot. I am having SQL changesets. I have not changed anything in the liquibase SQL scripts. but I am getting below error

Error creating bean with name ‘liquibase’ defined in class path
resource: Invocation of init method failed; nested exception is
liquibase.exception.ValidationFailedException: Validation Failed:\r\n
1 change sets check sum\r\n
liquibase/db/0001_sample.sql::sample1_2::admin was:
8:600cf084d9c1ea85df2ddaa4f7a8a309 but is now:
8:47d241e6e1636203501ec72cafe4e5b6\r\n",
“class”: “org.springframework.beans.factory.BeanCreationException”,

Below is my 0001_table1.sql

--liquibase formatted sql
--changeset admin:sample1_1
create table....
--rollback DROP TABLE tablename

--changeset admin:sample1_2
add column....

I think this is due to formatting changing from my IDE to another ide. But I like to fix it. I am not looking for clearing checksum. Please suggest how to handle when using plain SQL with liquibase.

Note: I have seen examples with xml version, but I am looking for SQL with liquibase.

Could you use a SQL UPDATE statement to change it in DATABASECHANGELOG?

You should break your change sets up. Don’t use a single file since when you add to it, the hash will change.

Here’s how we have ours set up:

changelog.xml:

<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog
	xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
	xmlns:pro="http://www.liquibase.org/xml/ns/pro"
	xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
		http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.9.xsd
		http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
		http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.9.xsd">

    <includeAll path="schema/"/>
</databaseChangeLog>

and then we use the schema/ folder to keep them organized. Don’t mind the xml suffixes, you can use sql files if you like. They are done in sequential order:

ekolp@KRSDEVEKOLPMBP13 liquibase % ls -lash schema 
total 16
0 drwxr-xr-x   4 ekolp  staff   128B Apr 19 16:53 .
0 drwxr-xr-x  16 ekolp  staff   512B Apr 19 16:53 ..
8 -rw-r--r--   1 ekolp  staff   1.3K Apr 19 16:53 221.xml
8 -rw-r--r--   1 ekolp  staff   1.9K Apr 18 11:02 222.xml

then a run looks like this:

Schema change running for elk on Mon Apr 18 21:30:56 UTC 2022
[2022-04-18 21:31:03] INFO [liquibase.integration] No Liquibase Pro license key supplied. Please set liquibaseProLicenseKey on command line or in liquibase.properties to use Liquibase Pro features.
Liquibase Community 4.3.4 by Datical
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ## 
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ## 
##  Free schema change activity reports at        ##
##      https://hub.liquibase.com                 ##
##                                                ##
####################################################
Starting Liquibase at 21:31:03 (version 4.3.4 #55 built at 2021-04-19 20:18+0000)
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
[2022-04-18 21:31:06] INFO [liquibase.lockservice] Successfully acquired change log lock
[2022-04-18 21:31:07] INFO [liquibase.changelog] Reading resource: schema/221.xml
[2022-04-18 21:31:08] INFO [liquibase.changelog] Reading resource: schema/222.xml
[2022-04-18 21:31:08] INFO [liquibase.changelog] Reading from elk.DATABASECHANGELOG
[2022-04-18 21:31:09] INFO [liquibase.ext] Using percona toolkit: 3.3.0
[2022-04-18 21:31:09] INFO [liquibase.lockservice] Successfully released change log lock
[2022-04-18 21:31:09] INFO [liquibase.lockservice] Successfully acquired change log lock
Skipping auto-registration
[2022-04-18 21:31:09] WARNING [liquibase.hub] Skipping auto-registration
[2022-04-18 21:31:09] INFO [liquibase.changelog] Index ProductCodeText dropped from table linesum
[2022-04-18 21:31:09] INFO [liquibase.changelog] ChangeSet schema/221.xml::221-2::ekolp ran successfully in 66ms
[2022-04-18 21:31:09] INFO [liquibase.changelog] Columns created_at(DATETIME) added to member_custom_fields
[2022-04-18 21:31:09] INFO [liquibase.changelog] ChangeSet schema/222.xml::222-1::ekolp ran successfully in 95ms
[2022-04-18 21:31:09] INFO [liquibase.changelog] Columns updated_at(TIMESTAMP) added to member_custom_fields
[2022-04-18 21:31:09] INFO [liquibase.changelog] ChangeSet schema/222.xml::222-2::ekolp ran successfully in 73ms
[2022-04-18 21:31:09] INFO [liquibase.lockservice] Successfully released change log lock
Liquibase: Update has been successful.

I may have misread the original post. I will leave my posts up in case they are needed.