Search code examples
mysqlliquibase

Adding 1 day from the current date in liquibase property


I need to insert a date by adding 1 day to the current date using Liquibase. I'm using Liquibase property for this. But it is always inserting the current date.

Following is the property I'm using

<property name="now" value="now() + interval 1 day" dbms="mysql" />

I also tried

<property name="now" value="now() + interval '1 day'" dbms="mysql" />

didn't work either.

In my changeset I've the insert script

<insert tableName="test">
            
     <column name="start_date" value="${now}"/>
          
</insert>

Solution

  • The following worked for me

    <property name="now" value="now()" dbms="mysql" />
    

    In changeSet

    <insert tableName="test">
          <column name="start_date" valueComputed="DATE_ADD(${now}, INTERVAL 1 DAY)"/>
    </insert>