property-substitution-enabled
--property-substitution-enabled
is a command argument specific to checks run
that allows you to determine when property substitution occurs in a changelog. You can change the default timing of property expansion in your changesets. This argument is for the whole of checks run
, not a specific Policy check.
- When
--property-substitution-enabled
istrue
, thechecks run
command evaluates the changeset after Liquibase replaces the property token,${token}
, with a value. - When
--property-substitution-enabled
isfalse
, thechecks run
command evaluates the changeset before Liquibase replaces the property token,${token}
, with a value.
Learn more here: Substituting Properties in Changelogs.
Uses
For example, consider a stored procedure that you want to modify depending on your environment, which you configure using Contexts. You can use the --property-substitution-enabled
parameter on checks run
to dynamically modify your SQL.
In this example, Liquibase replaces ${prop}
with @uat_db
within changesets where the UAT context is active and @prod_db
within changesets where the PROD context is active:
<property name="prop" value="@uat_db" context="UAT"/>
<property name="prop" value="@prod_db" context="PROD"/>
Notice ${prop}
in the following example. This is the name of the example property:
SELECT *
FROM my_table${prop}
WHERE column1 > column2;
Based on the value of --property-substitution-enabled
, Liquibase behaves in one of two ways:
- If
--property-substitution-enabled=true
, thechecks run
command sees the value of the property substitution (which could be the string@uat_db
or the string@prod_db
):
SELECT *
FROM my_table@uat_db
WHERE column1 > column2;
--property-substitution-enabled=false
, the checks run
command sees the token string:SELECT *
FROM my_table${prop}
WHERE column1 > column2;
Syntax
You can set this parameter in the following ways:
Option | Syntax |
---|---|
Liquibase properties file |
|
Command flow file argument (example) |
|
Command CLI parameter |
|
JVM system property (JAVA_OPTS Environment Variable) |
|
Liquibase Environment Variables |
|
For more information, see Working with Command Parameters.