You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may be a bit complex, but there is a "standardized" way of handling an updated_at column in postgres.
The idea is you create a function like this:
CREATE FUNCTION update_updated_at_column() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
This only has to be done once per database.
And then attach it to the column when it's created like this:
CREATE TRIGGER sometable_update_trigger BEFORE UPDATE ON sometable FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
I'm doing this manually in migrations right now but it would be really cool if Phinx could do this automatically as part of the addTimestamps and addTimestampsWithTimezone calls.
The text was updated successfully, but these errors were encountered:
This may be a bit complex, but there is a "standardized" way of handling an
updated_at
column in postgres.The idea is you create a function like this:
This only has to be done once per database.
And then attach it to the column when it's created like this:
I'm doing this manually in migrations right now but it would be really cool if Phinx could do this automatically as part of the
addTimestamps
andaddTimestampsWithTimezone
calls.The text was updated successfully, but these errors were encountered: