Can we dynamically pass values to <property> variables

Hi I know we can use tag to dynamically change the values. For example
"
< property name=“table.name” value=“tableA”/>
< changeSet id=“1” author=“joe”>
< createTable tableName="${table.name}">
< column name=“id” type=“int”/>
</ createTable>
</ changeSet>
</ databaseChangeLog>

How do I pass different values second time, for example this time I want to tableName as tableB. And consider I have 10 tables to create.

That is an interesting question. @MikeOlivas do you know how can achieve this ?

Hi @varunkumar

Are you trying to say you will be creating 10 tables having same structure? As in same columns in all these tables?

Also I don’t think you will be able to execute same changeset 10 times, as it will result in checksum issue because of same ID everytime. You will anyways have to create 10 different changesets.

And yes, you can define multiple properties in your liquibase.properties file and then use property substitution ${} to read/access those property values in changesets. OR you can define multiple property tags inside the changset itself for each table name.

Thanks!
Rakhi Agrawal

Hi @rakhi Thanks for the response.

No we are not creating 10 tables with same structure. I just used it for example. we have sql files executing some code. In that I need to use this variable. I tried manually passing value in property tag as below which worked.
< property name=“table.name” value=“tableA”/>

I want this value tableA in a properties file and use it in a sql file like this

< property  name="table.name"  value="${tablename}"/>
< changeSet id=“1” author=“joe”>
        <sqlFile path="src/main/sql/test.sql"/>

This didn’t worked for me. I believe this is the solution you provided in third paragraph. can you give me an example where it worked for you that would be great.

Basically we have sqlfiles(ddl’s) providing access to different roles. roles changes depending on the environment like dev,test,prod. We want to reuse these ddls instead of writing them multiple times. If my approach is out of context for this requirement can you please provide a feasible solution.