bkolasa
bkolasa

Reputation: 75

Multiple contexts in Liquibase sql format file

I'm trying to use multiple contexts support in Liquibase and I can't achieve the result. My changeset in SQL format looks as follows

--changeset bkolasa:1 context:new-db and !edb dbms:postgresql

Then when I execute command

java -jar liquibase.jar --contexts=new-db,edb --driver=org.postgresql.Driver --url=jdbc:postgresql://example.com:5432/liqtest?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory --username=liqtest --password=liqtest --changeLogFile=mychangelog.sql update

the changeset is still loaded.

My version of Liquibase is 3.2.2.

Upvotes: 4

Views: 5698

Answers (4)

Vayuj Rajan
Vayuj Rajan

Reputation: 107

–context=dev,qa worked for me. With Liquibase 3.2, support was added to for context expressions in changeSets. An example: context=”qa or (dev and release)”

Newer versions have label which can be used for complex business cases.

Upvotes: 1

jmgonet
jmgonet

Reputation: 1261

If you want a change set to be executed in two contexts, namely dev and test, you probably want to use or instead of and:

  • or requires only one of the contexts.
  • and requires all contexts.

For example, the following change set will be applied in dev context, and it will also be applied in the test context:

-- changeset istepniak:db-1.14.1 context:dev or test

Instead, the following change set needs both contexts to be present:

-- changeset istepniak:db-1.14.1 context:dev and oracle

Upvotes: 0

Iga Stępniak
Iga Stępniak

Reputation: 136

-- changeset istepniak:db-1.14.1 context:dev and test

This works for me

Upvotes: 3

lukfi
lukfi

Reputation: 319

Have you tried specifying the context at runtime as follows?

--contexts="new-db and edb"

Upvotes: 0

Related Questions