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.sql | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'deploy/update_timestamp.sql')

diff --git a/deploy/update_timestamp.sql b/deploy/update_timestamp.sql
index c84ca69..eac2a44 100644
--- a/deploy/update_timestamp.sql
+++ b/deploy/update_timestamp.sql
@@ -3,6 +3,13 @@
 
 BEGIN;
 
+CREATE OR REPLACE FUNCTION common.update_timestamp() RETURNS TRIGGER AS $$
+  BEGIN
+    NEW.updated_at = NOW();
+    RETURN NEW;
+  END;
+$$ LANGUAGE plpgsql;
+
 CREATE OR REPLACE FUNCTION kakeibo.update_timestamp() RETURNS TRIGGER AS $$
   BEGIN
     NEW.updated_at = NOW();
@@ -10,4 +17,5 @@ CREATE OR REPLACE FUNCTION kakeibo.update_timestamp() RETURNS TRIGGER AS $$
   END;
 $$ LANGUAGE plpgsql;
 
+
 COMMIT;
-- 
cgit v1.2.3

