Substituting Properties in Changelogs
Learn how to substitute properties in Liquibase changelogs using built-in and custom configurations in Harness DB DevOps.
It allows you to define placeholders in your changelog files (such as ${property.name}) and later replace these placeholders with actual values when the changelog is executed. This mechanism is especially useful for managing configurations and ensuring flexibility in database migration scripts.
It decouples your database migration logic from environment-specific values, making the whole process of versioning and deploying database changes far more efficient and scalable.
Uses
Environment-specific Names
Reusability
Separation of Concerns
Consistency Across Environments
Dynamic Configuration
Let us have a look at the below example to understand the above-mentioned uses.
Here is the YAML for the example:
Property substitution in changelogs
You can set property values from the instance, while creating & updating the instance. Here is the process:
The tokens of above example will get replaced by the property values, once you run update command.
Property substitution behavior
Unresolved properties
If the content of ${property-name} does not match a property, it is left as-is, and it is not removed. Once a property has been set, it cannot be changed. Only the first definition is used, others will fail with checksum error.
Let us look at the below changeset:
if ${column.updatedBy} is missing in substitute properties, the token will not be replaced, and it is left as-is:
Escape property substitution
If you do not want a ${property-name} placeholder to be replaced, add a colon : right after the ${.
For example, ${:property-name} will always stay as ${property-name}, even if property-name is defined. It is often useful when you want to show an example without real substitution:
Next steps
Go to Runtime secrets to pass sensitive values into changelogs at execution time.
Go to Tag database changeset to tag changesets for rollback and tracking.
Go to Get started with changelogs to learn how changelogs are structured and executed in Harness Database DevOps.
Last updated
Was this helpful?