Liquibase: How to set the default value of a date column to be “now” in UTC format?

前端 未结 6 555
忘掉有多难
忘掉有多难 2021-01-07 16:20

How do you set the default value of a date column to be \"now\" in UTC format? I think the answer involves the defaultValueComputed attribute on the column elem

6条回答
  •  一向
    一向 (楼主)
    2021-01-07 16:47

    In MySQL, to use a DATETIME column with fractions of second like DATETIME(6) (microseconds precision), use default value of NOW(6) (caution: CURRENT_TIMESTAMP(6) for some reason produces an error with me using liquibase 3.5.3):

    
       
    
    

    Note that the value will be stored internally in UTC, but read using the server's timezone settings (@@global.time_zone, @@session.time_zone).

提交回复
热议问题