Created
August 28, 2018 11:39
-
-
Save shahidhk/624c094e21a241d25734362b7e533705 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE FUNCTION update_last_seen_timestamp_func() RETURNS trigger | |
| LANGUAGE plpgsql | |
| AS $$ | |
| BEGIN | |
| NEW.last_seen_at := now(); | |
| RETURN NEW; | |
| END; | |
| $$; | |
| CREATE TRIGGER update_last_seen_timestamp_trigger | |
| BEFORE INSERT OR UPDATE ON "user" FOR EACH ROW | |
| EXECUTE PROCEDURE update_last_seen_timestamp_func(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment