From 6d6f4546b0cda266e6f5e6f2cda783da985dfb00 Mon Sep 17 00:00:00 2001
From: Masaya Tojo <masaya@tojo.tokyo>
Date: Wed, 30 Aug 2023 00:10:06 +0900
Subject: Add function to update timestamp

---
 deploy/update_timestamp.sql | 15 +++++++++++++++
 1 file changed, 15 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..7bcec3c
--- /dev/null
+++ b/deploy/update_timestamp.sql
@@ -0,0 +1,15 @@
+-- Deploy photos:update_timestamp to pg
+-- requires: schema
+
+BEGIN;
+
+SET search_path to photos;
+
+CREATE OR REPLACE FUNCTION update_timestamp() RETURNS TRIGGER AS $$
+  BEGIN
+    NEW.updated_at = NOW();
+    RETURN NEW;
+  END;
+$$ LANGUAGE plpgsql;
+
+COMMIT;
-- 
cgit v1.2.3

