Passing Runtime Variables to SQL files

Hello All, We have recently started using Liquibase, I would like to know if it is possible to pass runtime variables to SQL scripts in Liquibase. For examples I have &schema_name in my script, can I store this value in the properties file and call it out during the script execution.

Hi Karthik,

It is possible to pass runtime variables in Liquibase but the required format of the runtime variable is different than the patterns used by the DBMS you are using. Here’s the documentation link: https://docs.liquibase.com/concepts/basic/changelog-parameters.html?Highlight=parameters

To summarize, the variable would be expressed like this ${schema_name} in the SQL. Depending on how you are running Liquibase, you can pass in the value at runtime in a few different ways that are listed in the doc page above.

Hope that helps!

Thank you Pete.

Is this supported in Liquibase Open Source Version?

Regards,
Karthik.

Yes I believe it should be.

Thank you so much Pete , it s working perfectly.

1 Like