I have the following postgres column definition:
record_time TIMESTAMP WITHOUT TIME ZONE DEFAULT now()
How would I map it to slick? Please take into account that I wish to map the default value generated by the now()
function
i.e:
def recordTimestamp: Rep[Date] = column[Date]("record_time", ...???...)
Should any extra definition go where the ...???...
is currently located?
EDIT (1)
I do not want to use
column[Date]("record_time", O.Default(new Date(System.currentTimeMillis()))) // or some such applicative generation of the date column value
I found a blog explaining that you can use the following:
// slick 3
import slick.profile.SqlProfile.ColumnOption.SqlType
def created = column[Timestamp]("created", SqlType("timestamp not null default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP"))
// slick 3
def createdAt = column[Timestamp]("createdAt", O.NotNull, O.DBType("timestamp default now()"))
see: http://queirozf.com/entries/scala-slick-dealing-with-datetime-timestamp-attributes
I guess this is not supported yet. Here is issue: https://github.com/slick/slick/issues/214
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With