Property Substitution in changelogs - Is it a Pro feature?

Hello,

I tried to use the property substitution as described in this article.

In detail, I used a simple SQL script in a .sql file:
CREATE SCHEMA ${dbschema};

In CLI:
liquibase updateSql -Ddbschema=test1

But unfortunately the output of the command returns this:
CREATE SCHEMA ${dbschema};

→ The substitution/replacement simply does not work for me.
Does someone have the same problem?
Am I doing something wrong?

I am using Liquibase Open Source 4.23.0

Here the full output from my CLI:

$ liquibase updateSql -Ddbschema=test1
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ##
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ##
##                                                ##
####################################################
Starte Liquibase am 13:30:00 (Version 4.23.0 #10709, kompiliert am 2023-06-23 21:18+0000)
Liquibase Version: 4.23.0
Liquibase Open Source 4.23.0 by Liquibase
SET SEARCH_PATH TO public, "$user","public";

-- Lock Database
UPDATE public.databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = 'UGW11530 (192.168.178.61)', LOCKG
RANTED = 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: liquibase_main.yml
-- Ran at: 14.07.23, 13:30
-- Against: postgres@jdbc:postgresql://localhost:5432/postgres
-- Liquibase version: 4.23.0
-- *********************************************************************

SET SEARCH_PATH TO public, "$user","public";

-- Changeset sql_changesets/all_schemas/test_all_schemas.sql::raw::includeAll
SET SEARCH_PATH TO public, "$user","public";

--changeset lucas:1
CREATE SCHEMA ${dbschema};

INSERT INTO public.databasechangelog (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DES
CRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('raw', 'includeAll
', 'sql_changesets/all_schemas/test_all_schemas.sql', NOW(), 20, '9:a4f1942d1e1fe5389ac1b444366675ec
', 'sql', '', 'EXECUTED', NULL, NULL, '4.23.0', '9334200812');

-- 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";

Liquibase command 'updateSql' was executed successfully.

I’m using 4.21.1 community, and substitution is working fine.

Command:
liquibase updateSql -Dschema_id=tester -Dmode=read

Changeset:

--changeset bob:grant_test_country_privs
GRANT SELECT ON test_country TO ${schema_id}_${mode}_only;

Resulting sql:
GRANT SELECT ON test_country TO tester_read_only;

1 Like

Good to know, thank you!
So I just need to find my error…
Do I need a specific setting in the liquibase.properties file?

There is nothing in the liquibase.properties related to parameter substitution. I only have the user, password, and url in the file.

I found my issue here.
The .sql file that contained the parameterized SQL statement, was missing this line at the top:

-- liquibase formatted sql
1 Like