0

I'm trying to execute one of two insert depending on value of Java system property 'type'. But when I run updateSQL, it generates both insert entries despite of value and even presence of variable 'type'. This are my change sets:

 <!--changes for CS only-->
    <changeSet id="57" author="mborodin">
        <preConditions onFail="CONTINUE">
            <changeLogPropertyDefined property="type" value="cs"/>
        </preConditions>
        <sql>INSERT INTO cs.config(key, value) values('autochecks.findProfilesInDb', 'true'),
                ('web.type', 'cs'), ('globalFailureDetectorEnabled', 'true');
         </sql>
    </changeSet>

    <!--changes for LCS only-->
    <changeSet id="58" author="mborodin">
        <preConditions onFail="CONTINUE">
            <and>
                <changeLogPropertyDefined property="type" value="lcs"/>
                <not>
                    <changeSetExecuted
                            id="57"
                            author="mborodin"
                            changeLogFile="${changeLogFile}"
                            />
                </not>
            </and>
        </preConditions>
        <sql>INSERT INTO cs.config(key, value) values('autochecks.findProfilesInDb', 'false'),
            ('web.type', 'local-cs'), ('globalFailureDetectorEnabled', 'false');
        </sql>
    </changeSet>

What's wrong? Is there a better way to work it?

Borodin.Mik
  • 332
  • 1
  • 4
  • 11

1 Answers1

1

From the first nvoxland's answer at liquibase forum:

… we added the onSqlOutput tag. IGNORE just assumes that the precondition cannot be applied, but you should continue to "run" the changeLog. TEST means to actually run the precondition. FAIL mean to stop the execution of the changelog, alerting you that you cannot run in updateSql mode because a correct execution of the precondtion is required to continue.

The problem has been solved by adding onSqlOutput="TEST" tag.

Borodin.Mik
  • 332
  • 1
  • 4
  • 11