From 72d0dea1c23d16a6258d37b52d7885b387ec10cc Mon Sep 17 00:00:00 2001
From: Masaya Tojo <masaya@tojo.tokyo>
Date: Sun, 12 Mar 2023 23:04:05 +0900
Subject: Add function to update timestamp.

---
 deploy/update_timestamp.sql | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 deploy/update_timestamp.sql

(limited to 'deploy/update_timestamp.sql')

diff --git a/deploy/update_timestamp.sql b/deploy/update_timestamp.sql
new file mode 100644
index 0000000..c84ca69
--- /dev/null
+++ b/deploy/update_timestamp.sql
@@ -0,0 +1,13 @@
+-- Deploy kakeibo:update_timestamp to pg
+-- requires: schema
+
+BEGIN;
+
+CREATE OR REPLACE FUNCTION kakeibo.update_timestamp() RETURNS TRIGGER AS $$
+  BEGIN
+    NEW.updated_at = NOW();
+    RETURN NEW;
+  END;
+$$ LANGUAGE plpgsql;
+
+COMMIT;
-- 
cgit v1.2.3

