From c5f39ea2cd7cf02246705ea8872d3b350526165c Mon Sep 17 00:00:00 2001
From: Freya Murphy <freya@freyacat.org>
Date: Fri, 24 May 2024 09:05:42 -0400
Subject: initial

---
 src/db/rev.sql | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 src/db/rev.sql

(limited to 'src/db/rev.sql')

diff --git a/src/db/rev.sql b/src/db/rev.sql
new file mode 100644
index 0000000..bd02f3d
--- /dev/null
+++ b/src/db/rev.sql
@@ -0,0 +1,21 @@
+CREATE OR REPLACE FUNCTION curr_revision()
+RETURNS INTEGER
+LANGUAGE plpgsql VOLATILE
+AS $BODY$
+DECLARE
+	_revision INTEGER;
+BEGIN
+	BEGIN
+		SELECT curr_revision INTO _revision
+			FROM sys.database_info
+			WHERE name = current_database();
+		RETURN _revision;
+	EXCEPTION WHEN OTHERS THEN
+		RETURN 0;
+	END;
+END
+$BODY$;
+
+GRANT EXECUTE ON FUNCTION curr_revision() TO website;
+
+SELECT curr_revision();
-- 
cgit v1.2.3-freya

