'Liquibase context in changeset
The text below is from liquibase's contexts
page https://docs.liquibase.com/concepts/changelogs/attributes/contexts.html
By default, a database update runs all changesets in the changelog, regardless of what you specify in the CLI.
If you add a context to a changeset, it only runs when you specify that context in the CLI, but unmarked changesets still run.
If you do not specify any contexts in the CLI at runtime, every changeset in your changelog runs, even if they have contexts attached.
I'm confused by the second and third statements - I find them contradictory.
According to the second statement, if I have a context defined in a changeset, it will only run when specifying the context in the CLI but the third statement mentions all changesets are run even if contexts are attached and not specified in the CLI.
Solution 1:[1]
The documentation is worded rather ambiguously.
The correct behavior can be explained with the following pseudo steps:
If changeset X1 has context Y1 and Y1 is not mentioned as an argument in CLI:
-
- If at least one other context Y2 is mentioned as an argument: X1 does not run
-
- If no other Y2 is mentioned: X1 runs
Else if X1 has no contexts attached:
-
- If any context is mentioned as an argument: X1 does not run
-
- Else X1 runs
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | gsan |