Liquibase - Add defaultValueComputed as CURRENT_TIMESTAMP to timestamp column
Add type as 'TIMESTAMP' as following
<column defaultValueComputed="CURRENT_TIMESTAMP" name="Created_Time" type="TIMESTAMP"/>
This is a weird scenario causes by how liquibase handles DateTime defaultValueComputed
or defaultValueDate
.
In short anything that starts with current_timestamp
or the default function on your target engine to get the current timestamp will replace *the whole string* by only the default function call ignoring anything else you put.
We ended up with something like this:
<column name="created_at" type="datetime"
defaultValueComputed="NOW()">
<constraints nullable="false" />
</column>
<column name="updated_at" type="datetime"
defaultValueComputed="NOW() ON UPDATE NOW()">
<constraints nullable="false" />
</column>
LiquibaseDataType helper function