How to use custom liquibase context - what contexts does Jmix use?

I want to have some custom liquibase scripts that are ment for local development only.

They will insert some tenants and users to bootstrap a developers environment.

I added a specific liquibase context

   <changeSet author="LiquiBaseHelper" context="local-test-data" id="1" objectQuotingStrategy="LEGACY">-->

and I activate this in my application-local.yml

main.liquibase.contexts: local-test-data

The problem is that if you don’t specify a context in an application config, it liquibase executes all contexts.

I don’t know what contexts are used by jmix and it’s addons. I searched in the code and I found “!cuba” in some of the dependencies.

I have another project, that I migrated from cuba a long time ago. There I did something similar and have this in the config. that seems to work, but I can’t see who added the migrated (me or jmix).

main.liquibase.contexts=migrated, test-data

So,
What contexts are specified by jmix and it’s dependencies?
Can I just add any random context and everything should work?

Yeah, Liquibase does have this nasty behavior.

In one of my recent projects I’ve set the following property in application.properties, to make sure that some context is always set in all environments:

# without this, Liquibase would run all changesets, even if they are marked for particular context
main.liquibase.contexts = none

And I override this property in profile-specific file, e.g. in application-dev.properties :

main.liquibase.contexts = dev

None, AFAIK, except projects migrated from CUBA.

1 Like

Hi

To make Liquibase run some changeset only if specific context set in application config you can add @ before context name in changeset.
E.g.
<changeSet author="LiquiBaseHelper" context="@local-test-data" id="1" objectQuotingStrategy="LEGACY">

Changeset will be executed only if local-test-data context is set in application and filtered out otherwise.

1 Like