Can liquibase have configuration placeholders in sql?
Example code:
<changeSet author="name" id="sql-example" runAlways="true" failOnError="true">
<sql>SELECT schema.admin_insert('PARAMETER_PLACEHOLDER')</sql>
</changeSet>
Can I define parameter value in properties file; so that liquibase replace the value of the argument from a properties file ?
Liquibase (LB) is an open source tool written in Java. It makes defining database changes easy, in a format that's familiar and comfortable to each user. Then, it automatically generates database-specific SQL for you. Database changes (every change is called changeset) are managed in files called changelogs.
The changeset tag is a unit of change that Liquibase executes on a database and which is used to group database Liquibase Change Types together. A list of changes created by multiple changesets are tracked in a changelog.
In Liquibase there is no "create schema" tag, because it is designed to manage objects within the application's schema. However, we can use a custom SQL statement inside a 'sql' tag to make a creation of a schema a part of our migration.
Yes, you can. Liquibase calls these "Changelog Parameters"
http://www.liquibase.org/documentation/changelog_parameters.html
A short excerpt from that page:
Liquibase allows dynamic substitution of parameters in a changelog. The parameters to replace are described using the
${parameterName}
syntax.Configuring parameter values
Parameter values are looked up in the following order:
- Passed as a parameter to your Liquibase runner (see Ant, command_line, etc. documentation for how to pass them)
- As a JVM system property
- In the parameters block (
<property>
Tag) of the DatabaseChangeLog file itself.
Example
<createTable tableName="${table.name}">
<column name="id" type="int"/>
<column name="${column1.name}" type="varchar(${column1.length})"/>
<column name="${column2.name}" type="int"/>
</createTable>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With