liquibaseliquibase-sql

How to Update a Database table column to constraint nullable='true' | Liquibase


In liquibase, I created a table, one of column is like below

<column name="identifier" type=""varchar2(50)">
    <constraint nullable="false"/>
</column>

This changeset is already executed

Now I need to set this column as

<constraint nullable="true"/>  

I am using MySql


Solution

  • If you want to change a column to nullable='true' in Liquibase, you can use the modifyColumn tag.

    <modifyColumn tableName="table_name">
        <column name="identifier" type="varchar2(50)">
            <constraint nullable="true"/>
        </column>
    </modifyColumn>
    

    Note: in Mysql, the equivalent for varchar2 is varchar; So ur modifyColumn tag should look like this:

    <modifyColumn tableName="table_name">
        <column name="identifier" type="varchar(50)">
            <constraint nullable="true"/>
        </column>
    </modifyColumn>