Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting null values with liquibase

We use liquibase to manage one of our MySQL databases' updates, rollbacks, etc.

One small curiosity I've come across is the process of setting values to null in the course of updates or rollbacks. Example:

        <rollback>
            <update tableName="boats">
                <column name="engine" value="null" />
                <column name="oars" value="2" />

At first I was a bit worried that "null" would literally insert the string "null", but it turns out that liquibase seems to have some smarts that actually inserts a null value.

I was wondering if this was the recommended way of doing this, or whether there is a platform-agnostic way of saying 'nullValue' explicitly within Liquibase?

like image 718
f1dave Avatar asked May 01 '18 01:05

f1dave


1 Answers

Just omit the value attribute on <column>:

<rollback>
    <update tableName="boats">
        <column name="engine" type="varchar(255)"/>
    </update>
</rollback>

Reference: Update

like image 90
George Aristy Avatar answered Oct 21 '22 13:10

George Aristy