Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify defaultValue to "now" for a timestamp column in Propel?

Here is my table definition for Propel schema. Column modified has timestamp type (DateTime in PHP) and I'd like to assign a default value to now. I've tried setting it to "now" but I'm getting an error using propel-gen insert-sql command:

"Syntaxt error or access violation: 1067 Invalid default value for 'modified'.

Anyone knows how I can set default value to now for a timestamp column in Propel?

<table name="mashup_setting">
   <!-- omitted previous column definition -->
   <column name="modified" type="timestamp" required="true" defaultValue="now" />
</table>
like image 211
gremo Avatar asked Feb 06 '12 19:02

gremo


1 Answers

In newer Propel versions you can specify you column like so:

<column name="created" type="TIMESTAMP" defaultExpr="CURRENT_TIMESTAMP" />

It's then cross-db compatible.

like image 200
Marc J. Schmidt Avatar answered Oct 13 '22 12:10

Marc J. Schmidt