database icon indicating copy to clipboard operation
database copied to clipboard

Timestamp field with default value on creation

Open mcasto opened this issue 4 years ago • 3 comments

I'm trying to create a timestamp field that defaults to the current timestamp (a "created_at" field).

I've tried ->defaultValue('CURRENT_TIMESTAMP') and ->defaultValue('NOW()') ... both return errors saying it's an invalid default value.

I can't find anything about this situation in the documentation, but it seems like a common enough task that it should be pretty simple ... and I suspect I'm missing something obvious.

Thanks in advance.

mcasto avatar Jan 15 '22 00:01 mcasto

Stuck with the same issue, did you find a solution ?

debuss avatar Sep 07 '22 20:09 debuss

No. I wound up going into the DB directly and creating the table with SQL. A slight inconvenience, but easy enough. It does seem like this should be something Opis is set up for.

mcasto avatar Sep 08 '22 12:09 mcasto

I ended up doing the same, thanks for the feedback ;)

debuss avatar Sep 08 '22 20:09 debuss