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.
CodePudding user response:
Yeah, you can't really do that. Once you've applied a changeset it records the checksum in the config database, any changes (even whitespace) will cause this validation error. If you're using maven or gradle you can clear the checksums and they will be recomputed on the next run by using the clearChecksums goal on the liquibase plugin.
You should pay close attention, when you use the SQL option (via <include file="
I presume), it DOES NOT differ the checksum on whitespace so there are probably other differences that you are not seeing. If you're confident that the changes are inconsequential, add
--validCheckSum 8:47d241e6e1636203501ec72cafe4e5b6
to the header of your SQL file and this will tell liquibase that even though the original checksum was calculated as 8:600cf084d9c1ea85df2ddaa4f7a8a309
, 8:47d241e6e1636203501ec72cafe4e5b6
is also a valid checksum for this file.
Some good advice would be to have tighter control of these files using your RCS, otherwise you're going to be constantly fighting with this.