diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2024-03-10 20:31:56 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2024-03-10 20:31:56 +0900 |
commit | 516117207bbb3cca9723651b73941a2d1a5dca53 (patch) | |
tree | 14f77a11b8bd536f2e1e4814d499ce715264b9ef /deploy | |
parent | f1ffe938b95a274c550b67674fbd7a10fcaeee9a (diff) |
Add function to update `updated_at` column.
Diffstat (limited to 'deploy')
-rw-r--r-- | deploy/update_updated_at.sql | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/deploy/update_updated_at.sql b/deploy/update_updated_at.sql new file mode 100644 index 0000000..a41d27f --- /dev/null +++ b/deploy/update_updated_at.sql @@ -0,0 +1,15 @@ +-- Deploy diary:update_updated_at to pg +-- requires: schema + +BEGIN; + +SET search_path to diary; + +CREATE OR REPLACE FUNCTION update_updated_at() RETURNS TRIGGER AS $$ + BEGIN + NEW.updated_at = NOW(); + RETURN NEW; + END; +$$ LANGUAGE plpgsql; + +COMMIT; |