Database Manager - editing timestamp fields

Am I doing something wrong with this field addition

I would like a default value for current_timestamp and if possible an ON Update Current_timestamp too.

Try with
1 Like

I think we have to improve setting the defaults to the Knex functions indeed as currently those are just passed as strings


@george, any updates on this?

I’m running into the same issue. I want every table to have a “CreatedDate” and “UpdatedDate” field. Both should default to current date/time when a record is created. Unfortunately, I’m unable to get past the error – even if I correct the knex file by removing the single quotes, save it, then try to push the changes, Wappler is modifying the file leading to the same error.

Modifying to this:

Becomes this after trying to push:


1 Like

Use timestamps.

timestampstable.timestamps([useTimestamps], [defaultToNow])

Adds created_at and updated_at columns on the database, setting each to datetime types. When true is passed as the first argument a timestamp type is used instead. Both colums default to being not null and using the current timestamp when true is passed as the second argument. Note that on MySQL the .timestamps() only have seconds precision, to get better precision use the .datetime or .timestamp methods directly with precision.

1 Like

@JonL that would work great for what I’m looking to do and save some time (you could even have a way to specify this for all tables), but I think Wappler could also figure out a way to allow for other methods in the default field for other scenarios.

1 Like

I agree 100%. I was just referring to your use case.

I also opened a FR for this:

1 Like