Exclude Contexts?

I have a number of changesets that load non-test data into the database.  Since they’re expensive to run, I’d prefer not to execute them when running tests.  It looks like contexts are one way to do this, however it appears that I can’t mark those data-loading changesets with a context and exclude them.  Instead, I’d have to mark all other changesets as being safe to run in the test environment and pass in that context.

Is there another way to do this with 1.9.5, say by using a system property?  Is excluding contexts on the roadmap for version 2?

Thanks,
David

If you specify a context at runtime, only changeSets with the given context and changes with no context will be ran.  So you could (for example) set your non-test data changeSets as context=“prod” and leave the rest with no context set.  That way if you run liquibase with context=prod they will run, but if you make up some other context, like context=test, they prod contexts will not run.

Nathan 

Aha, thanks for the explanation.

It has been quite a while since I added the context support, so I don’t remember my thoughts on it exactly at the time. I know the decision was partly based on wanting to make the logic more seamless from no context usage to context usage. I was also trying to avoid adding some sort of assumed context or context keyword/s which could get in the way of how people want to use contexts. If we assumed that no context means “only changSets with no context specified”, then there would need to be a assumed context like “all” which people would need to know and use for all of them. It would also mean that all liquibase update calls that used to assume that they would run everything because there were no contexts would now not run some without changing the update call.


Thinking about it at this point, in response to your question, I think I agree with you that it would be more logical in most cases for no context to just mean changesets with no context, especially having a better idea of how they have been used over the years. It better optimizes for people who have used contexts before, not for people who are new to them (and who are only new for a very small time).


That being said, there have been times where people’s usage of contexts have worked well having no context mean all, although I do not remember the cases off hand.


At this point, however, it is too late to change. At least until 3.0… :slight_smile:


Nathan

Something has always bothered me here.  If I do <span).  Our non-decorated changesets (no context on them) are the ones we want to run in production and there are tons of them.  Surely this is the most common use case?  Or have you experienced otherwise?

Curious to know the historical rationale here.

Best,
Laird