1

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.

3 Answers 3

3

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 105 in FormattedSqlChangelogParser.java has code to look for this attribute.

Sign up to request clarification or add additional context in comments.

3 Comments

Wow, nice. Unfortunately, it was added less than a month ago and hasn't been released yet.
I think Liquibase version 3.5.0 is planned to be released by the end of April 2016.
Good to hear. Thanks again
0

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

Comments

0

For SQL grammar use syntax:

--validCheckSum VER:HASH

It is defined by pattern:

private static final String VALID_CHECK_SUM_REGEX = "\\-\\-[\\s]*validCheckSum:? (.*)";

You can find HASH by running:

gradle validate
...
Validation Error:
     1 change sets have changed since they were ran against the database
          liquibase/007-extra.sql::4::admin was: 8:c34ff9f5715de7a8fd548c608c0dfecb but is now: 8:1c13c7c5aec287a3eb1b32093d0b1f1c

Hash 1:any is magical: means ignore the check for the block ))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.