altering my sql table to add multiple new columns at once using liquibase

smart987 picture smart987 · Oct 8, 2015 · Viewed 11.4k times · Source

What is the correct syntax to alter the table and adding multiple columns at a time using liquibase xml. The official document gives the example for adding only one column :

<changeSet author="liquibase-docs" id="addColumn-example">
    <addColumn catalogName="cat"
            schemaName="public"
            tableName="person">
        <column name="address" type="varchar(255)"/>
    </addColumn>
</changeSet>

Now if I want to add multiple columns at a time, what is the correct syntax:

<changeSet author="liquibase-docs" id="addColumn-example">
    <addColumn catalogName="cat"
            schemaName="public"
            tableName="person">
        <column name="job" type="varchar(255)"/>
    </addColumn>
    <addColumn catalogName="cat"
            schemaName="public"
            tableName="person">
        <column name="designation" type="varchar(255)"/>
    </addColumn>
</changeSet>

Is it correct or

<changeSet author="liquibase-docs" id="addColumn-example">
    <addColumn catalogName="cat"
            schemaName="public"
            tableName="person">
        <column name="job" type="varchar(255)"/>
       <column name="designation" type="varchar(255)"/>
    </addColumn>   
</changeSet>

which is correct of the two above? or something different altogether.

Answer

SteveDonie picture SteveDonie · Oct 8, 2015

Both of those examples will work.