I have a bunch of changelogs that insert sample data, but sometimes I dont want to have sample data in the db.
So I marked all sample data with context “samples” and tried to run liquibase update --contexts="!samples". I hoped this would match all contexts that are not samples.
Turns out it does not match any contexts, only includes where context is not specified:
Does match: <include file="test"/>
Does not match: <include context="some_context" file="test"/>
How can I specify the desired behaviour to exclude the samples context but match all other contexts?
The doc page on contexts has a section on managing test data. According to that, you should run an update without specifying a --context parameter when you don’t want the changesets to be applied (like updates to prod) and you specify the context when you do want the changesets to be applied (like updates to dev or test).
When you want to skip test data try running a plain old update like liquibase update. When you want to execute the the test data changesets try running liquibase update --contexts="samples"