Liquibase How to escape Changelog Property Substitution

763 Views Asked by At

Is it possible to escape the Liquibase Changelog Property Substitution?

This is my Changeset:

<changeSet author="me" id="changeSetOne">
    <sql>
        INSERT INTO TABLE_NAME (VALUE, DESCRIPTION) VALUES (
            '${ENVIRONMENT_VARIABLE}/some/path/',
            'describe nothing');
    </sql>
</changeSet>

The result, with (ENVIRONMENT_VARIABLE = "C:/foo"):

+-----------------+----------------+
|VALUE            |DESCRIPTION     |
+-----------------+----------------+
|C:/foo/some/path/|describe nothing|
+-----------------+----------------+

But I don't want to replace this placeholder by Liquibase, so my result should look like this:

+----------------------------------+----------------+
|VALUE                             |DESCRIPTION     |
+----------------------------------+----------------+
|${ENVIRONMENT_VARIABLE}/some/path/|describe nothing|
+----------------------------------+----------------+

Is that even possible?

1

There are 1 best solutions below

0
On

What you seek is a hack or a way to escape (eg: \${ENVIRONMENT_VARIABLE} or $${ENVIRONMENT_VARIABLE}).

I don't know if this particular issue relate to that: https://github.com/liquibase/liquibase/issues/1023 but until someone fix it, you will have to use this awesome hack™:

<property name="dollar" value="$" />

<update tableName="THE_TABLE">
  <column name="THE_COLUMN" value="${dollar}{ENVIRONMENT_VARIABLE}" />
</update>

Then, when liquibase see ${dollar}{ENVIRONMENT_VARIABLE}, it should replace it with ${ENVIRONMENT_VARIABLE}.