I've just created a Postgres database and table ('users'). My table has a created_at
column of type:
TIMESTAMP WITH TIME ZONE NOT NULL;
I basically want to use this column to keep track of when a new user is created. Is there a way to have Postgres automatically update this with each insert or do I have to supply it a value for this on every insert?
(I want to say when using it before with Sequelize, it created this automatically - so wondering if this was done through Sequelize as a default when inserting).
Thank you!
You can declare a timestamp field to automatically be filled with the current time on INSERT by including the DEFAULT now()
clause in your column definition.
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