Option to ignore invalid pattern validation for already executed changeset

Hi there.

I’ve been using Liquibase Docker image for database migration for some time.
During the time I’ve applied a lot of changesets to the target database.
At some point I’ve decided to update the version of liquibase.
However after the update I started to get the following error:

Caused by: liquibase.exception.SetupException: liquibase.exception.SetupException:
Unexpected formatting at line 2. Formatted SQL changelogs require known formats, such as ‘–changeset <authorname>:<changesetId>’ and others to be recognized and run. Learn all the options at Example Changelogs: SQL Format

It looks like the change was introduced in 4.10.0 version of Liquibase:
Here is a corresponding PR: https://github.com/liquibase/liquibase/pull/2761

Before the change Liquibase allowed to use changeset IDs with invalid format without any errors.
I understand that my changelog contains some changesets with wrong IDs however I don’t want to re-apply the changesets or update the changesets.

So here comes the question: is there a way to ignore the invalid pattern validation for the changesets that have been already successfully applied to the DB?

Hello @alromos you are correct, Liquibase now requires an Author and ID in every changeset, the new flow works like this, whenever you have a new author and ID liquibase will automatically check and confirm they were already deployed, if not liquibase will deploy it, but if the author and ID already exist, liquibase ignore them.

Liquibase uses changesets to represent a single change to your database. Here’s an example of a changeset to create a table.

Each changeset has an “id” and “author” attribute which, along with the directory and file name of the changelog file, uniquely identify it.

--changeset Bob:157
CREATE TABLE public.person (
  id int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  firstname varchar (50) NULL,
  lastname varchar (50) NOT NULL,
  state bpchar (2) NULL,
  username varchar (8) NULL,
  column1 varchar(8) NULL,
  column2 varchar NULL,
  CONSTRAINT person_pkey PRIMARY KEY (id)
);


I hope it helps :slight_smile:

@raul.balestra
thank you for your reply! Unfortunately it didn’t help me.

However I’ve managed to resolve the issue I had.
I got the error because of the line in my changeset file:

--changeset alromos: 123

As you may see there is a redundant space between the colon and the changeset ID itself.
I’ve noticed that DATABASECHANGELOG table contains a corresponding record for the changeset but the ID column of the record has the ID value without the redundant space.

ID  | AUTHOR
-------------
123 | alromos

It looks like the ID value from the changeset file was trimmed before being inserted into the table. I just decided to remove the redundant space from the changeset file and see what liquibase will do:

--changeset alromos:123

Liquibase just ignored the changeset without any warnings or errors since the final value of the changeset ID didn’t change. I was just concerned that liquibase includes the --changeset line into changeset checksum calculation and my change will change the value but it looks like I worried for nothing and the line is just ignored during the calculation.

However, answering to my own question from the previous post: it looks like there is no way to ignore the validation since the validation happens during the stage when formatted SQL changeset files are parsed and it cannot be disabled (Liquibase 4.16.1).