From 3cfbd44f45098853cb8419bf61059f80c62466fd Mon Sep 17 00:00:00 2001
From: Masaya Tojo <masaya@tojo.tokyo>
Date: Tue, 28 Mar 2023 00:04:59 +0900
Subject: Add update_timestamp to common schema.

---
 deploy/update_timestamp@v1.0.0-alpha.2.sql | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 deploy/update_timestamp@v1.0.0-alpha.2.sql

(limited to 'deploy/update_timestamp@v1.0.0-alpha.2.sql')

diff --git a/deploy/update_timestamp@v1.0.0-alpha.2.sql b/deploy/update_timestamp@v1.0.0-alpha.2.sql
new file mode 100644
index 0000000..c84ca69
--- /dev/null
+++ b/deploy/update_timestamp@v1.0.0-alpha.2.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

