Labels option is not working in liquibase

Hi Team,

I am trying to use labels for Changelog files. While using labels in Changelog files, Liquibase unable to filter or Skip the changes based on the labels.

here is an example:

chnagelog file:

m2.sql:

–postgres formatted sql
–changeset vemulur:create_table_test2 labels:prod tags:test-table

create table test2(id int);

–rollback not;

Liquibase apply:

liquibase --changeLogFile=m2.sql --username=analytics --password=analytic --url=jdbc:postgresql://stage.abc.amazonaws.com:1111/analytics --labels=stage update-sql

Output As below:

Starting Liquibase at 21:56:03 (version 4.24.0 #14062 built at 2023-09-28 12:18+0000)
Liquibase Version: 4.24.0
Liquibase Open Source 4.24.0 by Liquibase
SET SEARCH_PATH TO public, “$user”,“public”;

– Lock Database
UPDATE public.databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = ‘STAGE-IP’, LOCKGRANTED = NOW() WHERE ID = 1 AND LOCKED = FALSE;

SET SEARCH_PATH TO public, “$user”,“public”;

SET SEARCH_PATH TO public, “$user”,“public”;

– *********************************************************************
– Update Database Script
– *********************************************************************
– Change Log: m2.sql
– Ran at: 10/16/23, 9:56 PM
– Against: analytics@jdbc:postgresql://stage.abc.amazonaws.com:1111/analytics
– Liquibase version: 4.24.0
– *********************************************************************

– Changeset m2.sql::raw::includeAll
SET SEARCH_PATH TO public, “$user”,“public”;

–postgres formatted sql
–changeset vemulur:create_table_test2 labels:prod-us tags:test table

create table test2(id int);

–rollback not;

INSERT INTO public.databasechangelog (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (‘raw’, ‘includeAll’, ‘m2.sql’, NOW(), 13, ‘9:ac6659ae9910a854657002a2e2e11c44’, ‘sql’, ‘’, ‘EXECUTED’, NULL, NULL, ‘4.24.0’, NULL);

– Release Database Lock
SET SEARCH_PATH TO public, “$user”,“public”;

UPDATE public.databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;

SET SEARCH_PATH TO public, “$user”,“public”;

Logs saved to liquibase.log
Liquibase command ‘update-sql’ was executed successfully.

**

  1. In my Change log SQL file I have used labels:prod
  2. running Liquibase command with labels:stage
    When I run liquibase command with labels:stage , its applyting the db changes.

May I know how I can avoid the such changes, I want to use labels based on matching pattern only.

Command I used:

liquibase --changeLogFile=m2.sql --username=analytics --password=analytic --url=jdbc:postgresql://stage.abc.amazonaws.com:1111/analytics --labels=stage update-sql**

May I get any help on this please. I am doing this in Postgres DB. Unable to see Label filterations.