Can I specify values for placeholders in a Liquibase properties file?

Viewed 85

I have a working Liquibase setup with placeholders in the used SQL files to make the setup configurable for different environments.

Here is a example SQL file with a placeholder:

CREATE ROLE ${rolename};

As I run Liquibase, currently version 4.11.0, at development time with the help of Maven, I can specify the value for the placeholder rolename like this:

$ mvn -Drolename=therole 

Can I also specify this property in a Liquibase properties file? I tried, but failed. Therefore I would be very happy to see a working example.

1 Answers

It is possible to specify so called changelog parameters in the used Liquibase properties file, if the name of the changelog parameter will be prefixed with parameter..

For the placeholder rolename from the initial question, a matching Liquibase properties file will look like this:

parameter.rolename: theRole

See https://docs.liquibase.com/concepts/connections/creating-config-properties.html for more information on this topic.

Related