# Parameter Substitution in logicalFilePath

**URL:** <https://forum.liquibase.org/t/parameter-substitution-in-logicalfilepath/6181>\
**Category:** Liquibase Development\
**Created:** [November 19, 2021, 9:31pm UTC](https://forum.liquibase.org/t/parameter-substitution-in-logicalfilepath/6181 "2021-11-19T21:31:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmeyers](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/jmeyers/32/572_2.png) [@jmeyers](https://forum.liquibase.org/u/jmeyers)\
**Post date:** [November 19, 2021, 9:31pm UTC](https://forum.liquibase.org/t/parameter-substitution-in-logicalfilepath/6181/1 "2021-11-19T21:31:16Z")

</div>

We are upgrading from 1.9.5 (I know!) to 4.6.1 and found that parameter substitution seems to no longer apply to the logicalFilePath attribute of the databaseChangeLog element.

We have multiple changelog files and depend on the logicalFilePath to normalize them regardless of their location. All changelog files have the attribute defined like this:

```auto
logicalFilePath="db.upgrade.changelog.${version}.xml"

```

Prior to upgrade, the file name recorded in the DATABASECHANGELOG table looked like this: db.upgrade.changelog.2020.3.2.xml

After the upgrade it is saved like this: db.upgrade.changelog.${version}.xml

Other parameters in the changelog appear to be working fine, so it seems to be specific to the databaseChangeLog element or logicalFilePath attribute.

Are there any ways to get this working or accomplish the same thing in a different way?

---

<div class="post-metadata">

**Author:** ![MikeOlivas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/mikeolivas/32/183_2.png) [@MikeOlivas](https://forum.liquibase.org/u/MikeOlivas)\
**Post date:** [November 24, 2021, 2:18pm UTC](https://forum.liquibase.org/t/parameter-substitution-in-logicalfilepath/6181/2 "2021-11-24T14:18:35Z")

</div>

Hi @jmeyers How were you replacing the ${version} in the 1.9.5 version of Liquibase?  
A quick workaround without knowing all the details might be to have a script replace the values before calling Liquibase update and use that new changelog file.

---

<div class="post-metadata">

**Author:** ![jmeyers](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/jmeyers/32/572_2.png) [@jmeyers](https://forum.liquibase.org/u/jmeyers)\
**Post date:** [November 24, 2021, 3:48pm UTC](https://forum.liquibase.org/t/parameter-substitution-in-logicalfilepath/6181/3 "2021-11-24T15:48:39Z")

</div>

Thanks for the reply. In 1.9.5 it worked by setting 2 parameter values using setChangeLogParameterValue() on the Liquibase object before calling update().

In 4.6.1 the only difference is I call setChangeLogParameter() as the old method no longer exists. One of the parameter substitutions seems to work and one does not. The working one uses “parentDir” to help specify the location of an sqlFile. Here is the whole changelog file:

```auto
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
				   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
				   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd"
				   logicalFilePath="db.upgrade.changelog.${version}.xml">
				   
	<changeSet author='daaSystem' id='1'>
		<sqlFile path="${parentDir}db.upgrade.sql" />
	</changeSet>

</databaseChangeLog>

```

The only difference I am aware of between the two are: one is in the “header” (i.e. the databaseChangeLog element itself) and one is in the body. I tried different names in case “version” had special meaning, but no joy.

---

<div class="post-metadata">

**Author:** ![jmeyers](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/jmeyers/32/572_2.png) [@jmeyers](https://forum.liquibase.org/u/jmeyers)\
**Post date:** [January 28, 2022, 3:31pm UTC](https://forum.liquibase.org/t/parameter-substitution-in-logicalfilepath/6181/4 "2022-01-28T15:31:09Z")

</div>

This change in behavior may track back to **CORE-1874** when `DatabaseChangeLog.load()` was modified to extract the logicalFilePath before performing any expression expansion.

Can anyone with internal knowledge of this change or how things **should** work please comment?

Is there an alternate way to dynamically change the logicalFilePath since expressions don’t seem to apply anymore?

---

<div class="post-metadata">

**Author:** ![jmeyers](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/jmeyers/32/572_2.png) [@jmeyers](https://forum.liquibase.org/u/jmeyers)\
**Post date:** [January 28, 2022, 6:22pm UTC](https://forum.liquibase.org/t/parameter-substitution-in-logicalfilepath/6181/5 "2022-01-28T18:22:01Z")

</div>

Sometimes I think I am talking to myself in these threads, but at least I can document the process and findings 😀

I believe I have successfully worked around this issue by doing the substitution myself. Setting the `DatabaseChangeLog` logicalFilePath was not sufficient (apparently a LOT of stuff happens in the constructor) I had to dig through each of the `ChangeSet` and set the filePath and storedFilePath, then it appears to work like it did years ago.

This is essentially what I had to do:

```java
Liquibase liquibase = new Liquibase(changeLogFile, sra, db);

String lfp = liquibase.getDatabaseChangeLog().getLogicalFilePath();
lfp = lfp.replace("${version}", changeLog.getVersion());
liquibase.getDatabaseChangeLog().setLogicalFilePath(lfp);

List<ChangeSet> csList = liquibase.getDatabaseChangeLog().getChangeSets();
for (ChangeSet cs : csList) {
	cs.setStoredFilePath(lfp);
	cs.setFilePath(lfp);
}

```
