-1

Is it possible to create two preconditons for single elements of a changeset? Like generating a column if the changelog file is run at a SQL Server database and generating another column if the changelog file is run at an Oracle database. In a way like this for example:

<changeSet author="Me" id="1528876614155">
 <createTable tableName="ELECTRICITY_PRODUCTS">

   <preConditions onFail="MARK_RAN" onSqlOutput="TEST">
        <dbms type="mssql" />
        <column autoIncrement="true" name="EP_ID" type="NUMBER">
   </preConditions>
   <preConditions onFail="MARK_RAN" onSqlOutput="TEST">
        <dbms type="oracle" />
        <column autoIncrement="false" name="EP_ID" type="FLOAT">
   </preConditions>
 </createTable>
</changeset>
Mad Scientist
  • 857
  • 4
  • 16
  • 43

2 Answers2

2

It's not possible to create column inside condition.

If I understand your problem, then you have two (maybe more) options:

  1. Separte the changeSets for each dbms
  2. Create property for dbms and use them like:

    <property dbms="oracle" name="autoincrement" value="true" />
    <property dbms="oracle" name="autoincrementType" value="NUMBER" />
    <property dbms="mssql" name="autoincrement" value="false" />
    <property dbms="mssql" name="autoincrementType" value="FLOAT" />
    
    
    <changeSet id="create_a_table" author="system">
        <createTable tableName="a_table">
            <column name="a_column" autoIncrement="${autoincrement}" type="${autoincrementType}" />
        </createTable>
    </changeSet>
    

I didn't tested that, it's just idea how to solve the problem.

bilak
  • 4,526
  • 3
  • 35
  • 75
0

This seems to be not possible but another good solution is to create changesets for these single elements. In this example it could be:

<changeSet author="Me" id="1528876614155">
    <createTable tableName="DAILY DATA">
        <column name="ID" type="NUMBER"/>
    </createTable>
</changeset>

<changeSet author="Me" id="1528876614156">
    <preConditions onFail="MARK_RAN" onSqlOutput="TEST">
        <dbms type="oracle" />
    </preConditions>
    <addColumn tableName="DAILY_DATA">
        <column name="VALUE" type="NUMBER"/>
    </addColumn>
</changeset>
<changeSet author="Me" id="1528876614157">
    <preConditions onFail="MARK_RAN" onSqlOutput="TEST">
        <dbms type="mssql" />
    </preConditions>
    <addColumn tableName="DAILY_DATA">
        <column name="VALUE" type="NUMBER"/>
    </addColumn>
</changeset>
Mad Scientist
  • 857
  • 4
  • 16
  • 43