Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using profiles in liquibase

I am using Liquibase and would like to execute the same script in two different variants (production and tests):

<changeSet author="..." id="...">   
    <insert tableName="...">
            <column name="ACTIVE" value="${isActive}" />
    </insert>
</changeset>

Currently, I use a property to steer this in two files:

<!--File1: For production --> 
<property name="isActive" value="true"/>

<!--File2: For tests--> 
<property name="isActive" value="false"/>

Is there a way to use something like a profile (as in Maven) or use command line arguments in Liquibase? I would like to avoid the handling of two different files, one for the production and one for the test systems.

like image 581
user2722077 Avatar asked Nov 11 '15 07:11

user2722077


1 Answers

You may specify context parameter for property or changeSet itself:

<property name="isActive" value="true" context="prod"/>
<property name="isActive" value="false" context="test"/>

Then pass the context parameter to liquibase in some way:

mvn liquibase:migrate -Dliquibase.contexts=prod
like image 168
dfche Avatar answered Sep 30 '22 14:09

dfche