It seems wrong to have to modify the "id" of the changeSet via property substitution or to provide a custom <sql> statement that selects a property value in order to “force” detection of a change, when the content in a referenced <sqlFile> has the same property substitution. One of our use cases relates to the use of Linked Servers referenced either by a Synonym, or directly inside a Stored Procedure. These can change from time to time (especially in test environments), so we need the ability to redeploy the same definitions, but with the latest Link Server references . When there is need to change these references, we want the ability to deploy the same definitions, but with the latest property substitution values by changeSets defined as runOnChange=“True”`.
We are currently running Liquibase 4.23.0 where this is working as expected, but in the latest version it is not.
Example
root.xml
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<property name="link_server_1" value="another_server" global="true"/>
<property name="database_1" value="another_database" global="true"/>
<changeSet author="x" id="1" runOnChange="true">
<sql>
drop synonym if exists synonym1;
CREATE SYNONYM synonym1 FOR [${link_server_1}].[${database_1}].[dbo].[TEST1];
</sql>
<rollback>
</rollback>
</changeSet>
<changeSet author="x" id="2" runOnChange="true">
<sql>
drop synonym if exists synonym2;
</sql>
<sqlFile
path="synonym2.sql"/>
<rollback>
</rollback>
</changeSet>
<changeSet author="x" id="3" runOnChange="true">
<comment>
detect [${link_server_1}] and/or [${database_1}] change
</comment>
<sql>
select '${link_server_1}';
select '${database_1}';
</sql>
<sql>
drop synonym if exists synonym2;
</sql>
<sqlFile
path="synonym2.sql"/>
<rollback>
</rollback>
</changeSet>
</databaseChangeLog>
synonym2.sql
CREATE SYNONYM synonym2 FOR [${link_server_1}].[${database_1}].[dbo].[TEST2];
First run (all 3 changeSets are run)
Running Changeset: root.xml::1::x
[2025-02-10 10:48:03] INFO [liquibase.ui] Running Changeset: root.xml::1::x
[2025-02-10 10:48:03] INFO [liquibase.changelog] Custom SQL executed
[2025-02-10 10:48:03] INFO [liquibase.changelog] ChangeSet root.xml::1::x ran successfully in 45ms
Running Changeset: root.xml::2::x
[2025-02-10 10:48:03] INFO [liquibase.ui] Running Changeset: root.xml::2::x
[2025-02-10 10:48:03] INFO [liquibase.changelog] Custom SQL executed
[2025-02-10 10:48:03] INFO [liquibase.changelog] SQL in file synonym2.sql executed
[2025-02-10 10:48:03] INFO [liquibase.changelog] ChangeSet root.xml::2::x ran successfully in 31ms
Running Changeset: root.xml::3::x
[2025-02-10 10:48:03] INFO [liquibase.ui] Running Changeset: root.xml::3::x
[2025-02-10 10:48:03] INFO [liquibase.changelog] Custom SQL executed
[2025-02-10 10:48:03] INFO [liquibase.changelog] Custom SQL executed
[2025-02-10 10:48:03] INFO [liquibase.changelog] SQL in file synonym2.sql executed
[2025-02-10 10:48:03] INFO [liquibase.changelog] ChangeSet root.xml::3::x ran successfully in 60ms
Second run (all 3 changeSets are run)
Database is up to date, no changesets to execute
[2025-02-10 10:49:04] INFO [liquibase.ui] Database is up to date, no changesets to execute
Third run (change one of the property values)
Starting Liquibase at 10:51:08 (version 4.23.0 #10709 built at 2023-06-23 21:18+0000)
Liquibase Version: 4.23.0
[2025-02-10 10:51:08] INFO [liquibase.ui] Liquibase Version: 4.23.0
Liquibase Open Source 4.23.0 by Liquibase
[2025-02-10 10:51:08] INFO [liquibase.ui] Liquibase Open Source 4.23.0 by Liquibase
...
Running Changeset: root.xml::1::x
[2025-02-10 10:51:10] INFO [liquibase.ui] Running Changeset: root.xml::1::x
[2025-02-10 10:51:10] INFO [liquibase.changelog] Custom SQL executed
[2025-02-10 10:51:10] INFO [liquibase.changelog] ChangeSet root.xml::1::x ran successfully in 47ms
Running Changeset: root.xml::2::x
[2025-02-10 10:51:10] INFO [liquibase.ui] Running Changeset: root.xml::2::x
[2025-02-10 10:51:10] INFO [liquibase.changelog] Custom SQL executed
[2025-02-10 10:51:10] INFO [liquibase.changelog] SQL in file synonym2.sql executed
[2025-02-10 10:51:10] INFO [liquibase.changelog] ChangeSet root.xml::2::x ran successfully in 40ms
Running Changeset: root.xml::3::x
[2025-02-10 10:51:10] INFO [liquibase.ui] Running Changeset: root.xml::3::x
[2025-02-10 10:51:10] INFO [liquibase.changelog] Custom SQL executed
[2025-02-10 10:51:10] INFO [liquibase.changelog] Custom SQL executed
[2025-02-10 10:51:10] INFO [liquibase.changelog] SQL in file synonym2.sql executed
[2025-02-10 10:51:10] INFO [liquibase.changelog] ChangeSet root.xml::3::x ran successfully in 60ms
...
UPDATE SUMMARY
Run: 3
Previously run: 0
Filtered out: 0
-------------------------------
Total change sets: 3
Repeat the same, but using Liquibase 4.30.0 (changeSet id=2 is skipped)
Starting Liquibase at 10:52:55 using Java 21.0.2 (version 4.30.0 #4943 built at 2024-10-31 17:00+0000)
Liquibase Version: 4.30.0
[2025-02-10 10:52:55] INFO [liquibase.ui] Liquibase Version: 4.30.0
Liquibase Open Source 4.30.0 by Liquibase
[2025-02-10 10:52:55] INFO [liquibase.ui] Liquibase Open Source 4.30.0 by Liquibase
...
Running Changeset: root.xml::1::x
[2025-02-10 10:52:59] INFO [liquibase.ui] Running Changeset: root.xml::1::x
[2025-02-10 10:52:59] INFO [liquibase.changelog] Custom SQL executed
[2025-02-10 10:52:59] INFO [liquibase.changelog] ChangeSet root.xml::1::x ran successfully in 84ms
Running Changeset: root.xml::3::x
[2025-02-10 10:52:59] INFO [liquibase.ui] Running Changeset: root.xml::3::x
[2025-02-10 10:52:59] INFO [liquibase.changelog] Custom SQL executed
[2025-02-10 10:52:59] INFO [liquibase.changelog] Custom SQL executed
[2025-02-10 10:52:59] INFO [liquibase.changelog] SQL in file synonym2.sql executed
[2025-02-10 10:52:59] INFO [liquibase.changelog] ChangeSet root.xml::3::x ran successfully in 61ms
...
UPDATE SUMMARY
Run: 2
Previously run: 1
Filtered out: 0
-------------------------------
Total change sets: 3