mysql - Default Value ON UPDATE Liquibase -
i using liquibase generating mysql , hsqldb databases.
in several tables have column called 'last_modified' timestamp of last update on particular record.
<changeset author="bob" id="7"> <createtable tablename="mytable"> <column autoincrement="true" name="id" type="int"> <constraints nullable="false" primarykey="true" /> </column> <column name="name" type="varchar(128)"> <constraints nullable="false" /> </column> <column name="description" type="varchar(512)" /> <column defaultvalueboolean="true" name="enabled" type="bit"> <constraints nullable="false" /> </column> <column name="last_modified" type="timestamp"/> </createtable> <modifysql dbms="mysql"> <append value=" engine innodb" /> </modifysql> </changeset> i noticed if use mysql, generated sql column is:
`last_modified` timestamp not null default current_timestamp on update current_timestamp, while if use hsqldb, in case of update nothing happens, have same behaviour of mysql database default value on update equals current_timestamp.
how can set current_timestamp default value on update?
you can't default value. mysql behaviour non-standard , not supported other databases. proper way trigger defined before update , sets timestamp each time row updated.
Comments
Post a Comment