I want to automate some migration processes for stack: Java, Maven, Spring-Boot, Postgres, Liquibase.
Is it possible to postpone some liquibase change logs until a specific maven module version?
Example:
- changes:
- changelog1.yaml
- changelog2.yaml
- 2.1: # Executed during deployment of version 2.1
- changelog3.yaml
- changelog4.yaml
- 2.2: # Executed during deployment of version 2.2
- changelog5.yaml
- changelog6.yaml
In the case of deployment 2.0, only the first 2 change logs will be applied.
Any idea how to do it?
Advertisement
Answer
Liquibase Labels allow you to choose a subset of changesets to execute at the runtime.
Labels can be specified using AND, OR, !, and () (parentheses that are used for grouping). For example:
labels="!v.2.1" labels="v.2.0 and v.2.1" labels="v.2.0 or v.2.1" labels="!v.2.0 and !v.2.1"
Where the version could be the maven module version in your case.