1
votes

Liquibase provides a <validCheckSum> tag to allow for a new checksum to be specified in case we want to modify an existing changeset.

However, this tag is not a valid attribute for SQL-formatted changesets. There is runOnChange, but that's different.

Is there any way of achieving that?

Basically, I made a mistake on a changeset, and I can't even add a rollback command because liquibase detects the checksum change and spits an error, so I'm stuck.

EDIT

The concrete changeset that I'm trying to change is:

--liquibase formatted sql

--changeset myname:0
ALTER TABLE `customers`
CHANGE COLUMN `name` `firstName` VARCHAR(45) NULL;

--changeset myname:1
ALTER TABLE `customers`
ADD COLUMN `lastName` VARCHAR(45) NULL AFTER `firstName`;

And I keep it in a file changelog_1.05.sql. Finally, I include that file in my changelog.xml:

<include file="changelog_1.05.sql" relativeToChangelogFile="true"/>

I can't add <validCheckSum> because is a SQL-formatted file, so no xml tags can be added there.

2

2 Answers

1
votes

Even though it is not documented, looking at the source it appears that validCheckSum is a valid attribute in a formatted sql changelog. You can see line 89 in FormattedSqlChangelogParser.java has code to look for this attribute.

0
votes

I ended up here trying to use the validCheckSum with SQL files in Liquibase 3.9.0. It works, but only when the "--validCheckSum" is in a new line without other attributes (as opposed to other attributes such as "--runAlways": --changeset me:test --runAlways:true --splitStatements:false --validCheckSum: 1:any

This seems to be due to the regex for parsing the attribute: https://github.com/liquibase/liquibase/blob/17fcfe4f8dae96ddb4caa6793051e47ce64ad933/liquibase-core/src/main/java/liquibase/parser/core/formattedsql/FormattedSqlChangeLogParser.java#L87