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.

---
 revert/update_timestamp.sql | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

(limited to 'revert/update_timestamp.sql')

diff --git a/revert/update_timestamp.sql b/revert/update_timestamp.sql
index 07074ac..30f9c6d 100644
--- a/revert/update_timestamp.sql
+++ b/revert/update_timestamp.sql
@@ -1,7 +1,14 @@
--- Revert kakeibo:update_timestamp from pg
+-- Deploy kakeibo:update_timestamp to pg
+-- requires: schema
 
 BEGIN;
 
-DROP FUNCTION kakeibo.update_timestamp;
+DROP FUNCTION common.update_timestamp();
+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

