# Match all but one context

**URL:** <https://forum.liquibase.org/t/match-all-but-one-context/10316>\
**Category:** General Discussion\
**Created:** [March 17, 2025, 4:31pm UTC](https://forum.liquibase.org/t/match-all-but-one-context/10316 "2025-03-17T16:31:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eseyfarth](https://avatars.discourse-cdn.com/v4/letter/e/35a633/32.png) [@eseyfarth](https://forum.liquibase.org/u/eseyfarth)\
**Post date:** [March 17, 2025, 4:31pm UTC](https://forum.liquibase.org/t/match-all-but-one-context/10316/1 "2025-03-17T16:31:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Pete](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/pete/32/184_2.png) [@Pete](https://forum.liquibase.org/u/Pete)\
**Post date:** [March 18, 2025, 3:26pm UTC](https://forum.liquibase.org/t/match-all-but-one-context/10316/2 "2025-03-18T15:26:35Z")

</div>

Welcome to the forum @eseyfarth!

[The doc page on contexts](https://docs.liquibase.com/concepts/changelogs/attributes/contexts.html) 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"`

Hope that helps!

---

<div class="post-metadata">

**Author:** ![eseyfarth](https://avatars.discourse-cdn.com/v4/letter/e/35a633/32.png) [@eseyfarth](https://forum.liquibase.org/u/eseyfarth)\
**Post date:** [May 19, 2025, 11:49am UTC](https://forum.liquibase.org/t/match-all-but-one-context/10316/3 "2025-05-19T11:49:20Z")

</div>

For all who are interested in the final solution:

I marked all sample data with context “@samples”.  
That way they only run when context samples is **explicitly** specified.

And then what @Pete said:  
For running all contexts excluding samples just run update without specifying a context.  
When you want to have samples, just run another **additional** update specifying samples in context.

---

<div class="post-metadata">

**Author:** ![Pete](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/pete/32/184_2.png) [@Pete](https://forum.liquibase.org/u/Pete)\
**Post date:** [May 19, 2025, 7:59pm UTC](https://forum.liquibase.org/t/match-all-but-one-context/10316/4 "2025-05-19T19:59:10Z")

</div>

Glad you got it squared away @eseyfarth!
